Mercurial > hg > truffle
changeset 15189:19a98af07b63
Truffle: Make sure exceptions during compilation result in a bailout.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Thu, 17 Apr 2014 13:17:16 +0200 |
parents | 78f1a1a70628 |
children | 039d8902bdb8 |
files | graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/HotSpotOptimizedCallTarget.java graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallTarget.java graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerImpl.java graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerOptions.java |
diffstat | 4 files changed, 25 insertions(+), 26 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/HotSpotOptimizedCallTarget.java Wed Apr 16 22:54:48 2014 +0200 +++ b/graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/HotSpotOptimizedCallTarget.java Thu Apr 17 13:17:16 2014 +0200 @@ -53,10 +53,6 @@ return speculationLog; } - public boolean isOptimized() { - return isValid() || installedCodeTask != null; - } - @Override public Object call(Object... args) { return callBoundary(args); @@ -111,7 +107,6 @@ Future<InstalledCode> task = this.installedCodeTask; if (task != null) { task.cancel(true); - this.installedCodeTask = null; logOptimizingUnqueued(this, oldNode, newNode, reason); compilationProfile.reportInvalidated(); } @@ -140,7 +135,7 @@ Future<InstalledCode> codeTask = this.installedCodeTask; if (codeTask != null) { if (codeTask.isCancelled() || codeTask.isDone()) { - installedCodeTask = null; + // System.out.println("done or cancelled => set null " + codeTask.isCancelled()); return false; } return true; @@ -160,23 +155,26 @@ } } - private InstalledCode receiveInstalledCode() { + @Override + public void exceptionWhileCompiling(Throwable t) { + compilationEnabled = false; + logOptimizingFailed(this, t.getMessage()); + if (t instanceof BailoutException) { + // Bailout => move on. + } else { + if (TruffleCompilationExceptionsAreFatal.getValue()) { + t.printStackTrace(OUT); + System.exit(-1); + } + } + } + + private void receiveInstalledCode() { try { - return installedCodeTask.get(); + // Force task completion. + installedCodeTask.get(); } catch (InterruptedException | ExecutionException e) { - compilationEnabled = false; - logOptimizingFailed(this, e.getMessage()); - if (e.getCause() instanceof BailoutException) { - // Bailout => move on. - } else { - if (TraceTruffleCompilationExceptions.getValue()) { - e.printStackTrace(OUT); - } - if (TruffleCompilationExceptionsAreFatal.getValue()) { - System.exit(-1); - } - } - return null; + exceptionWhileCompiling(e.getCause()); } }
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallTarget.java Wed Apr 16 22:54:48 2014 +0200 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallTarget.java Thu Apr 17 13:17:16 2014 +0200 @@ -188,4 +188,6 @@ } + public abstract void exceptionWhileCompiling(Throwable e); + }
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerImpl.java Wed Apr 16 22:54:48 2014 +0200 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerImpl.java Thu Apr 17 13:17:16 2014 +0200 @@ -118,11 +118,12 @@ public Future<InstalledCode> compile(final OptimizedCallTarget compilable) { return compileQueue.submit(new Callable<InstalledCode>() { @Override - public InstalledCode call() throws Exception { + public InstalledCode call() { try (Scope s = Debug.scope("Truffle", new TruffleDebugJavaMethod(compilable))) { return compileMethodImpl(compilable); } catch (Throwable e) { - throw Debug.handle(e); + compilable.exceptionWhileCompiling(e); + return null; } } });
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerOptions.java Wed Apr 16 22:54:48 2014 +0200 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerOptions.java Thu Apr 17 13:17:16 2014 +0200 @@ -94,9 +94,7 @@ @Option(help = "") public static final OptionValue<Boolean> TraceTruffleCacheDetails = new OptionValue<>(false); @Option(help = "") - public static final OptionValue<Boolean> TraceTruffleCompilationExceptions = new OptionValue<>(true); - @Option(help = "") - public static final OptionValue<Boolean> TruffleCompilationExceptionsAreFatal = new OptionValue<>(true); + public static final OptionValue<Boolean> TruffleCompilationExceptionsAreFatal = new OptionValue<>(false); @Option(help = "") public static final OptionValue<Boolean> TraceTruffleInlining = new OptionValue<>(false); @Option(help = "")