Mercurial > hg > truffle
diff 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 |
line wrap: on
line diff
--- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotXirGenerator.java Wed Aug 18 11:44:04 2010 -0700 +++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotXirGenerator.java Wed Aug 18 16:47:06 2010 -0700 @@ -38,8 +38,15 @@ // this needs to correspond to c1x_Compiler.hpp private static final Integer MARK_VERIFIED_ENTRY = 1; private static final Integer MARK_UNVERIFIED_ENTRY = 2; + private static final Integer MARK_OSR_ENTRY = 3; private static final Integer MARK_STATIC_CALL_STUB = 1000; + private static final Integer MARK_INVOKE_INVALID = 2000; + private static final Integer MARK_INVOKEINTERFACE = 2001; + private static final Integer MARK_INVOKESTATIC = 2002; + private static final Integer MARK_INVOKESPECIAL = 2003; + private static final Integer MARK_INVOKEVIRTUAL = 2004; + private final HotSpotVMConfig config; private final CiTarget target; private final RiRegisterConfig registerConfig; @@ -56,6 +63,8 @@ private XirTemplate exceptionObjectTemplate; private XirTemplate invokeStaticTemplate; private XirTemplate invokeSpecialTemplate; + private XirTemplate invokeInterfaceTemplate; + private XirTemplate invokeVirtualTemplate; private XirTemplate newInstanceTemplate; static class XirPair { @@ -122,6 +131,8 @@ instanceofTemplateNonnull = buildInstanceof(true); invokeStaticTemplate = buildInvokeStatic(); invokeSpecialTemplate = buildInvokeSpecial(); + invokeInterfaceTemplate = buildInvokeInterface(); + invokeVirtualTemplate = buildInvokeVirtual(); newInstanceTemplate = buildNewInstance(); return templates; @@ -133,6 +144,7 @@ XirOperand frame_pointer = asm.createRegister("frame pointer", CiKind.Word, AMD64.rbp); asm.align(config.codeEntryAlignment); + asm.mark(MARK_OSR_ENTRY); asm.mark(MARK_UNVERIFIED_ENTRY); if (!staticMethod) { // TODO do some checking... @@ -368,7 +380,8 @@ asm.restart(); XirParameter addr = asm.createConstantInputParameter("addr", CiKind.Word); - XirLabel stub = asm.createOutOfLineLabel("staticCallStub"); + XirLabel stub = asm.createOutOfLineLabel("call stub"); + asm.mark(MARK_INVOKESTATIC); asm.bindOutOfLine(stub); XirOperand method = asm.createRegister("method", CiKind.Word, AMD64.rbx); @@ -385,7 +398,8 @@ asm.restart(); XirParameter addr = asm.createConstantInputParameter("addr", CiKind.Word); - XirLabel stub = asm.createOutOfLineLabel("specialCallStub"); + XirLabel stub = asm.createOutOfLineLabel("call stub"); + asm.mark(MARK_INVOKESPECIAL); asm.bindOutOfLine(stub); XirOperand method = asm.createRegister("method", CiKind.Word, AMD64.rbx); @@ -398,6 +412,44 @@ return asm.finishTemplate(addr, "invokespecial"); } + private XirTemplate buildInvokeInterface() { + asm.restart(); + XirParameter addr = asm.createConstantInputParameter("addr", CiKind.Word); + XirOperand method = asm.createRegister("method", CiKind.Object, AMD64.rbx); + + XirLabel stub = asm.createOutOfLineLabel("call stub"); + asm.mark(MARK_INVOKEINTERFACE); + asm.mov(method, asm.createConstant(CiConstant.forObject(HotSpotProxy.DUMMY_CONSTANT_OBJ))); + + asm.bindOutOfLine(stub); + asm.mark(MARK_STATIC_CALL_STUB, XirMark.CALLSITE); + asm.mov(method, asm.w(0l)); + XirLabel dummy = asm.createOutOfLineLabel("dummy"); + asm.jmp(dummy); + asm.bindOutOfLine(dummy); + + return asm.finishTemplate(addr, "invokespecial"); + } + + private XirTemplate buildInvokeVirtual() { + asm.restart(); + XirParameter addr = asm.createConstantInputParameter("addr", CiKind.Word); + XirOperand method = asm.createRegister("method", CiKind.Object, AMD64.rbx); + + XirLabel stub = asm.createOutOfLineLabel("call stub"); + asm.mark(MARK_INVOKEVIRTUAL); + asm.mov(method, asm.createConstant(CiConstant.forObject(HotSpotProxy.DUMMY_CONSTANT_OBJ))); + + asm.bindOutOfLine(stub); + asm.mark(MARK_STATIC_CALL_STUB, XirMark.CALLSITE); + asm.mov(method, asm.w(0l)); + XirLabel dummy = asm.createOutOfLineLabel("dummy"); + asm.jmp(dummy); + asm.bindOutOfLine(dummy); + + return asm.finishTemplate(addr, "invokespecial"); + } + private XirTemplate buildNewInstance() { XirOperand result = asm.restart(CiKind.Word); XirOperand type = asm.createInputParameter("type", CiKind.Object); @@ -515,7 +567,7 @@ @Override public XirSnippet genInvokeInterface(XirSite site, XirArgument receiver, RiMethod method) { - return new XirSnippet(emptyTemplates[CiKind.Word.ordinal()]); + return new XirSnippet(invokeInterfaceTemplate, XirArgument.forWord(0)); } @Override @@ -530,7 +582,7 @@ @Override public XirSnippet genInvokeVirtual(XirSite site, XirArgument receiver, RiMethod method) { - return new XirSnippet(emptyTemplates[CiKind.Word.ordinal()]); + return new XirSnippet(invokeVirtualTemplate, XirArgument.forWord(0)); } @Override