changeset 15222:58d2c5bdb9cd

Truffle: Add option TruffleReturnTypeSpeculation.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Fri, 18 Apr 2014 02:00:24 +0200
parents 3e6cbf843040
children 7d6c2a0e60a8
files graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/HotSpotTruffleRuntime.java graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/GraalTruffleRuntime.java graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallTarget.java graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerOptions.java
diffstat 4 files changed, 24 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/HotSpotTruffleRuntime.java	Thu Apr 17 23:41:00 2014 +0200
+++ b/graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/HotSpotTruffleRuntime.java	Fri Apr 18 02:00:24 2014 +0200
@@ -336,4 +336,8 @@
     public void invalidateInstalledCode(OptimizedCallTarget optimizedCallTarget) {
         HotSpotGraalRuntime.runtime().getCompilerToVM().invalidateInstalledCode(optimizedCallTarget);
     }
+
+    public void reinstallStubs() {
+        installOptimizedCallTargetCallMethod();
+    }
 }
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/GraalTruffleRuntime.java	Thu Apr 17 23:41:00 2014 +0200
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/GraalTruffleRuntime.java	Fri Apr 18 02:00:24 2014 +0200
@@ -36,4 +36,6 @@
     boolean isCompiling(OptimizedCallTarget optimizedCallTarget);
 
     void invalidateInstalledCode(OptimizedCallTarget optimizedCallTarget);
+
+    void reinstallStubs();
 }
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallTarget.java	Thu Apr 17 23:41:00 2014 +0200
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallTarget.java	Fri Apr 18 02:00:24 2014 +0200
@@ -130,13 +130,17 @@
 
     private void interpreterCall() {
         CompilerAsserts.neverPartOfCompilation();
-        compilationProfile.reportInterpreterCall();
-        if (TruffleCallTargetProfiling.getValue()) {
-            callCount++;
-        }
-
-        if (compilationPolicy.shouldCompile(compilationProfile)) {
-            compile();
+        if (this.isValid()) {
+            // Stubs were deoptimized => reinstall.
+            this.runtime.reinstallStubs();
+        } else {
+            compilationProfile.reportInterpreterCall();
+            if (TruffleCallTargetProfiling.getValue()) {
+                callCount++;
+            }
+            if (compilationPolicy.shouldCompile(compilationProfile)) {
+                compile();
+            }
         }
     }
 
@@ -251,9 +255,11 @@
 
         // Profile call return type
         if (profiledReturnTypeAssumption == null) {
-            CompilerDirectives.transferToInterpreter();
-            profiledReturnType = result.getClass();
-            profiledReturnTypeAssumption = Truffle.getRuntime().createAssumption("Profiled Return Type");
+            if (TruffleReturnTypeSpeculation.getValue()) {
+                CompilerDirectives.transferToInterpreter();
+                profiledReturnType = result.getClass();
+                profiledReturnTypeAssumption = Truffle.getRuntime().createAssumption("Profiled Return Type");
+            }
         } else if (profiledReturnType != null) {
             if (result == null || profiledReturnType != result.getClass()) {
                 CompilerDirectives.transferToInterpreter();
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerOptions.java	Thu Apr 17 23:41:00 2014 +0200
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerOptions.java	Fri Apr 18 02:00:24 2014 +0200
@@ -75,6 +75,8 @@
     public static final OptionValue<Integer> TruffleCompilationDecisionTime = new OptionValue<>(100);
     @Option(help = "")
     public static final OptionValue<Boolean> TruffleCompilationDecisionTimePrintFail = new OptionValue<>(false);
+    @Option(help = "")
+    public static final OptionValue<Boolean> TruffleReturnTypeSpeculation = new OptionValue<>(true);
 
     // tracing
     @Option(help = "")