changeset 17341:e3f3233ec6cd

refactor BailoutException to include information about non-permanent errors
author Lukas Stadler <lukas.stadler@oracle.com>
date Mon, 06 Oct 2014 09:39:42 +0200
parents 53e91025205f
children a690ca62772c
files graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/BailoutException.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotCodeCacheProvider.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/phases/OnStackReplacementPhase.java graal/com.oracle.graal.java/src/com/oracle/graal/java/AbstractBytecodeParser.java graal/com.oracle.graal.lir/src/com/oracle/graal/lir/FrameMap.java graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/IterativeConditionalEliminationPhase.java graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/cfs/IterativeFlowSensitiveReductionPhase.java graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallTarget.java graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/PartialEvaluator.java
diffstat 9 files changed, 25 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/BailoutException.java	Mon Oct 06 09:39:34 2014 +0200
+++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/BailoutException.java	Mon Oct 06 09:39:42 2014 +0200
@@ -32,33 +32,34 @@
 public class BailoutException extends RuntimeException {
 
     public static final long serialVersionUID = 8974598793458772L;
+    private final boolean permanent;
 
     /**
      * Creates a new {@link BailoutException}.
-     * 
-     * @param reason a message indicating the reason
+     *
+     *
+     * @param args parameters to the formatter
      */
-    public BailoutException(String reason) {
-        super(reason);
+    public BailoutException(String format, Object... args) {
+        super(String.format(Locale.ENGLISH, format, args));
+        this.permanent = false;
     }
 
     /**
      * Creates a new {@link BailoutException}.
-     * 
+     *
+     * @param permanent specifies whether this exception will occur again if compilation is retried
      * @param args parameters to the formatter
      */
-    public BailoutException(String format, Object... args) {
-        this(String.format(Locale.ENGLISH, format, args));
+    public BailoutException(boolean permanent, String format, Object... args) {
+        super(String.format(Locale.ENGLISH, format, args));
+        this.permanent = permanent;
     }
 
     /**
-     * Creates a new {@link BailoutException} due to an internal exception being thrown.
-     * 
-     * @param reason a message indicating the reason
-     * @param cause the throwable that was the cause of the bailout
+     * @return whether this exception will occur again if compilation is retried
      */
-    public BailoutException(String reason, Throwable cause) {
-        super(reason);
-        initCause(cause);
+    public boolean isPermanent() {
+        return permanent;
     }
 }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotCodeCacheProvider.java	Mon Oct 06 09:39:34 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotCodeCacheProvider.java	Mon Oct 06 09:39:42 2014 +0200
@@ -228,7 +228,7 @@
         }
         CodeInstallResult result = runtime.getCompilerToVM().installCode(new HotSpotCompiledNmethod(target, hotspotMethod, compResult), installedCode, log);
         if (result != CodeInstallResult.OK) {
-            throw new BailoutException("Code installation failed: " + result);
+            throw new BailoutException(result != CodeInstallResult.DEPENDENCIES_FAILED, "Code installation failed: %s", result);
         }
         return logOrDump(installedCode, compResult);
     }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/phases/OnStackReplacementPhase.java	Mon Oct 06 09:39:34 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/phases/OnStackReplacementPhase.java	Mon Oct 06 09:39:42 2014 +0200
@@ -61,7 +61,7 @@
                 throw new BailoutException("OSR with locks not supported");
             }
             if (osr.stateAfter().stackSize() != 0) {
-                throw new BailoutException("OSR with stack entries not supported: " + osr.stateAfter().toString(Verbosity.Debugger));
+                throw new BailoutException("OSR with stack entries not supported: %s", osr.stateAfter().toString(Verbosity.Debugger));
             }
             LoopEx osrLoop = null;
             LoopsData loops = new LoopsData(graph);
--- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/AbstractBytecodeParser.java	Mon Oct 06 09:39:34 2014 +0200
+++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/AbstractBytecodeParser.java	Mon Oct 06 09:39:42 2014 +0200
@@ -1132,7 +1132,7 @@
         case BREAKPOINT:
             throw new BailoutException("concurrent setting of breakpoint");
         default:
-            throw new BailoutException("Unsupported opcode " + opcode + " (" + nameOf(opcode) + ") [bci=" + bci + "]");
+            throw new BailoutException("Unsupported opcode %d (%s) [bci=%d]", opcode, nameOf(opcode), bci);
     }
     // @formatter:on
         // Checkstyle: resume
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/FrameMap.java	Mon Oct 06 09:39:34 2014 +0200
+++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/FrameMap.java	Mon Oct 06 09:39:42 2014 +0200
@@ -190,7 +190,7 @@
         }
         frameSize = currentFrameSize();
         if (frameSize > registerConfig.getMaximumFrameSize()) {
-            throw new BailoutException(String.format("Frame size (%d) exceeded maximum allowed frame size (%d).", frameSize, registerConfig.getMaximumFrameSize()));
+            throw new BailoutException("Frame size (%d) exceeded maximum allowed frame size (%d).", frameSize, registerConfig.getMaximumFrameSize());
         }
     }
 
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/IterativeConditionalEliminationPhase.java	Mon Oct 06 09:39:34 2014 +0200
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/IterativeConditionalEliminationPhase.java	Mon Oct 06 09:39:42 2014 +0200
@@ -63,7 +63,7 @@
             canonicalizer.applyIncremental(graph, context, listener.getNodes());
             listener.getNodes().clear();
             if (++count > MAX_ITERATIONS) {
-                throw new BailoutException("Number of iterations in ConditionalEliminationPhase phase exceeds " + MAX_ITERATIONS);
+                throw new BailoutException("Number of iterations in ConditionalEliminationPhase phase exceeds %d", MAX_ITERATIONS);
             }
         }
     }
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/cfs/IterativeFlowSensitiveReductionPhase.java	Mon Oct 06 09:39:34 2014 +0200
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/cfs/IterativeFlowSensitiveReductionPhase.java	Mon Oct 06 09:39:42 2014 +0200
@@ -70,7 +70,7 @@
                 // System.out.println("Bailing out IterativeFlowSensitiveReductionPhase for graph: "
                 // + graph);
                 // FlowUtil.visualize(graph, "Bailout");
-                throw new BailoutException("Number of iterations in FlowSensitiveReductionPhase exceeds " + MAX_ITERATIONS);
+                throw new BailoutException("Number of iterations in FlowSensitiveReductionPhase exceeds %d", MAX_ITERATIONS);
             }
         }
         // histogram.print();
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallTarget.java	Mon Oct 06 09:39:34 2014 +0200
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallTarget.java	Mon Oct 06 09:39:42 2014 +0200
@@ -339,7 +339,9 @@
                 dequeueInlinedCallSites(inliningDecision);
             }
         } else {
-            compilationPolicy.recordCompilationFailure(t);
+            if (!(t instanceof BailoutException) || ((BailoutException) t).isPermanent()) {
+                compilationPolicy.recordCompilationFailure(t);
+            }
 
             if (TruffleCompilationExceptionsAreThrown.getValue()) {
                 throw new OptimizationFailedException(t, rootNode);
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/PartialEvaluator.java	Mon Oct 06 09:39:34 2014 +0200
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/PartialEvaluator.java	Mon Oct 06 09:39:42 2014 +0200
@@ -272,7 +272,7 @@
                 }
 
                 if (graph.getNodeCount() > TruffleCompilerOptions.TruffleGraphMaxNodes.getValue()) {
-                    throw new BailoutException("Truffle compilation is exceeding maximum node count: " + graph.getNodeCount());
+                    throw new BailoutException("Truffle compilation is exceeding maximum node count: %d", graph.getNodeCount());
                 }
             }