changeset 22578:8b3b7d701f78

Truffle: defer compilation and installation of call boundary trampoline method
author Andreas Woess <andreas.woess@oracle.com>
date Thu, 03 Sep 2015 19:42:00 +0200
parents 824520386e8e
children f5ba870db392
files graal/com.oracle.graal.truffle.hotspot.amd64/src/com/oracle/graal/truffle/hotspot/amd64/AMD64OptimizedCallTargetInstrumentationFactory.java graal/com.oracle.graal.truffle.hotspot.sparc/src/com/oracle/graal/truffle/hotspot/sparc/SPARCOptimizedCallTargetInstumentationFactory.java graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/HotSpotTruffleRuntime.java graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallTargetInstrumentationFactory.java graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompiler.java
diffstat 5 files changed, 16 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- 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";
     }
--- 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";
     }
--- 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<RootCallTarget, Void> callTargets = Collections.synchronizedMap(new WeakHashMap<RootCallTarget, Void>());
 
     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<HighTierContext> 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);
     }
 
--- 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);
 }
--- 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() {