# HG changeset patch # User Thomas Wuerthinger # Date 1397779224 -7200 # Node ID 58d2c5bdb9cd2e762987a607b975d232bdb238dc # Parent 3e6cbf84304005148231f7157f5ec7a9f16046ec Truffle: Add option TruffleReturnTypeSpeculation. diff -r 3e6cbf843040 -r 58d2c5bdb9cd 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 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(); + } } diff -r 3e6cbf843040 -r 58d2c5bdb9cd 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 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(); } diff -r 3e6cbf843040 -r 58d2c5bdb9cd graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallTarget.java --- 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(); diff -r 3e6cbf843040 -r 58d2c5bdb9cd graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerOptions.java --- 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 TruffleCompilationDecisionTime = new OptionValue<>(100); @Option(help = "") public static final OptionValue TruffleCompilationDecisionTimePrintFail = new OptionValue<>(false); + @Option(help = "") + public static final OptionValue TruffleReturnTypeSpeculation = new OptionValue<>(true); // tracing @Option(help = "")