# HG changeset patch # User Andreas Woess # Date 1441302120 -7200 # Node ID 8b3b7d701f7834da2068b7faf4c363f9a7836375 # Parent 824520386e8e1b012ca4f5def42a5f437fb28187 Truffle: defer compilation and installation of call boundary trampoline method diff -r 824520386e8e -r 8b3b7d701f78 graal/com.oracle.graal.truffle.hotspot.amd64/src/com/oracle/graal/truffle/hotspot/amd64/AMD64OptimizedCallTargetInstrumentationFactory.java --- a/graal/com.oracle.graal.truffle.hotspot.amd64/src/com/oracle/graal/truffle/hotspot/amd64/AMD64OptimizedCallTargetInstrumentationFactory.java Thu Sep 03 19:24:03 2015 +0200 +++ b/graal/com.oracle.graal.truffle.hotspot.amd64/src/com/oracle/graal/truffle/hotspot/amd64/AMD64OptimizedCallTargetInstrumentationFactory.java Thu Sep 03 19:42:00 2015 +0200 @@ -67,11 +67,6 @@ }; } - public void setInstrumentedMethod(ResolvedJavaMethod method) { - HotSpotResolvedJavaMethod hsMethod = (HotSpotResolvedJavaMethod) method; - hsMethod.setNotInlineable(); - } - public String getArchitecture() { return "AMD64"; } diff -r 824520386e8e -r 8b3b7d701f78 graal/com.oracle.graal.truffle.hotspot.sparc/src/com/oracle/graal/truffle/hotspot/sparc/SPARCOptimizedCallTargetInstumentationFactory.java --- a/graal/com.oracle.graal.truffle.hotspot.sparc/src/com/oracle/graal/truffle/hotspot/sparc/SPARCOptimizedCallTargetInstumentationFactory.java Thu Sep 03 19:24:03 2015 +0200 +++ b/graal/com.oracle.graal.truffle.hotspot.sparc/src/com/oracle/graal/truffle/hotspot/sparc/SPARCOptimizedCallTargetInstumentationFactory.java Thu Sep 03 19:42:00 2015 +0200 @@ -29,7 +29,6 @@ import static jdk.internal.jvmci.meta.Kind.*; import jdk.internal.jvmci.code.*; import jdk.internal.jvmci.hotspot.*; -import jdk.internal.jvmci.meta.*; import jdk.internal.jvmci.service.*; import com.oracle.graal.asm.*; @@ -70,11 +69,6 @@ }; } - public void setInstrumentedMethod(ResolvedJavaMethod method) { - HotSpotResolvedJavaMethod hsMethod = (HotSpotResolvedJavaMethod) method; - hsMethod.setNotInlineable(); - } - public String getArchitecture() { return "SPARC"; } diff -r 824520386e8e -r 8b3b7d701f78 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 Thu Sep 03 19:24:03 2015 +0200 +++ b/graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/HotSpotTruffleRuntime.java Thu Sep 03 19:42:00 2015 +0200 @@ -79,7 +79,7 @@ private final Map callTargets = Collections.synchronizedMap(new WeakHashMap()); private HotSpotTruffleRuntime() { - installOptimizedCallTargetCallMethod(); + setDontInlineCallBoundaryMethod(); lookupCallMethods(getGraalProviders().getMetaAccess()); installDefaultListeners(); @@ -147,6 +147,17 @@ return createCallTargetImpl(source, root); } + public static void setDontInlineCallBoundaryMethod() { + Providers providers = getGraalProviders(); + MetaAccessProvider metaAccess = providers.getMetaAccess(); + ResolvedJavaType type = metaAccess.lookupJavaType(OptimizedCallTarget.class); + for (ResolvedJavaMethod method : type.getDeclaredMethods()) { + if (method.getAnnotation(TruffleCallBoundary.class) != null) { + ((HotSpotResolvedJavaMethod) method).setNotInlineable(); + } + } + } + @SuppressWarnings("try") public static void installOptimizedCallTargetCallMethod() { Providers providers = getGraalProviders(); @@ -165,10 +176,9 @@ } } - private static CompilationResultBuilderFactory getOptimizedCallTargetInstrumentationFactory(String arch, ResolvedJavaMethod method) { + private static CompilationResultBuilderFactory getOptimizedCallTargetInstrumentationFactory(String arch) { for (OptimizedCallTargetInstrumentationFactory factory : Services.load(OptimizedCallTargetInstrumentationFactory.class)) { if (factory.getArchitecture().equals(arch)) { - factory.setInstrumentedMethod(method); return factory; } } @@ -193,7 +203,7 @@ PhaseSuite graphBuilderSuite = getGraphBuilderSuite(suitesProvider); CallingConvention cc = getCallingConvention(providers.getCodeCache(), Type.JavaCallee, graph.method(), false); Backend backend = Graal.getRequiredCapability(RuntimeProvider.class).getHostBackend(); - CompilationResultBuilderFactory factory = getOptimizedCallTargetInstrumentationFactory(backend.getTarget().arch.getName(), javaMethod); + CompilationResultBuilderFactory factory = getOptimizedCallTargetInstrumentationFactory(backend.getTarget().arch.getName()); return compileGraph(graph, cc, javaMethod, providers, backend, graphBuilderSuite, OptimisticOptimizations.ALL, getProfilingInfo(graph), suites, lirSuites, new CompilationResult(), factory); } diff -r 824520386e8e -r 8b3b7d701f78 graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallTargetInstrumentationFactory.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallTargetInstrumentationFactory.java Thu Sep 03 19:24:03 2015 +0200 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallTargetInstrumentationFactory.java Thu Sep 03 19:42:00 2015 +0200 @@ -22,8 +22,6 @@ */ package com.oracle.graal.truffle; -import jdk.internal.jvmci.meta.*; - import com.oracle.graal.lir.asm.*; /** @@ -36,9 +34,4 @@ * Gets the architecture supported by this factory. */ String getArchitecture(); - - /** - * Notifies this object of the method that is being instrumented. - */ - void setInstrumentedMethod(ResolvedJavaMethod method); } diff -r 824520386e8e -r 8b3b7d701f78 graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompiler.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompiler.java Thu Sep 03 19:24:03 2015 +0200 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompiler.java Thu Sep 03 19:42:00 2015 +0200 @@ -99,6 +99,8 @@ if (Debug.isEnabled()) { DebugEnvironment.initialize(System.out); } + + graalTruffleRuntime.reinstallStubs(); } public GraphBuilderConfiguration getGraphBuilderConfiguration() {