# HG changeset patch # User Lukas Stadler # Date 1412581182 -7200 # Node ID e3f3233ec6cd481a725f44205fb899c0a9d00b96 # Parent 53e91025205f4318da6ea8d0e5d1252c14917fb4 refactor BailoutException to include information about non-permanent errors diff -r 53e91025205f -r e3f3233ec6cd graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/BailoutException.java --- 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; } } diff -r 53e91025205f -r e3f3233ec6cd graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotCodeCacheProvider.java --- 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); } diff -r 53e91025205f -r e3f3233ec6cd graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/phases/OnStackReplacementPhase.java --- 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); diff -r 53e91025205f -r e3f3233ec6cd graal/com.oracle.graal.java/src/com/oracle/graal/java/AbstractBytecodeParser.java --- 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 diff -r 53e91025205f -r e3f3233ec6cd graal/com.oracle.graal.lir/src/com/oracle/graal/lir/FrameMap.java --- 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()); } } diff -r 53e91025205f -r e3f3233ec6cd graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/IterativeConditionalEliminationPhase.java --- 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); } } } diff -r 53e91025205f -r e3f3233ec6cd graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/cfs/IterativeFlowSensitiveReductionPhase.java --- 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(); diff -r 53e91025205f -r e3f3233ec6cd 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 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); diff -r 53e91025205f -r e3f3233ec6cd graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/PartialEvaluator.java --- 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()); } }