Mercurial > hg > truffle
comparison c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotXirGenerator.java @ 1427:149b1d2316de
basic invokeinterface and invokevirtual support
author | Lukas Stadler <lukas.stadler@oracle.com> |
---|---|
date | Wed, 18 Aug 2010 16:47:06 -0700 |
parents | ed6bd46ad55e |
children | 695451afc619 |
comparison
equal
deleted
inserted
replaced
1426:ed6bd46ad55e | 1427:149b1d2316de |
---|---|
36 public class HotSpotXirGenerator implements RiXirGenerator { | 36 public class HotSpotXirGenerator implements RiXirGenerator { |
37 | 37 |
38 // this needs to correspond to c1x_Compiler.hpp | 38 // this needs to correspond to c1x_Compiler.hpp |
39 private static final Integer MARK_VERIFIED_ENTRY = 1; | 39 private static final Integer MARK_VERIFIED_ENTRY = 1; |
40 private static final Integer MARK_UNVERIFIED_ENTRY = 2; | 40 private static final Integer MARK_UNVERIFIED_ENTRY = 2; |
41 private static final Integer MARK_OSR_ENTRY = 3; | |
41 private static final Integer MARK_STATIC_CALL_STUB = 1000; | 42 private static final Integer MARK_STATIC_CALL_STUB = 1000; |
43 | |
44 private static final Integer MARK_INVOKE_INVALID = 2000; | |
45 private static final Integer MARK_INVOKEINTERFACE = 2001; | |
46 private static final Integer MARK_INVOKESTATIC = 2002; | |
47 private static final Integer MARK_INVOKESPECIAL = 2003; | |
48 private static final Integer MARK_INVOKEVIRTUAL = 2004; | |
42 | 49 |
43 private final HotSpotVMConfig config; | 50 private final HotSpotVMConfig config; |
44 private final CiTarget target; | 51 private final CiTarget target; |
45 private final RiRegisterConfig registerConfig; | 52 private final RiRegisterConfig registerConfig; |
46 | 53 |
54 private XirTemplate epilogueTemplate; | 61 private XirTemplate epilogueTemplate; |
55 private XirTemplate arrayLengthTemplate; | 62 private XirTemplate arrayLengthTemplate; |
56 private XirTemplate exceptionObjectTemplate; | 63 private XirTemplate exceptionObjectTemplate; |
57 private XirTemplate invokeStaticTemplate; | 64 private XirTemplate invokeStaticTemplate; |
58 private XirTemplate invokeSpecialTemplate; | 65 private XirTemplate invokeSpecialTemplate; |
66 private XirTemplate invokeInterfaceTemplate; | |
67 private XirTemplate invokeVirtualTemplate; | |
59 private XirTemplate newInstanceTemplate; | 68 private XirTemplate newInstanceTemplate; |
60 | 69 |
61 static class XirPair { | 70 static class XirPair { |
62 | 71 |
63 final XirTemplate resolved; | 72 final XirTemplate resolved; |
120 exceptionObjectTemplate = buildExceptionObject(); | 129 exceptionObjectTemplate = buildExceptionObject(); |
121 instanceofTemplate = buildInstanceof(false); | 130 instanceofTemplate = buildInstanceof(false); |
122 instanceofTemplateNonnull = buildInstanceof(true); | 131 instanceofTemplateNonnull = buildInstanceof(true); |
123 invokeStaticTemplate = buildInvokeStatic(); | 132 invokeStaticTemplate = buildInvokeStatic(); |
124 invokeSpecialTemplate = buildInvokeSpecial(); | 133 invokeSpecialTemplate = buildInvokeSpecial(); |
134 invokeInterfaceTemplate = buildInvokeInterface(); | |
135 invokeVirtualTemplate = buildInvokeVirtual(); | |
125 newInstanceTemplate = buildNewInstance(); | 136 newInstanceTemplate = buildNewInstance(); |
126 | 137 |
127 return templates; | 138 return templates; |
128 } | 139 } |
129 | 140 |
131 asm.restart(CiKind.Void); | 142 asm.restart(CiKind.Void); |
132 XirOperand temp = asm.createRegister("temp (rax)", CiKind.Int, AMD64.rax); | 143 XirOperand temp = asm.createRegister("temp (rax)", CiKind.Int, AMD64.rax); |
133 XirOperand frame_pointer = asm.createRegister("frame pointer", CiKind.Word, AMD64.rbp); | 144 XirOperand frame_pointer = asm.createRegister("frame pointer", CiKind.Word, AMD64.rbp); |
134 | 145 |
135 asm.align(config.codeEntryAlignment); | 146 asm.align(config.codeEntryAlignment); |
147 asm.mark(MARK_OSR_ENTRY); | |
136 asm.mark(MARK_UNVERIFIED_ENTRY); | 148 asm.mark(MARK_UNVERIFIED_ENTRY); |
137 if (!staticMethod) { | 149 if (!staticMethod) { |
138 // TODO do some checking... | 150 // TODO do some checking... |
139 asm.add(temp, temp, asm.i(1)); | 151 asm.add(temp, temp, asm.i(1)); |
140 asm.sub(temp, temp, asm.i(1)); | 152 asm.sub(temp, temp, asm.i(1)); |
366 | 378 |
367 private XirTemplate buildInvokeStatic() { | 379 private XirTemplate buildInvokeStatic() { |
368 asm.restart(); | 380 asm.restart(); |
369 XirParameter addr = asm.createConstantInputParameter("addr", CiKind.Word); | 381 XirParameter addr = asm.createConstantInputParameter("addr", CiKind.Word); |
370 | 382 |
371 XirLabel stub = asm.createOutOfLineLabel("staticCallStub"); | 383 XirLabel stub = asm.createOutOfLineLabel("call stub"); |
384 asm.mark(MARK_INVOKESTATIC); | |
372 | 385 |
373 asm.bindOutOfLine(stub); | 386 asm.bindOutOfLine(stub); |
374 XirOperand method = asm.createRegister("method", CiKind.Word, AMD64.rbx); | 387 XirOperand method = asm.createRegister("method", CiKind.Word, AMD64.rbx); |
375 asm.mark(MARK_STATIC_CALL_STUB, XirMark.CALLSITE); | 388 asm.mark(MARK_STATIC_CALL_STUB, XirMark.CALLSITE); |
376 asm.mov(method, asm.w(0l)); | 389 asm.mov(method, asm.w(0l)); |
383 | 396 |
384 private XirTemplate buildInvokeSpecial() { | 397 private XirTemplate buildInvokeSpecial() { |
385 asm.restart(); | 398 asm.restart(); |
386 XirParameter addr = asm.createConstantInputParameter("addr", CiKind.Word); | 399 XirParameter addr = asm.createConstantInputParameter("addr", CiKind.Word); |
387 | 400 |
388 XirLabel stub = asm.createOutOfLineLabel("specialCallStub"); | 401 XirLabel stub = asm.createOutOfLineLabel("call stub"); |
402 asm.mark(MARK_INVOKESPECIAL); | |
389 | 403 |
390 asm.bindOutOfLine(stub); | 404 asm.bindOutOfLine(stub); |
391 XirOperand method = asm.createRegister("method", CiKind.Word, AMD64.rbx); | 405 XirOperand method = asm.createRegister("method", CiKind.Word, AMD64.rbx); |
392 asm.mark(MARK_STATIC_CALL_STUB, XirMark.CALLSITE); | 406 asm.mark(MARK_STATIC_CALL_STUB, XirMark.CALLSITE); |
393 asm.mov(method, asm.w(0l)); | 407 asm.mov(method, asm.w(0l)); |
396 asm.bindOutOfLine(dummy); | 410 asm.bindOutOfLine(dummy); |
397 | 411 |
398 return asm.finishTemplate(addr, "invokespecial"); | 412 return asm.finishTemplate(addr, "invokespecial"); |
399 } | 413 } |
400 | 414 |
415 private XirTemplate buildInvokeInterface() { | |
416 asm.restart(); | |
417 XirParameter addr = asm.createConstantInputParameter("addr", CiKind.Word); | |
418 XirOperand method = asm.createRegister("method", CiKind.Object, AMD64.rbx); | |
419 | |
420 XirLabel stub = asm.createOutOfLineLabel("call stub"); | |
421 asm.mark(MARK_INVOKEINTERFACE); | |
422 asm.mov(method, asm.createConstant(CiConstant.forObject(HotSpotProxy.DUMMY_CONSTANT_OBJ))); | |
423 | |
424 asm.bindOutOfLine(stub); | |
425 asm.mark(MARK_STATIC_CALL_STUB, XirMark.CALLSITE); | |
426 asm.mov(method, asm.w(0l)); | |
427 XirLabel dummy = asm.createOutOfLineLabel("dummy"); | |
428 asm.jmp(dummy); | |
429 asm.bindOutOfLine(dummy); | |
430 | |
431 return asm.finishTemplate(addr, "invokespecial"); | |
432 } | |
433 | |
434 private XirTemplate buildInvokeVirtual() { | |
435 asm.restart(); | |
436 XirParameter addr = asm.createConstantInputParameter("addr", CiKind.Word); | |
437 XirOperand method = asm.createRegister("method", CiKind.Object, AMD64.rbx); | |
438 | |
439 XirLabel stub = asm.createOutOfLineLabel("call stub"); | |
440 asm.mark(MARK_INVOKEVIRTUAL); | |
441 asm.mov(method, asm.createConstant(CiConstant.forObject(HotSpotProxy.DUMMY_CONSTANT_OBJ))); | |
442 | |
443 asm.bindOutOfLine(stub); | |
444 asm.mark(MARK_STATIC_CALL_STUB, XirMark.CALLSITE); | |
445 asm.mov(method, asm.w(0l)); | |
446 XirLabel dummy = asm.createOutOfLineLabel("dummy"); | |
447 asm.jmp(dummy); | |
448 asm.bindOutOfLine(dummy); | |
449 | |
450 return asm.finishTemplate(addr, "invokespecial"); | |
451 } | |
452 | |
401 private XirTemplate buildNewInstance() { | 453 private XirTemplate buildNewInstance() { |
402 XirOperand result = asm.restart(CiKind.Word); | 454 XirOperand result = asm.restart(CiKind.Word); |
403 XirOperand type = asm.createInputParameter("type", CiKind.Object); | 455 XirOperand type = asm.createInputParameter("type", CiKind.Object); |
404 XirOperand instanceSize = asm.createConstantInputParameter("instance size", CiKind.Word); | 456 XirOperand instanceSize = asm.createConstantInputParameter("instance size", CiKind.Word); |
405 | 457 |
513 return null; | 565 return null; |
514 } | 566 } |
515 | 567 |
516 @Override | 568 @Override |
517 public XirSnippet genInvokeInterface(XirSite site, XirArgument receiver, RiMethod method) { | 569 public XirSnippet genInvokeInterface(XirSite site, XirArgument receiver, RiMethod method) { |
518 return new XirSnippet(emptyTemplates[CiKind.Word.ordinal()]); | 570 return new XirSnippet(invokeInterfaceTemplate, XirArgument.forWord(0)); |
519 } | 571 } |
520 | 572 |
521 @Override | 573 @Override |
522 public XirSnippet genInvokeSpecial(XirSite site, XirArgument receiver, RiMethod method) { | 574 public XirSnippet genInvokeSpecial(XirSite site, XirArgument receiver, RiMethod method) { |
523 return new XirSnippet(invokeSpecialTemplate, XirArgument.forWord(0)); | 575 return new XirSnippet(invokeSpecialTemplate, XirArgument.forWord(0)); |
528 return new XirSnippet(invokeStaticTemplate, XirArgument.forWord(0)); | 580 return new XirSnippet(invokeStaticTemplate, XirArgument.forWord(0)); |
529 } | 581 } |
530 | 582 |
531 @Override | 583 @Override |
532 public XirSnippet genInvokeVirtual(XirSite site, XirArgument receiver, RiMethod method) { | 584 public XirSnippet genInvokeVirtual(XirSite site, XirArgument receiver, RiMethod method) { |
533 return new XirSnippet(emptyTemplates[CiKind.Word.ordinal()]); | 585 return new XirSnippet(invokeVirtualTemplate, XirArgument.forWord(0)); |
534 } | 586 } |
535 | 587 |
536 @Override | 588 @Override |
537 public XirSnippet genMonitorEnter(XirSite site, XirArgument receiver) { | 589 public XirSnippet genMonitorEnter(XirSite site, XirArgument receiver) { |
538 return new XirSnippet(emptyTemplates[CiKind.Void.ordinal()]); | 590 return new XirSnippet(emptyTemplates[CiKind.Void.ordinal()]); |