# HG changeset patch # User Doug Simon # Date 1401198216 -7200 # Node ID af0e42dad3580620fcdd4df03e3d9fece89748d7 # Parent 674d4065e9fb5eae553680ecb2c45d56cf31b4f7 reduced time to initialize ForeignCallProviders by avoiding triggering class initialization of Node subclasses as well as making annotation parsing lazy in SnippetInfo diff -r 674d4065e9fb -r af0e42dad358 graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotForeignCallsProvider.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotForeignCallsProvider.java Tue May 27 13:16:12 2014 +0200 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotForeignCallsProvider.java Tue May 27 15:43:36 2014 +0200 @@ -26,13 +26,12 @@ import static com.oracle.graal.api.code.CallingConvention.Type.*; import static com.oracle.graal.api.meta.LocationIdentity.*; import static com.oracle.graal.api.meta.Value.*; +import static com.oracle.graal.hotspot.HotSpotBackend.*; import static com.oracle.graal.hotspot.HotSpotForeignCallLinkage.*; import static com.oracle.graal.hotspot.HotSpotForeignCallLinkage.RegisterEffect.*; import static com.oracle.graal.hotspot.HotSpotForeignCallLinkage.Transition.*; import static com.oracle.graal.hotspot.HotSpotHostBackend.*; -import static com.oracle.graal.hotspot.replacements.AESCryptSubstitutions.*; import static com.oracle.graal.hotspot.replacements.CRC32Substitutions.*; -import static com.oracle.graal.hotspot.replacements.CipherBlockChainingSubstitutions.*; import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; diff -r 674d4065e9fb -r af0e42dad358 graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLIRGenerator.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLIRGenerator.java Tue May 27 13:16:12 2014 +0200 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLIRGenerator.java Tue May 27 15:43:36 2014 +0200 @@ -24,8 +24,8 @@ import static com.oracle.graal.amd64.AMD64.*; import static com.oracle.graal.api.code.ValueUtil.*; +import static com.oracle.graal.hotspot.HotSpotBackend.*; import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*; -import static com.oracle.graal.hotspot.nodes.UncommonTrapCallNode.*; import static com.oracle.graal.lir.LIRInstruction.OperandFlag.*; import java.util.*; diff -r 674d4065e9fb -r af0e42dad358 graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotLIRGenerator.java --- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotLIRGenerator.java Tue May 27 13:16:12 2014 +0200 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotLIRGenerator.java Tue May 27 15:43:36 2014 +0200 @@ -23,8 +23,8 @@ package com.oracle.graal.hotspot.sparc; import static com.oracle.graal.api.code.ValueUtil.*; +import static com.oracle.graal.hotspot.HotSpotBackend.*; import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*; -import static com.oracle.graal.hotspot.nodes.UncommonTrapCallNode.*; import static com.oracle.graal.sparc.SPARC.*; import com.oracle.graal.api.code.*; diff -r 674d4065e9fb -r af0e42dad358 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotBackend.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotBackend.java Tue May 27 13:16:12 2014 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotBackend.java Tue May 27 15:43:36 2014 +0200 @@ -30,6 +30,8 @@ import com.oracle.graal.compiler.common.cfg.*; import com.oracle.graal.compiler.target.*; import com.oracle.graal.hotspot.meta.*; +import com.oracle.graal.hotspot.nodes.*; +import com.oracle.graal.hotspot.replacements.*; import com.oracle.graal.hotspot.stubs.*; import com.oracle.graal.lir.*; import com.oracle.graal.lir.LIRInstruction.ValueProcedure; @@ -69,6 +71,51 @@ private final HotSpotGraalRuntime runtime; + /** + * @see AESCryptSubstitutions#encryptBlockStub(ForeignCallDescriptor, Word, Word, Word) + */ + public static final ForeignCallDescriptor ENCRYPT_BLOCK = new ForeignCallDescriptor("encrypt_block", void.class, Word.class, Word.class, Word.class); + + /** + * @see AESCryptSubstitutions#decryptBlockStub(ForeignCallDescriptor, Word, Word, Word) + */ + public static final ForeignCallDescriptor DECRYPT_BLOCK = new ForeignCallDescriptor("decrypt_block", void.class, Word.class, Word.class, Word.class); + + /** + * @see CipherBlockChainingSubstitutions#crypt + */ + public static final ForeignCallDescriptor ENCRYPT = new ForeignCallDescriptor("encrypt", void.class, Word.class, Word.class, Word.class, Word.class, int.class); + + /** + * @see CipherBlockChainingSubstitutions#crypt + */ + public static final ForeignCallDescriptor DECRYPT = new ForeignCallDescriptor("decrypt", void.class, Word.class, Word.class, Word.class, Word.class, int.class); + + /** + * @see VMErrorNode + */ + public static final ForeignCallDescriptor VM_ERROR = new ForeignCallDescriptor("vm_error", void.class, Object.class, Object.class, long.class); + + /** + * @see NewMultiArrayStubCall + */ + public static final ForeignCallDescriptor NEW_MULTI_ARRAY = new ForeignCallDescriptor("new_multi_array", Object.class, Word.class, int.class, Word.class); + + /** + * @see NewArrayStubCall + */ + public static final ForeignCallDescriptor NEW_ARRAY = new ForeignCallDescriptor("new_array", Object.class, Word.class, int.class); + + /** + * @see NewInstanceStubCall + */ + public static final ForeignCallDescriptor NEW_INSTANCE = new ForeignCallDescriptor("new_instance", Object.class, Word.class); + + /** + * @see UncommonTrapCallNode + */ + public static final ForeignCallDescriptor UNCOMMON_TRAP = new ForeignCallDescriptor("uncommonTrap", Word.class, Word.class, int.class); + public HotSpotBackend(HotSpotGraalRuntime runtime, HotSpotProviders providers) { super(providers); this.runtime = runtime; diff -r 674d4065e9fb -r af0e42dad358 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotHostForeignCallsProvider.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotHostForeignCallsProvider.java Tue May 27 13:16:12 2014 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotHostForeignCallsProvider.java Tue May 27 15:43:36 2014 +0200 @@ -27,11 +27,7 @@ import static com.oracle.graal.hotspot.HotSpotBackend.*; import static com.oracle.graal.hotspot.HotSpotForeignCallLinkage.RegisterEffect.*; import static com.oracle.graal.hotspot.HotSpotForeignCallLinkage.Transition.*; -import static com.oracle.graal.hotspot.nodes.NewArrayStubCall.*; -import static com.oracle.graal.hotspot.nodes.NewInstanceStubCall.*; -import static com.oracle.graal.hotspot.nodes.NewMultiArrayStubCall.*; -import static com.oracle.graal.hotspot.nodes.UncommonTrapCallNode.*; -import static com.oracle.graal.hotspot.nodes.VMErrorNode.*; +import static com.oracle.graal.hotspot.meta.DefaultHotSpotLoweringProvider.RuntimeCalls.*; import static com.oracle.graal.hotspot.replacements.HotSpotReplacementsUtil.*; import static com.oracle.graal.hotspot.replacements.MonitorSnippets.*; import static com.oracle.graal.hotspot.replacements.NewObjectSnippets.*; @@ -44,8 +40,7 @@ import static com.oracle.graal.hotspot.stubs.NewInstanceStub.*; import static com.oracle.graal.hotspot.stubs.StubUtil.*; import static com.oracle.graal.hotspot.stubs.UnwindExceptionToCallerStub.*; -import static com.oracle.graal.hotspot.meta.DefaultHotSpotLoweringProvider.RuntimeCalls.*; -import static com.oracle.graal.nodes.java.RegisterFinalizerNode.*; +import static com.oracle.graal.nodes.java.ForeignCallDescriptors.*; import static com.oracle.graal.replacements.Log.*; import static com.oracle.graal.replacements.MathSubstitutionsX86.*; diff -r 674d4065e9fb -r af0e42dad358 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/NewArrayStubCall.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/NewArrayStubCall.java Tue May 27 13:16:12 2014 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/NewArrayStubCall.java Tue May 27 15:43:36 2014 +0200 @@ -22,8 +22,9 @@ */ package com.oracle.graal.hotspot.nodes; +import static com.oracle.graal.hotspot.HotSpotBackend.*; + import com.oracle.graal.api.code.*; -import com.oracle.graal.api.meta.*; import com.oracle.graal.compiler.common.type.*; import com.oracle.graal.hotspot.meta.*; import com.oracle.graal.hotspot.stubs.*; @@ -42,8 +43,6 @@ @Input private ValueNode hub; @Input private ValueNode length; - public static final ForeignCallDescriptor NEW_ARRAY = new ForeignCallDescriptor("new_array", Object.class, Word.class, int.class); - public NewArrayStubCall(ValueNode hub, ValueNode length) { super(defaultStamp); this.hub = hub; diff -r 674d4065e9fb -r af0e42dad358 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/NewInstanceStubCall.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/NewInstanceStubCall.java Tue May 27 13:16:12 2014 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/NewInstanceStubCall.java Tue May 27 15:43:36 2014 +0200 @@ -22,6 +22,8 @@ */ package com.oracle.graal.hotspot.nodes; +import static com.oracle.graal.hotspot.HotSpotBackend.*; + import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.compiler.common.type.*; @@ -40,8 +42,6 @@ @Input private ValueNode hub; - public static final ForeignCallDescriptor NEW_INSTANCE = new ForeignCallDescriptor("new_instance", Object.class, Word.class); - public NewInstanceStubCall(ValueNode hub) { super(defaultStamp); this.hub = hub; diff -r 674d4065e9fb -r af0e42dad358 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/NewMultiArrayStubCall.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/NewMultiArrayStubCall.java Tue May 27 13:16:12 2014 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/NewMultiArrayStubCall.java Tue May 27 15:43:36 2014 +0200 @@ -22,6 +22,8 @@ */ package com.oracle.graal.hotspot.nodes; +import static com.oracle.graal.hotspot.HotSpotBackend.*; + import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.compiler.common.type.*; @@ -42,8 +44,6 @@ @Input private ValueNode dims; private final int rank; - public static final ForeignCallDescriptor NEW_MULTI_ARRAY = new ForeignCallDescriptor("new_multi_array", Object.class, Word.class, int.class, Word.class); - public NewMultiArrayStubCall(@InjectedNodeParameter ForeignCallsProvider foreignCalls, ValueNode hub, int rank, ValueNode dims) { super(foreignCalls, NEW_MULTI_ARRAY, defaultStamp); this.hub = hub; diff -r 674d4065e9fb -r af0e42dad358 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/UncommonTrapCallNode.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/UncommonTrapCallNode.java Tue May 27 13:16:12 2014 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/UncommonTrapCallNode.java Tue May 27 15:43:36 2014 +0200 @@ -22,6 +22,8 @@ */ package com.oracle.graal.hotspot.nodes; +import static com.oracle.graal.hotspot.HotSpotBackend.*; + import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.compiler.common.type.*; @@ -42,7 +44,6 @@ @Input private ValueNode trapRequest; @Input private SaveAllRegistersNode registerSaver; private final ForeignCallsProvider foreignCalls; - public static final ForeignCallDescriptor UNCOMMON_TRAP = new ForeignCallDescriptor("uncommonTrap", Word.class, Word.class, int.class); public UncommonTrapCallNode(@InjectedNodeParameter ForeignCallsProvider foreignCalls, ValueNode registerSaver, ValueNode trapRequest) { super(StampFactory.forKind(Kind.fromJavaClass(UNCOMMON_TRAP.getResultType()))); diff -r 674d4065e9fb -r af0e42dad358 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/VMErrorNode.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/VMErrorNode.java Tue May 27 13:16:12 2014 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/VMErrorNode.java Tue May 27 15:43:36 2014 +0200 @@ -23,6 +23,7 @@ package com.oracle.graal.hotspot.nodes; import static com.oracle.graal.api.meta.MetaUtil.*; +import static com.oracle.graal.hotspot.HotSpotBackend.*; import static com.oracle.graal.hotspot.nodes.CStringNode.*; import com.oracle.graal.api.code.*; @@ -40,7 +41,6 @@ private final String format; @Input private ValueNode value; - public static final ForeignCallDescriptor VM_ERROR = new ForeignCallDescriptor("vm_error", void.class, Object.class, Object.class, long.class); public VMErrorNode(String format, ValueNode value) { super(StampFactory.forVoid()); @@ -67,7 +67,7 @@ Value whereArg = emitCString(gen, whereString); Value formatArg = emitCString(gen, format); - ForeignCallLinkage linkage = gen.getLIRGeneratorTool().getForeignCalls().lookupForeignCall(VMErrorNode.VM_ERROR); + ForeignCallLinkage linkage = gen.getLIRGeneratorTool().getForeignCalls().lookupForeignCall(VM_ERROR); gen.getLIRGeneratorTool().emitForeignCall(linkage, null, whereArg, formatArg, gen.operand(value)); } diff -r 674d4065e9fb -r af0e42dad358 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/AESCryptSubstitutions.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/AESCryptSubstitutions.java Tue May 27 13:16:12 2014 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/AESCryptSubstitutions.java Tue May 27 15:43:36 2014 +0200 @@ -22,6 +22,7 @@ */ package com.oracle.graal.hotspot.replacements; +import static com.oracle.graal.hotspot.HotSpotBackend.*; import static com.oracle.graal.hotspot.replacements.HotSpotReplacementsUtil.*; import sun.misc.*; @@ -93,9 +94,6 @@ } } - public static final ForeignCallDescriptor ENCRYPT_BLOCK = new ForeignCallDescriptor("encrypt_block", void.class, Word.class, Word.class, Word.class); - public static final ForeignCallDescriptor DECRYPT_BLOCK = new ForeignCallDescriptor("decrypt_block", void.class, Word.class, Word.class, Word.class); - @NodeIntrinsic(ForeignCallNode.class) public static native void encryptBlockStub(@ConstantNodeParameter ForeignCallDescriptor descriptor, Word in, Word out, Word key); diff -r 674d4065e9fb -r af0e42dad358 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/CipherBlockChainingSubstitutions.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/CipherBlockChainingSubstitutions.java Tue May 27 13:16:12 2014 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/CipherBlockChainingSubstitutions.java Tue May 27 15:43:36 2014 +0200 @@ -22,6 +22,7 @@ */ package com.oracle.graal.hotspot.replacements; +import static com.oracle.graal.hotspot.HotSpotBackend.*; import static com.oracle.graal.hotspot.replacements.HotSpotReplacementsUtil.*; import sun.misc.*; @@ -108,9 +109,6 @@ } } - public static final ForeignCallDescriptor ENCRYPT = new ForeignCallDescriptor("encrypt", void.class, Word.class, Word.class, Word.class, Word.class, int.class); - public static final ForeignCallDescriptor DECRYPT = new ForeignCallDescriptor("decrypt", void.class, Word.class, Word.class, Word.class, Word.class, int.class); - @NodeIntrinsic(ForeignCallNode.class) public static native void encryptAESCryptStub(@ConstantNodeParameter ForeignCallDescriptor descriptor, Word in, Word out, Word key, Word r, int inLength); diff -r 674d4065e9fb -r af0e42dad358 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/MonitorSnippets.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/MonitorSnippets.java Tue May 27 13:16:12 2014 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/MonitorSnippets.java Tue May 27 15:43:36 2014 +0200 @@ -180,7 +180,7 @@ // owns the bias and we need to revoke that bias. The revocation will occur // in the interpreter runtime. traceObject(trace, "+lock{stub:revoke}", object, true); - monitorenterStub(MONITORENTER, object, lock); + monitorenterStubC(MONITORENTER, object, lock); return; } else { // At this point we know the epoch has expired, meaning that the @@ -200,7 +200,7 @@ // succeeded in biasing it toward itself and we need to revoke that // bias. The revocation will occur in the runtime in the slow case. traceObject(trace, "+lock{stub:epoch-expired}", object, true); - monitorenterStub(MONITORENTER, object, lock); + monitorenterStubC(MONITORENTER, object, lock); return; } } else { @@ -257,7 +257,7 @@ 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); - monitorenterStub(MONITORENTER, object, lock); + monitorenterStubC(MONITORENTER, object, lock); return; } else { // Recursively locked => write 0 to the lock slot @@ -283,7 +283,7 @@ // cannot float about the null check above final Word lock = beginLockScope(lockDepth); traceObject(trace, "+lock{stub}", object, true); - monitorenterStub(MONITORENTER, object, lock); + monitorenterStubC(MONITORENTER, object, lock); } @Snippet @@ -324,7 +324,7 @@ // The object's mark word was not pointing to the displaced header, // we do unlocking via runtime call. traceObject(trace, "-lock{stub}", object, false); - monitorexitStub(MONITOREXIT, object, lock); + monitorexitStubC(MONITOREXIT, object, lock); } else { traceObject(trace, "-lock{cas}", object, false); } @@ -341,7 +341,7 @@ verifyOop(object); traceObject(trace, "-lock{stub}", object, false); final Word lock = CurrentLockNode.currentLock(lockDepth); - monitorexitStub(MONITOREXIT, object, lock); + monitorexitStubC(MONITOREXIT, object, lock); endLockScope(); decCounter(); } @@ -531,9 +531,9 @@ public static final ForeignCallDescriptor MONITOREXIT = new ForeignCallDescriptor("monitorexit", void.class, Object.class, Word.class); @NodeIntrinsic(ForeignCallNode.class) - private static native void monitorenterStub(@ConstantNodeParameter ForeignCallDescriptor descriptor, Object object, Word lock); + private static native void monitorenterStubC(@ConstantNodeParameter ForeignCallDescriptor descriptor, Object object, Word lock); @NodeIntrinsic(ForeignCallNode.class) - private static native void monitorexitStub(@ConstantNodeParameter ForeignCallDescriptor descriptor, Object object, Word lock); + private static native void monitorexitStubC(@ConstantNodeParameter ForeignCallDescriptor descriptor, Object object, Word lock); } diff -r 674d4065e9fb -r af0e42dad358 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/DeoptimizationStub.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/DeoptimizationStub.java Tue May 27 13:16:12 2014 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/DeoptimizationStub.java Tue May 27 15:43:36 2014 +0200 @@ -35,7 +35,8 @@ import com.oracle.graal.hotspot.meta.*; import com.oracle.graal.hotspot.nodes.*; import com.oracle.graal.replacements.*; -import com.oracle.graal.replacements.Snippet.*; +import com.oracle.graal.replacements.Snippet.ConstantParameter; +import com.oracle.graal.replacements.Snippet.Fold; import com.oracle.graal.word.*; /** @@ -80,7 +81,7 @@ private final TargetDescription target; public DeoptimizationStub(HotSpotProviders providers, TargetDescription target, HotSpotForeignCallLinkage linkage) { - super(providers, target, linkage); + super(DeoptimizationStub.class, "deoptimizationHandler", providers, target, linkage); this.target = target; } @@ -270,8 +271,8 @@ return config().deoptimizationUnpackUncommonTrap; } - public static final ForeignCallDescriptor FETCH_UNROLL_INFO = descriptorFor(DeoptimizationStub.class, "fetchUnrollInfo"); - public static final ForeignCallDescriptor UNPACK_FRAMES = descriptorFor(DeoptimizationStub.class, "unpackFrames"); + public static final ForeignCallDescriptor FETCH_UNROLL_INFO = newDescriptor(DeoptimizationStub.class, "fetchUnrollInfo", Word.class, Word.class); + public static final ForeignCallDescriptor UNPACK_FRAMES = newDescriptor(DeoptimizationStub.class, "unpackFrames", int.class, Word.class, int.class); @NodeIntrinsic(value = StubForeignCallNode.class, setStampFromReturnType = true) public static native Word fetchUnrollInfo(@ConstantNodeParameter ForeignCallDescriptor fetchUnrollInfo, Word thread); diff -r 674d4065e9fb -r af0e42dad358 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/ExceptionHandlerStub.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/ExceptionHandlerStub.java Tue May 27 13:16:12 2014 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/ExceptionHandlerStub.java Tue May 27 15:43:36 2014 +0200 @@ -50,7 +50,7 @@ public class ExceptionHandlerStub extends SnippetStub { public ExceptionHandlerStub(HotSpotProviders providers, TargetDescription target, HotSpotForeignCallLinkage linkage) { - super(providers, target, linkage); + super("exceptionHandler", providers, target, linkage); } /** @@ -142,7 +142,7 @@ return enabled || cAssertionsEnabled(); } - public static final ForeignCallDescriptor EXCEPTION_HANDLER_FOR_PC = descriptorFor(ExceptionHandlerStub.class, "exceptionHandlerForPc"); + public static final ForeignCallDescriptor EXCEPTION_HANDLER_FOR_PC = newDescriptor(ExceptionHandlerStub.class, "exceptionHandlerForPc", Word.class, Word.class); @NodeIntrinsic(value = StubForeignCallNode.class, setStampFromReturnType = true) public static native Word exceptionHandlerForPc(@ConstantNodeParameter ForeignCallDescriptor exceptionHandlerForPc, Word thread); diff -r 674d4065e9fb -r af0e42dad358 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/NewArrayStub.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/NewArrayStub.java Tue May 27 13:16:12 2014 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/NewArrayStub.java Tue May 27 15:43:36 2014 +0200 @@ -53,7 +53,7 @@ public class NewArrayStub extends SnippetStub { public NewArrayStub(HotSpotProviders providers, TargetDescription target, HotSpotForeignCallLinkage linkage) { - super(providers, target, linkage); + super("newArray", providers, target, linkage); } @Override @@ -115,7 +115,7 @@ return verifyObject(getAndClearObjectResult(thread)); } - public static final ForeignCallDescriptor NEW_ARRAY_C = descriptorFor(NewArrayStub.class, "newArrayC"); + public static final ForeignCallDescriptor NEW_ARRAY_C = newDescriptor(NewArrayStub.class, "newArrayC", void.class, Word.class, Word.class, int.class); @NodeIntrinsic(StubForeignCallNode.class) public static native void newArrayC(@ConstantNodeParameter ForeignCallDescriptor newArrayC, Word thread, Word hub, int length); diff -r 674d4065e9fb -r af0e42dad358 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/NewInstanceStub.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/NewInstanceStub.java Tue May 27 13:16:12 2014 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/NewInstanceStub.java Tue May 27 15:43:36 2014 +0200 @@ -53,7 +53,7 @@ public class NewInstanceStub extends SnippetStub { public NewInstanceStub(HotSpotProviders providers, TargetDescription target, HotSpotForeignCallLinkage linkage) { - super(providers, target, linkage); + super("newInstance", providers, target, linkage); } @Override @@ -251,7 +251,7 @@ return Boolean.getBoolean("graal.newInstanceStub.forceSlowPath"); } - public static final ForeignCallDescriptor NEW_INSTANCE_C = descriptorFor(NewInstanceStub.class, "newInstanceC"); + public static final ForeignCallDescriptor NEW_INSTANCE_C = newDescriptor(NewInstanceStub.class, "newInstanceC", void.class, Word.class, Word.class); @NodeIntrinsic(StubForeignCallNode.class) public static native void newInstanceC(@ConstantNodeParameter ForeignCallDescriptor newInstanceC, Word thread, Word hub); diff -r 674d4065e9fb -r af0e42dad358 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/SnippetStub.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/SnippetStub.java Tue May 27 13:16:12 2014 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/SnippetStub.java Tue May 27 15:43:36 2014 +0200 @@ -44,9 +44,9 @@ static class Template extends AbstractTemplates { - Template(HotSpotProviders providers, TargetDescription target, Class declaringClass) { + Template(HotSpotProviders providers, TargetDescription target, Class declaringClass, String snippetMethodName) { super(providers, providers.getSnippetReflection(), target); - this.info = snippet(declaringClass, null); + this.info = snippet(declaringClass, snippetMethodName); } /** @@ -65,11 +65,26 @@ /** * Creates a new snippet stub. * + * @param snippetMethodName name of the single {@link Snippet} annotated method in the class of + * this object * @param linkage linkage details for a call to the stub */ - public SnippetStub(HotSpotProviders providers, TargetDescription target, HotSpotForeignCallLinkage linkage) { + public SnippetStub(String snippetMethodName, HotSpotProviders providers, TargetDescription target, HotSpotForeignCallLinkage linkage) { + this(null, snippetMethodName, providers, target, linkage); + } + + /** + * Creates a new snippet stub. + * + * @param snippetDeclaringClass this class in which the {@link Snippet} annotated method is + * declared. If {@code null}, this the class of this object is used. + * @param snippetMethodName name of the single {@link Snippet} annotated method in + * {@code snippetDeclaringClass} + * @param linkage linkage details for a call to the stub + */ + public SnippetStub(Class snippetDeclaringClass, String snippetMethodName, HotSpotProviders providers, TargetDescription target, HotSpotForeignCallLinkage linkage) { super(providers, linkage); - this.snippet = new Template(providers, target, getClass()); + this.snippet = new Template(providers, target, snippetDeclaringClass == null ? getClass() : snippetDeclaringClass, snippetMethodName); } @Override diff -r 674d4065e9fb -r af0e42dad358 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/StubUtil.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/StubUtil.java Tue May 27 13:16:12 2014 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/StubUtil.java Tue May 27 15:43:36 2014 +0200 @@ -47,14 +47,20 @@ */ public class StubUtil { - public static final ForeignCallDescriptor VM_MESSAGE_C = descriptorFor(StubUtil.class, "vmMessageC"); + public static final ForeignCallDescriptor VM_MESSAGE_C = newDescriptor(StubUtil.class, "vmMessageC", void.class, boolean.class, Word.class, long.class, long.class, long.class); + + public static ForeignCallDescriptor newDescriptor(Class stubClass, String name, Class resultType, Class... argumentTypes) { + ForeignCallDescriptor d = new ForeignCallDescriptor(name, resultType, argumentTypes); + assert descriptorFor(stubClass, name).equals(d) : descriptorFor(stubClass, name) + " != " + d; + return d; + } /** * Looks for a {@link StubForeignCallNode} node intrinsic named {@code name} in * {@code stubClass} and returns a {@link ForeignCallDescriptor} based on its signature and the * value of {@code hasSideEffect}. */ - public static ForeignCallDescriptor descriptorFor(Class stubClass, String name) { + private static ForeignCallDescriptor descriptorFor(Class stubClass, String name) { Method found = null; for (Method method : stubClass.getDeclaredMethods()) { if (Modifier.isStatic(method.getModifiers()) && method.getAnnotation(NodeIntrinsic.class) != null && method.getName().equals(name)) { diff -r 674d4065e9fb -r af0e42dad358 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/UncommonTrapStub.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/UncommonTrapStub.java Tue May 27 13:16:12 2014 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/UncommonTrapStub.java Tue May 27 15:43:36 2014 +0200 @@ -80,7 +80,7 @@ private final TargetDescription target; public UncommonTrapStub(HotSpotProviders providers, TargetDescription target, HotSpotForeignCallLinkage linkage) { - super(providers, target, linkage); + super(UncommonTrapStub.class, "uncommonTrapHandler", providers, target, linkage); this.target = target; } @@ -281,7 +281,7 @@ return config().deoptimizationUnpackUncommonTrap; } - public static final ForeignCallDescriptor UNPACK_FRAMES = descriptorFor(UncommonTrapStub.class, "unpackFrames"); + public static final ForeignCallDescriptor UNPACK_FRAMES = newDescriptor(UncommonTrapStub.class, "unpackFrames", int.class, Word.class, int.class); @NodeIntrinsic(value = StubForeignCallNode.class, setStampFromReturnType = true) public static native int unpackFrames(@ConstantNodeParameter ForeignCallDescriptor unpackFrames, Word thread, int mode); diff -r 674d4065e9fb -r af0e42dad358 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/UnwindExceptionToCallerStub.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/UnwindExceptionToCallerStub.java Tue May 27 13:16:12 2014 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/UnwindExceptionToCallerStub.java Tue May 27 15:43:36 2014 +0200 @@ -47,7 +47,7 @@ public class UnwindExceptionToCallerStub extends SnippetStub { public UnwindExceptionToCallerStub(HotSpotProviders providers, TargetDescription target, HotSpotForeignCallLinkage linkage) { - super(providers, target, linkage); + super("unwindExceptionToCaller", providers, target, linkage); } /** @@ -110,7 +110,8 @@ return enabled || cAssertionsEnabled(); } - public static final ForeignCallDescriptor EXCEPTION_HANDLER_FOR_RETURN_ADDRESS = descriptorFor(UnwindExceptionToCallerStub.class, "exceptionHandlerForReturnAddress"); + public static final ForeignCallDescriptor EXCEPTION_HANDLER_FOR_RETURN_ADDRESS = newDescriptor(UnwindExceptionToCallerStub.class, "exceptionHandlerForReturnAddress", Word.class, Word.class, + Word.class); @NodeIntrinsic(value = StubForeignCallNode.class, setStampFromReturnType = true) public static native Word exceptionHandlerForReturnAddress(@ConstantNodeParameter ForeignCallDescriptor exceptionHandlerForReturnAddress, Word thread, Word returnAddress); diff -r 674d4065e9fb -r af0e42dad358 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/VerifyOopStub.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/VerifyOopStub.java Tue May 27 13:16:12 2014 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/VerifyOopStub.java Tue May 27 15:43:36 2014 +0200 @@ -35,7 +35,7 @@ public class VerifyOopStub extends SnippetStub { public VerifyOopStub(HotSpotProviders providers, TargetDescription target, HotSpotForeignCallLinkage linkage) { - super(providers, target, linkage); + super("verifyOop", providers, target, linkage); } @Snippet diff -r 674d4065e9fb -r af0e42dad358 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/ForeignCallDescriptors.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/ForeignCallDescriptors.java Tue May 27 15:43:36 2014 +0200 @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.nodes.java; + +import com.oracle.graal.api.meta.*; + +/** + * The foreign call descriptors used by nodes in this package. + *

+ * Using a separate class for such descriptors prevents an access from triggering unwanted class + * initialization during runtime initialization. + */ +public class ForeignCallDescriptors { + + /** + * @see RegisterFinalizerNode + */ + public static final ForeignCallDescriptor REGISTER_FINALIZER = new ForeignCallDescriptor("registerFinalizer", void.class, Object.class); + +} \ No newline at end of file diff -r 674d4065e9fb -r af0e42dad358 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/RegisterFinalizerNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/RegisterFinalizerNode.java Tue May 27 13:16:12 2014 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/RegisterFinalizerNode.java Tue May 27 15:43:36 2014 +0200 @@ -22,8 +22,9 @@ */ package com.oracle.graal.nodes.java; +import static com.oracle.graal.nodes.java.ForeignCallDescriptors.*; + import com.oracle.graal.api.code.*; -import com.oracle.graal.api.meta.*; import com.oracle.graal.compiler.common.type.*; import com.oracle.graal.graph.*; import com.oracle.graal.graph.spi.*; @@ -36,8 +37,6 @@ */ public final class RegisterFinalizerNode extends AbstractStateSplit implements Canonicalizable, LIRLowerable, Virtualizable, DeoptimizingNode.DeoptAfter { - public static final ForeignCallDescriptor REGISTER_FINALIZER = new ForeignCallDescriptor("registerFinalizer", void.class, Object.class); - @Input(InputType.State) private FrameState deoptState; @Input private ValueNode object; diff -r 674d4065e9fb -r af0e42dad358 graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java --- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java Tue May 27 13:16:12 2014 +0200 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java Tue May 27 15:43:36 2014 +0200 @@ -33,6 +33,7 @@ import java.lang.reflect.*; import java.util.*; import java.util.concurrent.*; +import java.util.concurrent.atomic.*; import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; @@ -78,8 +79,51 @@ public static class SnippetInfo { protected final ResolvedJavaMethod method; - protected final boolean[] constantParameters; - protected final boolean[] varargsParameters; + + /** + * Lazily constructed parts of {@link SnippetInfo}. + */ + static class Lazy { + public Lazy(ResolvedJavaMethod method) { + int count = method.getSignature().getParameterCount(false); + constantParameters = new boolean[count]; + varargsParameters = new boolean[count]; + for (int i = 0; i < count; i++) { + constantParameters[i] = MetaUtil.getParameterAnnotation(ConstantParameter.class, i, method) != null; + varargsParameters[i] = MetaUtil.getParameterAnnotation(VarargsParameter.class, i, method) != null; + + assert !constantParameters[i] || !varargsParameters[i] : "Parameter cannot be annotated with both @" + ConstantParameter.class.getSimpleName() + " and @" + + VarargsParameter.class.getSimpleName(); + } + + // Retrieve the names only when assertions are turned on. + assert initNames(method, count); + } + + final boolean[] constantParameters; + final boolean[] varargsParameters; + + /** + * The parameter names, taken from the local variables table. Only used for assertion + * checking, so use only within an assert statement. + */ + String[] names; + + private boolean initNames(ResolvedJavaMethod method, int parameterCount) { + names = new String[parameterCount]; + int slotIdx = 0; + for (int i = 0; i < names.length; i++) { + names[i] = method.getLocalVariableTable().getLocal(slotIdx, 0).getName(); + + Kind kind = method.getSignature().getParameterKind(i); + slotIdx += kind == Kind.Long || kind == Kind.Double ? 2 : 1; + } + return true; + } + + } + + protected final AtomicReference lazy = new AtomicReference<>(null); /** * Times instantiations of all templates derived form this snippet. @@ -95,31 +139,18 @@ */ private final DebugMetric instantiationCounter; - /** - * The parameter names, taken from the local variables table. Only used for assertion - * checking, so use only within an assert statement. - */ - protected final String[] names; + private Lazy lazy() { + if (lazy.get() == null) { + lazy.compareAndSet(null, new Lazy(method)); + } + return lazy.get(); + } protected SnippetInfo(ResolvedJavaMethod method) { this.method = method; instantiationCounter = Debug.metric("SnippetInstantiationCount[%s]", method); instantiationTimer = Debug.timer("SnippetInstantiationTime[%s]", method); assert method.isStatic() : "snippet method must be static: " + MetaUtil.format("%H.%n", method); - int count = method.getSignature().getParameterCount(false); - constantParameters = new boolean[count]; - varargsParameters = new boolean[count]; - for (int i = 0; i < count; i++) { - constantParameters[i] = MetaUtil.getParameterAnnotation(ConstantParameter.class, i, method) != null; - varargsParameters[i] = MetaUtil.getParameterAnnotation(VarargsParameter.class, i, method) != null; - - assert !isConstantParameter(i) || !isVarargsParameter(i) : "Parameter cannot be annotated with both @" + ConstantParameter.class.getSimpleName() + " and @" + - VarargsParameter.class.getSimpleName(); - } - - names = new String[count]; - // Retrieve the names only when assertions are turned on. - assert initNames(); } private int templateCount; @@ -133,35 +164,28 @@ } } - private boolean initNames() { - int slotIdx = 0; - for (int i = 0; i < names.length; i++) { - names[i] = method.getLocalVariableTable().getLocal(slotIdx, 0).getName(); - - Kind kind = method.getSignature().getParameterKind(i); - slotIdx += kind == Kind.Long || kind == Kind.Double ? 2 : 1; - } - return true; - } - public ResolvedJavaMethod getMethod() { return method; } public int getParameterCount() { - return constantParameters.length; + return lazy().constantParameters.length; } public boolean isConstantParameter(int paramIdx) { - return constantParameters[paramIdx]; + return lazy().constantParameters[paramIdx]; } public boolean isVarargsParameter(int paramIdx) { - return varargsParameters[paramIdx]; + return lazy().varargsParameters[paramIdx]; } public String getParameterName(int paramIdx) { - return names[paramIdx]; + String[] names = lazy().names; + if (names != null) { + return names[paramIdx]; + } + return null; } } @@ -223,7 +247,7 @@ private boolean check(String name, boolean constParam, boolean varargsParam) { assert nextParamIdx < info.getParameterCount() : "too many parameters: " + name + " " + this; - assert info.names[nextParamIdx] == null || info.names[nextParamIdx].equals(name) : "wrong parameter name: " + name + " " + this; + assert info.getParameterName(nextParamIdx) == null || info.getParameterName(nextParamIdx).equals(name) : "wrong parameter name: " + name + " " + this; assert constParam == info.isConstantParameter(nextParamIdx) : "Parameter " + (constParam ? "not " : "") + "annotated with @" + ConstantParameter.class.getSimpleName() + ": " + name + " " + this; assert varargsParam == info.isVarargsParameter(nextParamIdx) : "Parameter " + (varargsParam ? "not " : "") + "annotated with @" + VarargsParameter.class.getSimpleName() + ": " + name + @@ -243,7 +267,7 @@ } else if (info.isVarargsParameter(i)) { result.append("varargs "); } - result.append(info.names[i]).append(" = ").append(values[i]); + result.append(info.getParameterName(i)).append(" = ").append(values[i]); sep = ", "; } result.append(">"); @@ -260,8 +284,8 @@ for (int i = 0; i < info.getParameterCount(); i++) { if (info.isConstantParameter(i)) { sb.append(sep); - if (info.names[i] != null) { - sb.append(info.names[i]); + if (info.getParameterName(i) != null) { + sb.append(info.getParameterName(i)); } else { sb.append(i); } @@ -418,25 +442,27 @@ } } + private static Method findMethod(Class declaringClass, String methodName, Method except) { + for (Method m : declaringClass.getDeclaredMethods()) { + if (m.getName().equals(methodName) && !m.equals(except)) { + return m; + } + } + return null; + } + /** - * Finds the method in {@code declaringClass} annotated with {@link Snippet} named - * {@code methodName}. If {@code methodName} is null, then there must be exactly one snippet - * method in {@code declaringClass}. + * Finds the unique method in {@code declaringClass} named {@code methodName} annotated by + * {@link Snippet} and returns a {@link SnippetInfo} value describing it. There must be + * exactly one snippet method in {@code declaringClass}. */ protected SnippetInfo snippet(Class declaringClass, String methodName) { - Method found = null; - Class clazz = declaringClass; - while (clazz != Object.class) { - for (Method method : clazz.getDeclaredMethods()) { - if (method.getAnnotation(Snippet.class) != null && (methodName == null || method.getName().equals(methodName))) { - assert found == null : "found more than one @" + Snippet.class.getSimpleName() + " method in " + declaringClass + (methodName == null ? "" : " named " + methodName); - found = method; - } - } - clazz = clazz.getSuperclass(); - } - assert found != null : "did not find @" + Snippet.class.getSimpleName() + " method in " + declaringClass + (methodName == null ? "" : " named " + methodName); - ResolvedJavaMethod javaMethod = providers.getMetaAccess().lookupJavaMethod(found); + assert methodName != null; + Method method = findMethod(declaringClass, methodName, null); + assert method != null : "did not find @" + Snippet.class.getSimpleName() + " method in " + declaringClass + " named " + methodName; + assert method.getAnnotation(Snippet.class) != null : method + " must be annotated with @" + Snippet.class.getSimpleName(); + assert findMethod(declaringClass, methodName, method) == null : "found more than one method named " + methodName + " in " + declaringClass; + ResolvedJavaMethod javaMethod = providers.getMetaAccess().lookupJavaMethod(method); providers.getReplacements().registerSnippet(javaMethod); return new SnippetInfo(javaMethod); } @@ -797,14 +823,14 @@ assert args.info.getParameterCount() == parameters.length : "number of args (" + args.info.getParameterCount() + ") != number of parameters (" + parameters.length + ")"; for (int i = 0; i < parameters.length; i++) { Object parameter = parameters[i]; - assert parameter != null : this + " has no parameter named " + args.info.names[i]; + assert parameter != null : this + " has no parameter named " + args.info.getParameterName(i); Object argument = args.values[i]; if (parameter instanceof ParameterNode) { if (argument instanceof ValueNode) { replacements.put((ParameterNode) parameter, (ValueNode) argument); } else { Kind kind = ((ParameterNode) parameter).getKind(); - assert argument != null || kind == Kind.Object : this + " cannot accept null for non-object parameter named " + args.info.names[i]; + assert argument != null || kind == Kind.Object : this + " cannot accept null for non-object parameter named " + args.info.getParameterName(i); Constant constant = forBoxed(argument, kind); replacements.put((ParameterNode) parameter, ConstantNode.forConstant(constant, metaAccess, replaceeGraph)); } @@ -836,7 +862,7 @@ } } } else { - assert parameter == CONSTANT_PARAMETER || parameter == UNUSED_PARAMETER : "unexpected entry for parameter: " + args.info.names[i] + " -> " + parameter; + assert parameter == CONSTANT_PARAMETER || parameter == UNUSED_PARAMETER : "unexpected entry for parameter: " + args.info.getParameterName(i) + " -> " + parameter; } } return replacements; @@ -1253,12 +1279,12 @@ for (int i = 0; i < args.info.getParameterCount(); i++) { if (args.info.isConstantParameter(i)) { Kind kind = signature.getParameterKind(i); - assert checkConstantArgument(metaAccess, method, signature, i, args.info.names[i], args.values[i], kind); + assert checkConstantArgument(metaAccess, method, signature, i, args.info.getParameterName(i), args.values[i], kind); } else if (args.info.isVarargsParameter(i)) { assert args.values[i] instanceof Varargs; Varargs varargs = (Varargs) args.values[i]; - assert checkVarargs(metaAccess, method, signature, i, args.info.names[i], varargs); + assert checkVarargs(metaAccess, method, signature, i, args.info.getParameterName(i), varargs); } } return true; diff -r 674d4065e9fb -r af0e42dad358 src/share/vm/graal/graalVMToCompiler.hpp --- a/src/share/vm/graal/graalVMToCompiler.hpp Tue May 27 13:16:12 2014 +0200 +++ b/src/share/vm/graal/graalVMToCompiler.hpp Tue May 27 15:43:36 2014 +0200 @@ -44,6 +44,9 @@ static Handle VMToCompiler_instance(); public: + + static bool is_HotSpotGraalRuntime_initialized() { return _HotSpotGraalRuntime_instance != NULL; } + // Gets the singleton HotSpotGraalRuntime instance, initializing it if necessary static Handle get_HotSpotGraalRuntime(); diff -r 674d4065e9fb -r af0e42dad358 src/share/vm/oops/instanceKlass.cpp --- a/src/share/vm/oops/instanceKlass.cpp Tue May 27 13:16:12 2014 +0200 +++ b/src/share/vm/oops/instanceKlass.cpp Tue May 27 15:43:36 2014 +0200 @@ -59,6 +59,10 @@ #include "services/threadService.hpp" #include "utilities/dtrace.hpp" #include "utilities/macros.hpp" +#ifdef GRAAL +#include "classfile/javaAssertions.hpp" +#include "graal/graalVMToCompiler.hpp" +#endif #if INCLUDE_ALL_GCS #include "gc_implementation/concurrentMarkSweep/cmsOopClosures.inline.hpp" #include "gc_implementation/g1/g1CollectedHeap.inline.hpp" @@ -1205,6 +1209,15 @@ #ifdef GRAAL if (this_oop->is_subtype_of(SystemDictionary::Node_klass())) { if (this_oop() != SystemDictionary::Node_klass()) { + if (!VMToCompiler::is_HotSpotGraalRuntime_initialized() && JavaAssertions::systemClassDefault() == false) { + // We want to ensure that the process of initializing HotSpotGraalRuntime + // is fast since it executes at VM startup. We must avoid triggering + // class initialization of any Node classes during this process. + ResourceMark rm; + char buf[200]; + jio_snprintf(buf, sizeof(buf), "Node subclass %s must not be initialized before HotSpotGraalRuntime is initialized", this_oop->name()->as_C_string()); + THROW_MSG(vmSymbols::java_lang_InternalError(), buf); + } // Create the NodeClass for a Node subclass. TempNewSymbol sig = SymbolTable::new_symbol("(Ljava/lang/Class;)Lcom/oracle/graal/graph/NodeClass;", CHECK); JavaValue result(T_OBJECT);