Mercurial > hg > truffle
changeset 12795:d6b4f61ff643
Merge.
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Wed, 20 Nov 2013 14:49:47 +0100 |
parents | f8aef2693731 (diff) c13633a4d472 (current diff) |
children | 68ff7abbfae5 |
files | |
diffstat | 22 files changed, 176 insertions(+), 125 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBackendFactory.java Wed Nov 20 12:09:33 2013 +0100 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBackendFactory.java Wed Nov 20 14:49:47 2013 +0100 @@ -52,12 +52,13 @@ assert host == null; TargetDescription target = createTarget(runtime.getConfig()); + HotSpotRegistersProvider registers = createRegisters(); HotSpotMetaAccessProvider metaAccess = createMetaAccess(runtime); HotSpotCodeCacheProvider codeCache = createCodeCache(runtime, target); HotSpotConstantReflectionProvider constantReflection = createConstantReflection(runtime); Value[] nativeABICallerSaveRegisters = createNativeABICallerSaveRegisters(runtime.getConfig(), codeCache.getRegisterConfig()); HotSpotHostForeignCallsProvider foreignCalls = createForeignCalls(runtime, metaAccess, codeCache, nativeABICallerSaveRegisters); - HotSpotHostLoweringProvider lowerer = createLowerer(runtime, metaAccess, foreignCalls); + HotSpotHostLoweringProvider lowerer = createLowerer(runtime, metaAccess, foreignCalls, registers); // Replacements cannot have speculative optimizations since they have // to be valid for the entire run of the VM. Assumptions assumptions = new Assumptions(false); @@ -65,7 +66,6 @@ Replacements replacements = createReplacements(runtime, assumptions, p); HotSpotDisassemblerProvider disassembler = createDisassembler(runtime); HotSpotSuitesProvider suites = createSuites(runtime); - HotSpotRegisters registers = createRegisters(); HotSpotProviders providers = new HotSpotProviders(metaAccess, codeCache, constantReflection, foreignCalls, lowerer, replacements, disassembler, suites, registers); return createBackend(runtime, providers); @@ -75,7 +75,7 @@ return new AMD64HotSpotBackend(runtime, providers); } - protected HotSpotRegisters createRegisters() { + protected HotSpotRegistersProvider createRegisters() { return new HotSpotRegisters(AMD64.r15, AMD64.r12, AMD64.rsp); } @@ -108,8 +108,8 @@ return new HotSpotSuitesProvider(runtime); } - protected AMD64HotSpotLoweringProvider createLowerer(HotSpotGraalRuntime runtime, HotSpotMetaAccessProvider metaAccess, HotSpotForeignCallsProvider foreignCalls) { - return new AMD64HotSpotLoweringProvider(runtime, metaAccess, foreignCalls); + protected AMD64HotSpotLoweringProvider createLowerer(HotSpotGraalRuntime runtime, HotSpotMetaAccessProvider metaAccess, HotSpotForeignCallsProvider foreignCalls, HotSpotRegistersProvider registers) { + return new AMD64HotSpotLoweringProvider(runtime, metaAccess, foreignCalls, registers); } protected Value[] createNativeABICallerSaveRegisters(HotSpotVMConfig config, RegisterConfig regConfig) {
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLIRGenerator.java Wed Nov 20 12:09:33 2013 +0100 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLIRGenerator.java Wed Nov 20 14:49:47 2013 +0100 @@ -76,7 +76,7 @@ } @Override - protected HotSpotProviders getProviders() { + public HotSpotProviders getProviders() { return (HotSpotProviders) super.getProviders(); }
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLoweringProvider.java Wed Nov 20 12:09:33 2013 +0100 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLoweringProvider.java Wed Nov 20 14:49:47 2013 +0100 @@ -35,8 +35,8 @@ private AMD64ConvertSnippets.Templates convertSnippets; - public AMD64HotSpotLoweringProvider(HotSpotGraalRuntime runtime, MetaAccessProvider metaAccess, ForeignCallsProvider foreignCalls) { - super(runtime, metaAccess, foreignCalls); + public AMD64HotSpotLoweringProvider(HotSpotGraalRuntime runtime, MetaAccessProvider metaAccess, ForeignCallsProvider foreignCalls, HotSpotRegistersProvider registers) { + super(runtime, metaAccess, foreignCalls, registers); } @Override
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotBackendFactory.java Wed Nov 20 12:09:33 2013 +0100 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotBackendFactory.java Wed Nov 20 14:49:47 2013 +0100 @@ -50,12 +50,13 @@ assert host == null; TargetDescription target = createTarget(); + HotSpotRegistersProvider registers = new HotSpotRegisters(Register.None, Register.None, Register.None); // FIXME HotSpotMetaAccessProvider metaAccess = new HotSpotMetaAccessProvider(runtime); HotSpotCodeCacheProvider codeCache = new SPARCHotSpotCodeCacheProvider(runtime, target); HotSpotConstantReflectionProvider constantReflection = new HotSpotConstantReflectionProvider(runtime); Value[] nativeABICallerSaveRegisters = createNativeABICallerSaveRegisters(runtime.getConfig(), codeCache.getRegisterConfig()); HotSpotForeignCallsProvider foreignCalls = new SPARCHotSpotForeignCallsProvider(runtime, metaAccess, codeCache, nativeABICallerSaveRegisters); - LoweringProvider lowerer = new SPARCHotSpotLoweringProvider(runtime, metaAccess, foreignCalls); + LoweringProvider lowerer = new SPARCHotSpotLoweringProvider(runtime, metaAccess, foreignCalls, registers); // Replacements cannot have speculative optimizations since they have // to be valid for the entire run of the VM. Assumptions assumptions = new Assumptions(false); @@ -63,7 +64,6 @@ HotSpotReplacementsImpl replacements = new HotSpotReplacementsImpl(p, runtime.getConfig(), assumptions); HotSpotDisassemblerProvider disassembler = new HotSpotDisassemblerProvider(runtime); HotSpotSuitesProvider suites = new HotSpotSuitesProvider(runtime); - HotSpotRegisters registers = new HotSpotRegisters(Register.None, Register.None, Register.None); // FIXME HotSpotProviders providers = new HotSpotProviders(metaAccess, codeCache, constantReflection, foreignCalls, lowerer, replacements, disassembler, suites, registers); return new SPARCHotSpotBackend(runtime, providers);
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotLIRGenerator.java Wed Nov 20 12:09:33 2013 +0100 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotLIRGenerator.java Wed Nov 20 14:49:47 2013 +0100 @@ -57,7 +57,7 @@ } @Override - protected HotSpotProviders getProviders() { + public HotSpotProviders getProviders() { return (HotSpotProviders) super.getProviders(); }
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotLoweringProvider.java Wed Nov 20 12:09:33 2013 +0100 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotLoweringProvider.java Wed Nov 20 14:49:47 2013 +0100 @@ -32,8 +32,8 @@ public class SPARCHotSpotLoweringProvider extends HotSpotHostLoweringProvider { - public SPARCHotSpotLoweringProvider(HotSpotGraalRuntime runtime, MetaAccessProvider metaAccess, ForeignCallsProvider foreignCalls) { - super(runtime, metaAccess, foreignCalls); + public SPARCHotSpotLoweringProvider(HotSpotGraalRuntime runtime, MetaAccessProvider metaAccess, ForeignCallsProvider foreignCalls, HotSpotRegistersProvider registers) { + super(runtime, metaAccess, foreignCalls, registers); } @Override
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotLIRGenerator.java Wed Nov 20 12:09:33 2013 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotLIRGenerator.java Wed Nov 20 14:49:47 2013 +0100 @@ -25,6 +25,7 @@ import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.compiler.gen.*; +import com.oracle.graal.hotspot.meta.*; import com.oracle.graal.hotspot.nodes.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.spi.*; @@ -55,4 +56,6 @@ * Gets a stack slot for a lock at a given lock nesting depth. */ StackSlot getLockSlot(int lockDepth); + + HotSpotProviders getProviders(); }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotHostLoweringProvider.java Wed Nov 20 12:09:33 2013 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotHostLoweringProvider.java Wed Nov 20 14:49:47 2013 +0100 @@ -64,6 +64,7 @@ protected final HotSpotGraalRuntime runtime; protected final MetaAccessProvider metaAccess; protected final ForeignCallsProvider foreignCalls; + protected final HotSpotRegistersProvider registers; private CheckCastDynamicSnippets.Templates checkcastDynamicSnippets; private InstanceOfSnippets.Templates instanceofSnippets; @@ -74,10 +75,11 @@ private LoadExceptionObjectSnippets.Templates exceptionObjectSnippets; private UnsafeLoadSnippets.Templates unsafeLoadSnippets; - public HotSpotHostLoweringProvider(HotSpotGraalRuntime runtime, MetaAccessProvider metaAccess, ForeignCallsProvider foreignCalls) { + public HotSpotHostLoweringProvider(HotSpotGraalRuntime runtime, MetaAccessProvider metaAccess, ForeignCallsProvider foreignCalls, HotSpotRegistersProvider registers) { this.runtime = runtime; this.metaAccess = metaAccess; this.foreignCalls = foreignCalls; + this.registers = registers; } public void initialize(HotSpotProviders providers, HotSpotVMConfig config) { @@ -459,7 +461,7 @@ } } else if (n instanceof DynamicCounterNode) { if (graph.getGuardsStage() == StructuredGraph.GuardsStage.AFTER_FSA) { - BenchmarkCounters.lower((DynamicCounterNode) n, runtime.getHostProviders().getRegisters(), runtime.getConfig(), wordKind); + BenchmarkCounters.lower((DynamicCounterNode) n, registers, runtime.getConfig(), wordKind); } } else if (n instanceof CheckCastDynamicNode) { checkcastDynamicSnippets.lower((CheckCastDynamicNode) n); @@ -473,44 +475,44 @@ } } else if (n instanceof NewInstanceNode) { if (graph.getGuardsStage() == StructuredGraph.GuardsStage.AFTER_FSA) { - newObjectSnippets.lower((NewInstanceNode) n); + newObjectSnippets.lower((NewInstanceNode) n, registers); } } else if (n instanceof NewArrayNode) { if (graph.getGuardsStage() == StructuredGraph.GuardsStage.AFTER_FSA) { - newObjectSnippets.lower((NewArrayNode) n); + newObjectSnippets.lower((NewArrayNode) n, registers); } } else if (n instanceof DynamicNewArrayNode) { if (graph.getGuardsStage() == StructuredGraph.GuardsStage.AFTER_FSA) { - newObjectSnippets.lower((DynamicNewArrayNode) n); + newObjectSnippets.lower((DynamicNewArrayNode) n, registers); } } else if (n instanceof MonitorEnterNode) { if (graph.getGuardsStage() == StructuredGraph.GuardsStage.FIXED_DEOPTS) { - monitorSnippets.lower((MonitorEnterNode) n, tool); + monitorSnippets.lower((MonitorEnterNode) n, registers); } } else if (n instanceof MonitorExitNode) { if (graph.getGuardsStage() == StructuredGraph.GuardsStage.FIXED_DEOPTS) { monitorSnippets.lower((MonitorExitNode) n, tool); } } else if (n instanceof G1PreWriteBarrier) { - writeBarrierSnippets.lower((G1PreWriteBarrier) n, tool); + writeBarrierSnippets.lower((G1PreWriteBarrier) n, registers); } else if (n instanceof G1PostWriteBarrier) { - writeBarrierSnippets.lower((G1PostWriteBarrier) n, tool); + writeBarrierSnippets.lower((G1PostWriteBarrier) n, registers); } else if (n instanceof G1ReferentFieldReadBarrier) { - writeBarrierSnippets.lower((G1ReferentFieldReadBarrier) n, tool); + writeBarrierSnippets.lower((G1ReferentFieldReadBarrier) n, registers); } else if (n instanceof SerialWriteBarrier) { - writeBarrierSnippets.lower((SerialWriteBarrier) n, tool); + writeBarrierSnippets.lower((SerialWriteBarrier) n); } else if (n instanceof SerialArrayRangeWriteBarrier) { - writeBarrierSnippets.lower((SerialArrayRangeWriteBarrier) n, tool); + writeBarrierSnippets.lower((SerialArrayRangeWriteBarrier) n); } else if (n instanceof G1ArrayRangePreWriteBarrier) { - writeBarrierSnippets.lower((G1ArrayRangePreWriteBarrier) n, tool); + writeBarrierSnippets.lower((G1ArrayRangePreWriteBarrier) n, registers); } else if (n instanceof G1ArrayRangePostWriteBarrier) { - writeBarrierSnippets.lower((G1ArrayRangePostWriteBarrier) n, tool); + writeBarrierSnippets.lower((G1ArrayRangePostWriteBarrier) n, registers); } else if (n instanceof NewMultiArrayNode) { if (graph.getGuardsStage() == StructuredGraph.GuardsStage.AFTER_FSA) { newObjectSnippets.lower((NewMultiArrayNode) n); } } else if (n instanceof LoadExceptionObjectNode) { - exceptionObjectSnippets.lower((LoadExceptionObjectNode) n); + exceptionObjectSnippets.lower((LoadExceptionObjectNode) n, registers); } else if (n instanceof IntegerDivNode || n instanceof IntegerRemNode || n instanceof UnsignedDivNode || n instanceof UnsignedRemNode) { // Nothing to do for division nodes. The HotSpot signal handler catches divisions by // zero and the MIN_VALUE / -1 cases.
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/CurrentJavaThreadNode.java Wed Nov 20 12:09:33 2013 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/CurrentJavaThreadNode.java Wed Nov 20 14:49:47 2013 +0100 @@ -26,6 +26,7 @@ import com.oracle.graal.api.code.*; import com.oracle.graal.graph.*; +import com.oracle.graal.hotspot.*; import com.oracle.graal.nodes.calc.*; import com.oracle.graal.nodes.spi.*; import com.oracle.graal.word.*; @@ -41,7 +42,7 @@ @Override public void generate(LIRGeneratorTool gen) { - Register rawThread = runtime().getHostProviders().getRegisters().getThreadRegister(); + Register rawThread = ((HotSpotLIRGenerator) gen).getProviders().getRegisters().getThreadRegister(); gen.setResult(this, rawThread.asValue(this.kind())); }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/HotSpotReplacementsUtil.java Wed Nov 20 12:09:33 2013 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/HotSpotReplacementsUtil.java Wed Nov 20 14:49:47 2013 +0100 @@ -202,16 +202,6 @@ } @Fold - public static Register threadRegister() { - return runtime().getHostProviders().getRegisters().getThreadRegister(); - } - - @Fold - public static Register stackPointerRegister() { - return runtime().getHostProviders().getRegisters().getStackPointerRegister(); - } - - @Fold public static int wordSize() { return runtime().getTarget().wordSize; } @@ -469,23 +459,19 @@ @NodeIntrinsic(ForeignCallNode.class) private static native Object verifyOopStub(@ConstantNodeParameter ForeignCallDescriptor descriptor, Object object); - /** - * Gets the value of the stack pointer register as a Word. - */ - public static Word stackPointer() { - return registerAsWord(stackPointerRegister(), true, false); + public static Word loadWordFromObject(Object object, int offset) { + assert offset != hubOffset() : "Use loadHubIntrinsic instead"; + return loadWordFromObjectIntrinsic(object, offset, getWordKind(), LocationIdentity.ANY_LOCATION); } /** - * Gets the value of the thread register as a Word. + * Reads the value of a given register. + * + * @param register a register which must not be available to the register allocator + * @return the value of {@code register} as a word */ - public static Word thread() { - return registerAsWord(threadRegister(), true, false); - } - - public static Word loadWordFromObject(Object object, int offset) { - assert offset != hubOffset() : "Use loadHubIntrinsic instead"; - return loadWordFromObjectIntrinsic(object, offset, getWordKind(), LocationIdentity.ANY_LOCATION); + public static Word registerAsWord(@ConstantNodeParameter Register register) { + return registerAsWord(register, true, false); } @NodeIntrinsic(value = ReadRegisterNode.class, setStampFromReturnType = true)
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/LoadExceptionObjectSnippets.java Wed Nov 20 12:09:33 2013 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/LoadExceptionObjectSnippets.java Wed Nov 20 14:49:47 2013 +0100 @@ -34,6 +34,7 @@ import com.oracle.graal.nodes.java.*; import com.oracle.graal.nodes.type.*; import com.oracle.graal.replacements.*; +import com.oracle.graal.replacements.Snippet.*; import com.oracle.graal.replacements.SnippetTemplate.AbstractTemplates; import com.oracle.graal.replacements.SnippetTemplate.Arguments; import com.oracle.graal.replacements.SnippetTemplate.SnippetInfo; @@ -51,8 +52,8 @@ private static final boolean USE_C_RUNTIME = Boolean.getBoolean("graal.loadExceptionObject.useCRuntime"); @Snippet - public static Object loadException() { - Word thread = thread(); + public static Object loadException(@ConstantParameter Register threadRegister) { + Word thread = registerAsWord(threadRegister); Object exception = readExceptionOop(thread); writeExceptionOop(thread, null); writeExceptionPc(thread, Word.zero()); @@ -67,10 +68,9 @@ super(providers, target); } - public void lower(LoadExceptionObjectNode loadExceptionObject) { + public void lower(LoadExceptionObjectNode loadExceptionObject, HotSpotRegistersProvider registers) { if (USE_C_RUNTIME) { StructuredGraph graph = loadExceptionObject.graph(); - HotSpotRegistersProvider registers = ((HotSpotProviders) providers).getRegisters(); ReadRegisterNode thread = graph.add(new ReadRegisterNode(registers.getThreadRegister(), true, false)); graph.addBeforeFixed(loadExceptionObject, thread); ForeignCallNode loadExceptionC = graph.add(new ForeignCallNode(providers.getForeignCalls(), LOAD_AND_CLEAR_EXCEPTION, thread)); @@ -78,6 +78,7 @@ graph.replaceFixedWithFixed(loadExceptionObject, loadExceptionC); } else { Arguments args = new Arguments(loadException, loadExceptionObject.graph().getGuardsStage()); + args.addConst("threadRegister", registers.getThreadRegister()); template(args).instantiate(providers.getMetaAccess(), loadExceptionObject, DEFAULT_REPLACER, args); } }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/MonitorSnippets.java Wed Nov 20 12:09:33 2013 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/MonitorSnippets.java Wed Nov 20 14:49:47 2013 +0100 @@ -38,6 +38,7 @@ import com.oracle.graal.graph.Node.ConstantNodeParameter; import com.oracle.graal.graph.Node.NodeIntrinsic; import com.oracle.graal.graph.iterators.*; +import com.oracle.graal.hotspot.meta.*; import com.oracle.graal.hotspot.nodes.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.debug.*; @@ -96,7 +97,8 @@ public static final boolean CHECK_BALANCED_MONITORS = Boolean.getBoolean("graal.monitors.checkBalanced"); @Snippet - public static void monitorenter(Object object, @ConstantParameter int lockDepth, @ConstantParameter boolean trace) { + public static void monitorenter(Object object, @ConstantParameter int lockDepth, @ConstantParameter Register threadRegister, @ConstantParameter Register stackPointerRegister, + @ConstantParameter boolean trace) { verifyOop(object); if (object == null) { @@ -130,7 +132,7 @@ // whether the bias owner and the epoch are both still current. Word hub = loadHubIntrinsic(object, getWordKind(), anchorNode); final Word prototypeMarkWord = hub.readWord(prototypeMarkWordOffset(), PROTOTYPE_MARK_WORD_LOCATION); - final Word thread = thread(); + final Word thread = registerAsWord(threadRegister); final Word tmp = prototypeMarkWord.or(thread).xor(mark).and(~ageMaskInPlace()); trace(trace, "prototypeMarkWord: 0x%016lx\n", prototypeMarkWord); trace(trace, " thread: 0x%016lx\n", thread); @@ -253,7 +255,7 @@ // assuming both the stack pointer and page_size have their least // significant 2 bits cleared and page_size is a power of 2 final Word alignedMask = Word.unsigned(wordSize() - 1); - final Word stackPointer = stackPointer(); + final Word stackPointer = registerAsWord(stackPointerRegister); if (probability(VERY_SLOW_PATH_PROBABILITY, currentMark.subtract(stackPointer).and(alignedMask.subtract(pageSize())).notEqual(0))) { // Most likely not a recursive lock, go into a slow runtime call traceObject(trace, "+lock{stub:failed-cas}", object, true); @@ -420,7 +422,7 @@ this.useFastLocking = useFastLocking; } - public void lower(MonitorEnterNode monitorenterNode, @SuppressWarnings("unused") LoweringTool tool) { + public void lower(MonitorEnterNode monitorenterNode, HotSpotRegistersProvider registers) { StructuredGraph graph = monitorenterNode.graph(); checkBalancedMonitors(graph); FrameState stateAfter = monitorenterNode.stateAfter(); @@ -434,6 +436,8 @@ args.add("object", monitorenterNode.object()); args.addConst("lockDepth", monitorenterNode.getLockDepth()); boolean tracingEnabledForMethod = stateAfter != null && (isTracingEnabledForMethod(stateAfter.method()) || isTracingEnabledForMethod(graph.method())); + args.addConst("threadRegister", registers.getThreadRegister()); + args.addConst("stackPointerRegister", registers.getStackPointerRegister()); args.addConst("trace", isTracingEnabledForType(monitorenterNode.object()) || tracingEnabledForMethod); Map<Node, Node> nodes = template(args).instantiate(providers.getMetaAccess(), monitorenterNode, DEFAULT_REPLACER, args);
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/NewObjectSnippets.java Wed Nov 20 12:09:33 2013 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/NewObjectSnippets.java Wed Nov 20 14:49:47 2013 +0100 @@ -113,9 +113,10 @@ } @Snippet - public static Object allocateInstance(@ConstantParameter int size, Word hub, Word prototypeMarkWord, @ConstantParameter boolean fillContents, @ConstantParameter String typeContext) { + public static Object allocateInstance(@ConstantParameter int size, Word hub, Word prototypeMarkWord, @ConstantParameter boolean fillContents, @ConstantParameter Register threadRegister, + @ConstantParameter String typeContext) { Object result; - Word thread = thread(); + Word thread = registerAsWord(threadRegister); Word top = readTlabTop(thread); Word end = readTlabEnd(thread); Word newTop = top.add(size); @@ -137,19 +138,20 @@ @Snippet public static Object allocateArray(Word hub, int length, Word prototypeMarkWord, @ConstantParameter int headerSize, @ConstantParameter int log2ElementSize, - @ConstantParameter boolean fillContents, @ConstantParameter String typeContext) { + @ConstantParameter boolean fillContents, @ConstantParameter Register threadRegister, @ConstantParameter String typeContext) { if (!belowThan(length, MAX_ARRAY_FAST_PATH_ALLOCATION_LENGTH)) { // This handles both negative array sizes and very large array sizes DeoptimizeNode.deopt(DeoptimizationAction.None, DeoptimizationReason.RuntimeConstraint); } - return allocateArrayImpl(hub, length, prototypeMarkWord, headerSize, log2ElementSize, fillContents, typeContext); + return allocateArrayImpl(hub, length, prototypeMarkWord, headerSize, log2ElementSize, fillContents, threadRegister, typeContext); } - private static Object allocateArrayImpl(Word hub, int length, Word prototypeMarkWord, int headerSize, int log2ElementSize, boolean fillContents, String typeContext) { + private static Object allocateArrayImpl(Word hub, int length, Word prototypeMarkWord, int headerSize, int log2ElementSize, boolean fillContents, @ConstantParameter Register threadRegister, + String typeContext) { Object result; int alignment = wordSize(); int allocationSize = computeArrayAllocationSize(length, alignment, headerSize, log2ElementSize); - Word thread = thread(); + Word thread = registerAsWord(threadRegister); Word top = readTlabTop(thread); Word end = readTlabEnd(thread); Word newTop = top.add(allocationSize); @@ -171,7 +173,7 @@ public static native Object dynamicNewArrayStub(@ConstantNodeParameter ForeignCallDescriptor descriptor, Class<?> elementType, int length); @Snippet - public static Object allocateArrayDynamic(Class<?> elementType, int length, @ConstantParameter boolean fillContents) { + public static Object allocateArrayDynamic(Class<?> elementType, int length, @ConstantParameter boolean fillContents, @ConstantParameter Register threadRegister) { Word hub = loadWordFromObject(elementType, arrayKlassOffset()); if (hub.equal(Word.zero()) || !belowThan(length, MAX_ARRAY_FAST_PATH_ALLOCATION_LENGTH)) { return dynamicNewArrayStub(DYNAMIC_NEW_ARRAY, elementType, length); @@ -195,7 +197,7 @@ int log2ElementSize = (layoutHelper >> layoutHelperLog2ElementSizeShift()) & layoutHelperLog2ElementSizeMask(); Word prototypeMarkWord = hub.readWord(prototypeMarkWordOffset(), PROTOTYPE_MARK_WORD_LOCATION); - return allocateArrayImpl(hub, length, prototypeMarkWord, headerSize, log2ElementSize, fillContents, "dynamic type"); + return allocateArrayImpl(hub, length, prototypeMarkWord, headerSize, log2ElementSize, fillContents, threadRegister, "dynamic type"); } /** @@ -288,7 +290,7 @@ /** * Lowers a {@link NewInstanceNode}. */ - public void lower(NewInstanceNode newInstanceNode) { + public void lower(NewInstanceNode newInstanceNode, HotSpotRegistersProvider registers) { StructuredGraph graph = newInstanceNode.graph(); HotSpotResolvedObjectType type = (HotSpotResolvedObjectType) newInstanceNode.instanceClass(); assert !type.isArray(); @@ -300,6 +302,7 @@ args.add("hub", hub); args.add("prototypeMarkWord", type.prototypeMarkWord()); args.addConst("fillContents", newInstanceNode.fillContents()); + args.addConst("threadRegister", registers.getThreadRegister()); args.addConst("typeContext", ProfileAllocations.getValue() ? toJavaName(type, false) : ""); SnippetTemplate template = template(args); @@ -310,7 +313,7 @@ /** * Lowers a {@link NewArrayNode}. */ - public void lower(NewArrayNode newArrayNode) { + public void lower(NewArrayNode newArrayNode, HotSpotRegistersProvider registers) { StructuredGraph graph = newArrayNode.graph(); ResolvedJavaType elementType = newArrayNode.elementType(); HotSpotResolvedObjectType arrayType = (HotSpotResolvedObjectType) elementType.getArrayClass(); @@ -327,6 +330,7 @@ args.addConst("headerSize", headerSize); args.addConst("log2ElementSize", log2ElementSize); args.addConst("fillContents", newArrayNode.fillContents()); + args.addConst("threadRegister", registers.getThreadRegister()); args.addConst("typeContext", ProfileAllocations.getValue() ? toJavaName(arrayType, false) : ""); SnippetTemplate template = template(args); @@ -334,11 +338,12 @@ template.instantiate(providers.getMetaAccess(), newArrayNode, DEFAULT_REPLACER, args); } - public void lower(DynamicNewArrayNode newArrayNode) { + public void lower(DynamicNewArrayNode newArrayNode, HotSpotRegistersProvider registers) { Arguments args = new Arguments(allocateArrayDynamic, newArrayNode.graph().getGuardsStage()); args.add("elementType", newArrayNode.getElementType()); args.add("length", newArrayNode.length()); args.addConst("fillContents", newArrayNode.fillContents()); + args.addConst("threadRegister", registers.getThreadRegister()); SnippetTemplate template = template(args); template.instantiate(providers.getMetaAccess(), newArrayNode, DEFAULT_REPLACER, args);
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/WriteBarrierSnippets.java Wed Nov 20 12:09:33 2013 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/WriteBarrierSnippets.java Wed Nov 20 14:49:47 2013 +0100 @@ -31,11 +31,11 @@ import com.oracle.graal.api.meta.*; import com.oracle.graal.graph.Node.ConstantNodeParameter; import com.oracle.graal.graph.Node.NodeIntrinsic; +import com.oracle.graal.hotspot.meta.*; import com.oracle.graal.hotspot.nodes.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.HeapAccess.BarrierType; import com.oracle.graal.nodes.extended.*; -import com.oracle.graal.nodes.spi.*; import com.oracle.graal.phases.*; import com.oracle.graal.phases.util.*; import com.oracle.graal.replacements.*; @@ -106,11 +106,11 @@ @Snippet public static void g1PreWriteBarrier(Object object, Object expectedObject, Object location, @ConstantParameter boolean doLoad, @ConstantParameter boolean nullCheck, - @ConstantParameter boolean trace) { + @ConstantParameter Register threadRegister, @ConstantParameter boolean trace) { if (nullCheck && object == null) { DeoptimizeNode.deopt(DeoptimizationAction.InvalidateReprofile, DeoptimizationReason.NullCheckException); } - Word thread = thread(); + Word thread = registerAsWord(threadRegister); Object fixedObject = FixedValueAnchorNode.getObject(object); verifyOop(fixedObject); Object fixedExpectedObject = FixedValueAnchorNode.getObject(expectedObject); @@ -161,8 +161,9 @@ } @Snippet - public static void g1PostWriteBarrier(Object object, Object value, Object location, @ConstantParameter boolean usePrecise, @ConstantParameter boolean trace) { - Word thread = thread(); + public static void g1PostWriteBarrier(Object object, Object value, Object location, @ConstantParameter boolean usePrecise, @ConstantParameter Register threadRegister, + @ConstantParameter boolean trace) { + Word thread = registerAsWord(threadRegister); Object fixedObject = FixedValueAnchorNode.getObject(object); Object fixedValue = FixedValueAnchorNode.getObject(value); verifyOop(fixedObject); @@ -233,8 +234,8 @@ } @Snippet - public static void g1ArrayRangePreWriteBarrier(Object object, int startIndex, int length) { - Word thread = thread(); + public static void g1ArrayRangePreWriteBarrier(Object object, int startIndex, int length, @ConstantParameter Register threadRegister) { + Word thread = registerAsWord(threadRegister); byte markingValue = thread.readByte(g1SATBQueueMarkingOffset()); // If the concurrent marker is not enabled or the vector length is zero, return. if (markingValue == (byte) 0 || length == 0) { @@ -267,12 +268,12 @@ } @Snippet - public static void g1ArrayRangePostWriteBarrier(Object object, int startIndex, int length) { + public static void g1ArrayRangePostWriteBarrier(Object object, int startIndex, int length, @ConstantParameter Register threadRegister) { if (length == 0) { return; } Object dest = FixedValueAnchorNode.getObject(object); - Word thread = thread(); + Word thread = registerAsWord(threadRegister); Word bufferAddress = thread.readWord(g1CardQueueBufferOffset()); Word indexAddress = thread.add(g1CardQueueIndexOffset()); long indexValue = thread.readWord(g1CardQueueIndexOffset()).rawValue(); @@ -332,7 +333,7 @@ super(providers, target); } - public void lower(SerialWriteBarrier writeBarrier, @SuppressWarnings("unused") LoweringTool tool) { + public void lower(SerialWriteBarrier writeBarrier) { if (writeBarrier.alwaysNull()) { writeBarrier.graph().removeFixed(writeBarrier); return; @@ -344,7 +345,7 @@ template(args).instantiate(providers.getMetaAccess(), writeBarrier, DEFAULT_REPLACER, args); } - public void lower(SerialArrayRangeWriteBarrier arrayRangeWriteBarrier, @SuppressWarnings("unused") LoweringTool tool) { + public void lower(SerialArrayRangeWriteBarrier arrayRangeWriteBarrier) { Arguments args = new Arguments(serialArrayRangeWriteBarrier, arrayRangeWriteBarrier.graph().getGuardsStage()); args.add("object", arrayRangeWriteBarrier.getObject()); args.add("startIndex", arrayRangeWriteBarrier.getStartIndex()); @@ -352,29 +353,31 @@ template(args).instantiate(providers.getMetaAccess(), arrayRangeWriteBarrier, DEFAULT_REPLACER, args); } - public void lower(G1PreWriteBarrier writeBarrierPre, @SuppressWarnings("unused") LoweringTool tool) { + public void lower(G1PreWriteBarrier writeBarrierPre, HotSpotRegistersProvider registers) { Arguments args = new Arguments(g1PreWriteBarrier, writeBarrierPre.graph().getGuardsStage()); args.add("object", writeBarrierPre.getObject()); args.add("expectedObject", writeBarrierPre.getExpectedObject()); args.add("location", writeBarrierPre.getLocation()); args.addConst("doLoad", writeBarrierPre.doLoad()); args.addConst("nullCheck", writeBarrierPre.getNullCheck()); + args.addConst("threadRegister", registers.getThreadRegister()); args.addConst("trace", traceBarrier()); template(args).instantiate(providers.getMetaAccess(), writeBarrierPre, DEFAULT_REPLACER, args); } - public void lower(G1ReferentFieldReadBarrier readBarrier, @SuppressWarnings("unused") LoweringTool tool) { + public void lower(G1ReferentFieldReadBarrier readBarrier, HotSpotRegistersProvider registers) { Arguments args = new Arguments(g1ReferentReadBarrier, readBarrier.graph().getGuardsStage()); args.add("object", readBarrier.getObject()); args.add("expectedObject", readBarrier.getExpectedObject()); args.add("location", readBarrier.getLocation()); args.addConst("doLoad", readBarrier.doLoad()); args.addConst("nullCheck", false); + args.addConst("threadRegister", registers.getThreadRegister()); args.addConst("trace", traceBarrier()); template(args).instantiate(providers.getMetaAccess(), readBarrier, DEFAULT_REPLACER, args); } - public void lower(G1PostWriteBarrier writeBarrierPost, @SuppressWarnings("unused") LoweringTool tool) { + public void lower(G1PostWriteBarrier writeBarrierPost, HotSpotRegistersProvider registers) { if (writeBarrierPost.alwaysNull()) { writeBarrierPost.graph().removeFixed(writeBarrierPost); return; @@ -384,23 +387,26 @@ args.add("value", writeBarrierPost.getValue()); args.add("location", writeBarrierPost.getLocation()); args.addConst("usePrecise", writeBarrierPost.usePrecise()); + args.addConst("threadRegister", registers.getThreadRegister()); args.addConst("trace", traceBarrier()); template(args).instantiate(providers.getMetaAccess(), writeBarrierPost, DEFAULT_REPLACER, args); } - public void lower(G1ArrayRangePreWriteBarrier arrayRangeWriteBarrier, @SuppressWarnings("unused") LoweringTool tool) { + public void lower(G1ArrayRangePreWriteBarrier arrayRangeWriteBarrier, HotSpotRegistersProvider registers) { Arguments args = new Arguments(g1ArrayRangePreWriteBarrier, arrayRangeWriteBarrier.graph().getGuardsStage()); args.add("object", arrayRangeWriteBarrier.getObject()); args.add("startIndex", arrayRangeWriteBarrier.getStartIndex()); args.add("length", arrayRangeWriteBarrier.getLength()); + args.addConst("threadRegister", registers.getThreadRegister()); template(args).instantiate(providers.getMetaAccess(), arrayRangeWriteBarrier, DEFAULT_REPLACER, args); } - public void lower(G1ArrayRangePostWriteBarrier arrayRangeWriteBarrier, @SuppressWarnings("unused") LoweringTool tool) { + public void lower(G1ArrayRangePostWriteBarrier arrayRangeWriteBarrier, HotSpotRegistersProvider registers) { Arguments args = new Arguments(g1ArrayRangePostWriteBarrier, arrayRangeWriteBarrier.graph().getGuardsStage()); args.add("object", arrayRangeWriteBarrier.getObject()); args.add("startIndex", arrayRangeWriteBarrier.getStartIndex()); args.add("length", arrayRangeWriteBarrier.getLength()); + args.addConst("threadRegister", registers.getThreadRegister()); template(args).instantiate(providers.getMetaAccess(), arrayRangeWriteBarrier, DEFAULT_REPLACER, args); } }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/ExceptionHandlerStub.java Wed Nov 20 12:09:33 2013 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/ExceptionHandlerStub.java Wed Nov 20 14:49:47 2013 +0100 @@ -35,7 +35,7 @@ import com.oracle.graal.hotspot.meta.*; import com.oracle.graal.hotspot.nodes.*; import com.oracle.graal.replacements.*; -import com.oracle.graal.replacements.Snippet.Fold; +import com.oracle.graal.replacements.Snippet.*; import com.oracle.graal.word.*; /** @@ -62,12 +62,19 @@ return false; } + @Override + protected Object getConstantParameterValue(int index, String name) { + assert index == 2; + return providers.getRegisters().getThreadRegister(); + } + @Snippet - private static void exceptionHandler(Object exception, Word exceptionPc) { - checkNoExceptionInThread(assertionsEnabled()); + private static void exceptionHandler(Object exception, Word exceptionPc, @ConstantParameter Register threadRegister) { + Word thread = registerAsWord(threadRegister); + checkNoExceptionInThread(thread, assertionsEnabled()); checkExceptionNotNull(assertionsEnabled(), exception); - writeExceptionOop(thread(), exception); - writeExceptionPc(thread(), exceptionPc); + writeExceptionOop(thread, exception); + writeExceptionPc(thread, exceptionPc); if (logging()) { printf("handling exception %p (", Word.fromObject(exception).rawValue()); decipher(Word.fromObject(exception).rawValue()); @@ -79,7 +86,7 @@ // patch throwing pc into return address so that deoptimization finds the right debug info patchReturnAddress(exceptionPc); - Word handlerPc = exceptionHandlerForPc(EXCEPTION_HANDLER_FOR_PC, thread()); + Word handlerPc = exceptionHandlerForPc(EXCEPTION_HANDLER_FOR_PC, thread); if (logging()) { printf("handler for exception %p at %p is at %p (", Word.fromObject(exception).rawValue(), exceptionPc.rawValue(), handlerPc.rawValue()); @@ -91,16 +98,16 @@ patchReturnAddress(handlerPc); } - static void checkNoExceptionInThread(boolean enabled) { + static void checkNoExceptionInThread(Word thread, boolean enabled) { if (enabled) { - Object currentException = readExceptionOop(thread()); + Object currentException = readExceptionOop(thread); if (currentException != null) { fatal("exception object in thread must be null, not %p", Word.fromObject(currentException).rawValue()); } if (cAssertionsEnabled()) { // This thread-local is only cleared in DEBUG builds of the VM // (see OptoRuntime::generate_exception_blob) - Word currentExceptionPc = readExceptionPc(thread()); + Word currentExceptionPc = readExceptionPc(thread); if (currentExceptionPc.notEqual(Word.zero())) { fatal("exception PC in thread must be zero, not %p", currentExceptionPc.rawValue()); }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/ForeignCallStub.java Wed Nov 20 12:09:33 2013 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/ForeignCallStub.java Wed Nov 20 14:49:47 2013 +0100 @@ -54,8 +54,8 @@ * deoptimization while the call is in progress. And since these are foreign/runtime calls on slow * paths, we don't want to force the register allocator to spill around the call. As such, this stub * saves and restores all allocatable registers. It also - * {@linkplain StubUtil#handlePendingException(boolean) handles} any exceptions raised during the - * foreign call. + * {@linkplain StubUtil#handlePendingException(Word, boolean) handles} any exceptions raised during + * the foreign call. */ public class ForeignCallStub extends Stub { @@ -226,9 +226,9 @@ LocalNode[] locals = createLocals(builder, args); List<InvokeNode> invokes = new ArrayList<>(3); - ReadRegisterNode thread = prependThread || isObjectResult ? builder.append(new ReadRegisterNode(providers.getRegisters().getThreadRegister(), true, false)) : null; + ReadRegisterNode thread = builder.append(new ReadRegisterNode(providers.getRegisters().getThreadRegister(), true, false)); ValueNode result = createTargetCall(builder, locals, thread); - invokes.add(createInvoke(builder, StubUtil.class, "handlePendingException", ConstantNode.forBoolean(isObjectResult, builder.graph))); + invokes.add(createInvoke(builder, StubUtil.class, "handlePendingException", thread, ConstantNode.forBoolean(isObjectResult, builder.graph))); if (isObjectResult) { InvokeNode object = createInvoke(builder, HotSpotReplacementsUtil.class, "getAndClearObjectResult", thread); result = createInvoke(builder, StubUtil.class, "verifyObject", object); @@ -276,7 +276,7 @@ return locals; } - private InvokeNode createInvoke(GraphBuilder builder, Class<?> declaringClass, String name, ValueNode... hpeArgs) { + private InvokeNode createInvoke(GraphBuilder builder, Class<?> declaringClass, String name, ValueNode... args) { ResolvedJavaMethod method = null; for (Method m : declaringClass.getDeclaredMethods()) { if (Modifier.isStatic(m.getModifiers()) && m.getName().equals(name)) { @@ -285,12 +285,25 @@ } } assert method != null : "did not find method in " + declaringClass + " named " + name; - JavaType returnType = method.getSignature().getReturnType(null); - MethodCallTargetNode callTarget = builder.graph.add(new MethodCallTargetNode(InvokeKind.Static, method, hpeArgs, returnType)); + Signature signature = method.getSignature(); + JavaType returnType = signature.getReturnType(null); + assert checkArgs(method, args); + MethodCallTargetNode callTarget = builder.graph.add(new MethodCallTargetNode(InvokeKind.Static, method, args, returnType)); InvokeNode invoke = builder.append(new InvokeNode(callTarget, FrameState.UNKNOWN_BCI)); return invoke; } + private boolean checkArgs(ResolvedJavaMethod method, ValueNode... args) { + Signature signature = method.getSignature(); + assert signature.getParameterCount(false) == args.length : target + ": wrong number of arguments to " + method; + for (int i = 0; i != args.length; i++) { + Kind expected = signature.getParameterKind(i).getStackKind(); + Kind actual = args[i].stamp().kind(); + assert expected == actual : target + ": wrong kind of value for argument " + i + " of calls to " + method + " [" + actual + " != " + expected + "]"; + } + return true; + } + private StubForeignCallNode createTargetCall(GraphBuilder builder, LocalNode[] locals, ReadRegisterNode thread) { if (prependThread) { ValueNode[] targetArguments = new ValueNode[1 + locals.length];
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/NewArrayStub.java Wed Nov 20 12:09:33 2013 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/NewArrayStub.java Wed Nov 20 14:49:47 2013 +0100 @@ -70,6 +70,7 @@ args.add("hub", null); args.add("length", null); args.addConst("intArrayHub", intArrayHub); + args.addConst("threadRegister", providers.getRegisters().getThreadRegister()); return args; } @@ -87,7 +88,7 @@ * @param intArrayHub the hub for {@code int[].class} */ @Snippet - private static Object newArray(Word hub, int length, @ConstantParameter Word intArrayHub) { + private static Object newArray(Word hub, int length, @ConstantParameter Word intArrayHub, @ConstantParameter Register threadRegister) { int layoutHelper = hub.readInt(layoutHelperOffset(), LocationIdentity.FINAL_LOCATION); int log2ElementSize = (layoutHelper >> layoutHelperLog2ElementSizeShift()) & layoutHelperLog2ElementSizeMask(); int headerSize = (layoutHelper >> layoutHelperHeaderSizeShift()) & layoutHelperHeaderSizeMask(); @@ -101,8 +102,9 @@ } // check that array length is small enough for fast path. + Word thread = registerAsWord(threadRegister); if (length <= MAX_ARRAY_FAST_PATH_ALLOCATION_LENGTH) { - Word memory = refillAllocate(intArrayHub, sizeInBytes, logging()); + Word memory = refillAllocate(thread, intArrayHub, sizeInBytes, logging()); if (memory.notEqual(0)) { if (logging()) { printf("newArray: allocated new array at %p\n", memory.rawValue()); @@ -114,9 +116,9 @@ printf("newArray: calling new_array_c\n"); } - newArrayC(NEW_ARRAY_C, thread(), hub, length); - handlePendingException(true); - return verifyObject(getAndClearObjectResult(thread())); + newArrayC(NEW_ARRAY_C, thread, hub, length); + handlePendingException(thread, true); + return verifyObject(getAndClearObjectResult(thread)); } public static final ForeignCallDescriptor NEW_ARRAY_C = descriptorFor(NewArrayStub.class, "newArrayC");
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/NewInstanceStub.java Wed Nov 20 12:09:33 2013 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/NewInstanceStub.java Wed Nov 20 14:49:47 2013 +0100 @@ -70,11 +70,11 @@ Arguments args = new Arguments(stub, GuardsStage.FLOATING_GUARDS); args.add("hub", null); args.addConst("intArrayHub", intArrayHub); + args.addConst("threadRegister", providers.getRegisters().getThreadRegister()); return args; } - private static Word allocate(int size) { - Word thread = thread(); + private static Word allocate(Word thread, int size) { Word top = readTlabTop(thread); Word end = readTlabEnd(thread); Word newTop = top.add(size); @@ -102,11 +102,12 @@ * @param intArrayHub the hub for {@code int[].class} */ @Snippet - private static Object newInstance(Word hub, @ConstantParameter Word intArrayHub) { + private static Object newInstance(Word hub, @ConstantParameter Word intArrayHub, @ConstantParameter Register threadRegister) { int sizeInBytes = hub.readInt(klassInstanceSizeOffset(), LocationIdentity.FINAL_LOCATION); + Word thread = registerAsWord(threadRegister); if (!forceSlowPath() && inlineContiguousAllocationSupported()) { if (hub.readByte(klassStateOffset(), CLASS_STATE_LOCATION) == klassStateFullyInitialized()) { - Word memory = refillAllocate(intArrayHub, sizeInBytes, logging()); + Word memory = refillAllocate(thread, intArrayHub, sizeInBytes, logging()); if (memory.notEqual(0)) { Word prototypeMarkWord = hub.readWord(prototypeMarkWordOffset(), PROTOTYPE_MARK_WORD_LOCATION); initializeObjectHeader(memory, prototypeMarkWord, hub); @@ -122,9 +123,9 @@ printf("newInstance: calling new_instance_c\n"); } - newInstanceC(NEW_INSTANCE_C, thread(), hub); - handlePendingException(true); - return verifyObject(getAndClearObjectResult(thread())); + newInstanceC(NEW_INSTANCE_C, thread, hub); + handlePendingException(thread, true); + return verifyObject(getAndClearObjectResult(thread)); } /** @@ -133,10 +134,11 @@ * @param intArrayHub the hub for {@code int[].class} * @param sizeInBytes the size of the allocation * @param log specifies if logging is enabled + * * @return the newly allocated, uninitialized chunk of memory, or {@link Word#zero()} if the * operation was unsuccessful */ - static Word refillAllocate(Word intArrayHub, int sizeInBytes, boolean log) { + static Word refillAllocate(Word thread, Word intArrayHub, int sizeInBytes, boolean log) { // If G1 is enabled, the "eden" allocation space is not the same always // and therefore we have to go to slowpath to allocate a new TLAB. if (useG1GC()) { @@ -148,7 +150,6 @@ Word intArrayMarkWord = Word.unsigned(tlabIntArrayMarkWord()); int alignmentReserveInBytes = tlabAlignmentReserveInHeapWords() * wordSize(); - Word thread = thread(); Word top = readTlabTop(thread); Word end = readTlabEnd(thread); @@ -206,7 +207,7 @@ end = top.add(tlabRefillSizeInBytes.subtract(alignmentReserveInBytes)); initializeTlab(thread, top, end); - return NewInstanceStub.allocate(sizeInBytes); + return NewInstanceStub.allocate(thread, sizeInBytes); } else { return Word.zero(); }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/SnippetStub.java Wed Nov 20 12:09:33 2013 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/SnippetStub.java Wed Nov 20 14:49:47 2013 +0100 @@ -26,6 +26,7 @@ import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; +import com.oracle.graal.graph.*; import com.oracle.graal.hotspot.*; import com.oracle.graal.hotspot.meta.*; import com.oracle.graal.nodes.*; @@ -82,11 +83,21 @@ protected Arguments makeArguments(SnippetInfo stub) { Arguments args = new Arguments(stub, GuardsStage.FLOATING_GUARDS); for (int i = 0; i < stub.getParameterCount(); i++) { - args.add(stub.getParameterName(i), null); + String name = stub.getParameterName(i); + if (stub.isConstantParameter(i)) { + args.addConst(name, getConstantParameterValue(i, name)); + } else { + assert !stub.isVarargsParameter(i); + args.add(name, null); + } } return args; } + protected Object getConstantParameterValue(int index, String name) { + throw new GraalInternalError("%s must override getConstantParameterValue() to provide a value for parameter %d%s", getClass().getName(), index, name == null ? "" : " (" + name + ")"); + } + @Override protected Object debugScopeContext() { return getInstalledCodeOwner();
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/StubUtil.java Wed Nov 20 12:09:33 2013 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/StubUtil.java Wed Nov 20 14:49:47 2013 +0100 @@ -73,10 +73,10 @@ return new ForeignCallDescriptor(name, found.getReturnType(), cCallTypes); } - public static void handlePendingException(boolean isObjectResult) { - if (clearPendingException(thread())) { + public static void handlePendingException(Word thread, boolean isObjectResult) { + if (clearPendingException(thread)) { if (isObjectResult) { - getAndClearObjectResult(thread()); + getAndClearObjectResult(thread); } DeoptimizeCallerNode.deopt(InvalidateReprofile, RuntimeConstraint); }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/UnwindExceptionToCallerStub.java Wed Nov 20 12:09:33 2013 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/UnwindExceptionToCallerStub.java Wed Nov 20 14:49:47 2013 +0100 @@ -36,7 +36,7 @@ import com.oracle.graal.hotspot.nodes.*; import com.oracle.graal.nodes.*; import com.oracle.graal.replacements.*; -import com.oracle.graal.replacements.Snippet.Fold; +import com.oracle.graal.replacements.Snippet.*; import com.oracle.graal.word.*; /** @@ -58,8 +58,14 @@ return false; } + @Override + protected Object getConstantParameterValue(int index, String name) { + assert index == 2; + return providers.getRegisters().getThreadRegister(); + } + @Snippet - private static void unwindExceptionToCaller(Object exception, Word returnAddress) { + private static void unwindExceptionToCaller(Object exception, Word returnAddress, @ConstantParameter Register threadRegister) { Pointer exceptionOop = Word.fromObject(exception); if (logging()) { printf("unwinding exception %p (", exceptionOop.rawValue()); @@ -68,10 +74,11 @@ decipher(returnAddress.rawValue()); printf(")\n"); } - checkNoExceptionInThread(assertionsEnabled()); + Word thread = registerAsWord(threadRegister); + checkNoExceptionInThread(thread, assertionsEnabled()); checkExceptionNotNull(assertionsEnabled(), exception); - Word handlerInCallerPc = exceptionHandlerForReturnAddress(EXCEPTION_HANDLER_FOR_RETURN_ADDRESS, thread(), returnAddress); + Word handlerInCallerPc = exceptionHandlerForReturnAddress(EXCEPTION_HANDLER_FOR_RETURN_ADDRESS, thread, returnAddress); if (logging()) { printf("handler for exception %p at return address %p is at %p (", exceptionOop.rawValue(), returnAddress.rawValue(), handlerInCallerPc.rawValue());
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/ReadRegisterNode.java Wed Nov 20 12:09:33 2013 +0100 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/ReadRegisterNode.java Wed Nov 20 14:49:47 2013 +0100 @@ -56,6 +56,7 @@ public ReadRegisterNode(Register register, Kind kind, boolean directUse, boolean incoming) { super(StampFactory.forKind(kind)); + assert register != null; this.register = register; this.directUse = directUse; this.incoming = incoming; @@ -67,6 +68,7 @@ */ public ReadRegisterNode(Register register, boolean directUse, boolean incoming) { super(StampFactory.forNodeIntrinsic()); + assert register != null; this.register = register; this.directUse = directUse; this.incoming = incoming;