# HG changeset patch # User Andreas Woess # Date 1443624393 -7200 # Node ID 359f60a0a45734c7d0ff6bf5e11c54b924b9e8a9 # Parent 5e8c004f535835615302609e1985ba65124630e5 Truffle: defer lookup of call methods diff -r 5e8c004f5358 -r 359f60a0a457 graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/HotSpotTruffleRuntime.java --- a/graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/HotSpotTruffleRuntime.java Wed Sep 30 16:19:48 2015 +0200 +++ b/graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/HotSpotTruffleRuntime.java Wed Sep 30 16:46:33 2015 +0200 @@ -127,7 +127,6 @@ private HotSpotTruffleRuntime() { setDontInlineCallBoundaryMethod(); - lookupCallMethods(getHotSpotProviders().getMetaAccess()); installDefaultListeners(); @@ -380,11 +379,19 @@ } @Override - public boolean platformEnableInfopoints() { + protected boolean platformEnableInfopoints() { return getCodeCache().shouldDebugNonSafepoints(); } @Override + protected CallMethods getCallMethods() { + if (callMethods == null) { + lookupCallMethods(getHotSpotProviders().getMetaAccess()); + } + return callMethods; + } + + @Override public Collection getCallTargets() { return Collections.unmodifiableSet(callTargets.keySet()); } diff -r 5e8c004f5358 -r 359f60a0a457 graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/GraalTruffleRuntime.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/GraalTruffleRuntime.java Wed Sep 30 16:19:48 2015 +0200 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/GraalTruffleRuntime.java Wed Sep 30 16:46:33 2015 +0200 @@ -75,15 +75,12 @@ private ArrayList includes; private ArrayList excludes; - protected ResolvedJavaMethod[] callNodeMethod; - protected ResolvedJavaMethod[] callTargetMethod; - protected ResolvedJavaMethod[] anyFrameMethod; - private final List compilationListeners = new ArrayList<>(); private final GraalTruffleCompilationListener compilationNotify = new DispatchTruffleCompilationListener(); protected TruffleCompiler truffleCompiler; protected LoopNodeFactory loopNodeFactory; + protected CallMethods callMethods; public GraalTruffleRuntime() { Runtime.getRuntime().addShutdownHook(new Thread(this::shutdown)); @@ -125,9 +122,7 @@ } protected void lookupCallMethods(MetaAccessProvider metaAccess) { - callNodeMethod = new ResolvedJavaMethod[]{metaAccess.lookupJavaMethod(GraalFrameInstance.CallNodeFrame.METHOD)}; - callTargetMethod = new ResolvedJavaMethod[]{metaAccess.lookupJavaMethod(GraalFrameInstance.CallTargetFrame.METHOD)}; - anyFrameMethod = new ResolvedJavaMethod[]{callNodeMethod[0], callTargetMethod[0]}; + callMethods = CallMethods.lookup(metaAccess); } @Override @@ -207,22 +202,22 @@ public T visitFrame(InspectedFrame frame) { if (skipNext) { - assert frame.isMethod(callTargetMethod[0]); + assert frame.isMethod(getCallMethods().callTargetMethod[0]); skipNext = false; return null; } - if (frame.isMethod(callNodeMethod[0])) { + if (frame.isMethod(getCallMethods().callNodeMethod[0])) { skipNext = true; return visitor.visitFrame(new GraalFrameInstance.CallNodeFrame(frame)); } else { - assert frame.isMethod(callTargetMethod[0]); + assert frame.isMethod(getCallMethods().callTargetMethod[0]); return visitor.visitFrame(new GraalFrameInstance.CallTargetFrame(frame, false)); } } }; - return stackIntrospection.iterateFrames(anyFrameMethod, anyFrameMethod, 1, inspectedFrameVisitor); + return stackIntrospection.iterateFrames(getCallMethods().anyFrameMethod, getCallMethods().anyFrameMethod, 1, inspectedFrameVisitor); } protected abstract StackIntrospection getStackIntrospection(); @@ -235,7 +230,7 @@ @TruffleBoundary @Override public FrameInstance getCurrentFrame() { - return getStackIntrospection().iterateFrames(callTargetMethod, callTargetMethod, 0, frame -> new GraalFrameInstance.CallTargetFrame(frame, true)); + return getStackIntrospection().iterateFrames(getCallMethods().callTargetMethod, getCallMethods().callTargetMethod, 0, frame -> new GraalFrameInstance.CallTargetFrame(frame, true)); } public T getCapability(Class capability) { @@ -329,6 +324,10 @@ protected abstract boolean platformEnableInfopoints(); + protected CallMethods getCallMethods() { + return callMethods; + } + private final class DispatchTruffleCompilationListener implements GraalTruffleCompilationListener { public void notifyCompilationQueued(OptimizedCallTarget target) { @@ -376,4 +375,20 @@ } } + + protected static final class CallMethods { + protected final ResolvedJavaMethod[] callNodeMethod; + protected final ResolvedJavaMethod[] callTargetMethod; + protected final ResolvedJavaMethod[] anyFrameMethod; + + private CallMethods(MetaAccessProvider metaAccess) { + this.callNodeMethod = new ResolvedJavaMethod[]{metaAccess.lookupJavaMethod(GraalFrameInstance.CallNodeFrame.METHOD)}; + this.callTargetMethod = new ResolvedJavaMethod[]{metaAccess.lookupJavaMethod(GraalFrameInstance.CallTargetFrame.METHOD)}; + this.anyFrameMethod = new ResolvedJavaMethod[]{callNodeMethod[0], callTargetMethod[0]}; + } + + public static CallMethods lookup(MetaAccessProvider metaAccess) { + return new CallMethods(metaAccess); + } + } }