# HG changeset patch # User Doug Simon # Date 1394707044 -3600 # Node ID a0c31f940950d8280cb953ccc05424ae36618646 # Parent a1ddf86f5d79ebb6f44318bd477be3d5a1caa303 use AssertionError subclass for verification errors found by VerifyPhases diff -r a1ddf86f5d79 -r a0c31f940950 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/CheckGraalInvariants.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/CheckGraalInvariants.java Thu Mar 13 01:33:50 2014 +0100 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/CheckGraalInvariants.java Thu Mar 13 11:37:24 2014 +0100 @@ -37,6 +37,7 @@ import com.oracle.graal.java.*; import com.oracle.graal.nodes.*; import com.oracle.graal.phases.*; +import com.oracle.graal.phases.VerifyPhase.VerificationError; import com.oracle.graal.phases.tiers.*; import com.oracle.graal.phases.util.*; import com.oracle.graal.phases.verify.*; @@ -115,10 +116,12 @@ try (DebugConfigScope s = Debug.setConfig(noInterceptConfig)) { graphBuilderSuite.apply(graph, context); checkGraph(context, graph); - } catch (AssertionError e) { + } catch (VerificationError e) { errors.add(e.getMessage()); } catch (LinkageError e) { // suppress linkages errors resulting from eager resolution + } catch (Throwable e) { + throw new AssertionError("Error while checking " + methodName, e); } } diff -r a1ddf86f5d79 -r a0c31f940950 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/phases/AheadOfTimeVerificationPhase.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/phases/AheadOfTimeVerificationPhase.java Thu Mar 13 01:33:50 2014 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/phases/AheadOfTimeVerificationPhase.java Thu Mar 13 11:37:24 2014 +0100 @@ -42,7 +42,9 @@ protected boolean verify(StructuredGraph graph, PhaseContext context) { for (ConstantNode node : getConstantNodes(graph)) { if (node.recordsUsages() || !node.gatherUsages(graph).isEmpty()) { - assert !isObject(node) || isNullReference(node) || isInternedString(node) : "illegal object constant: " + node; + if (isObject(node) && !isNullReference(node) && !isInternedString(node)) { + throw new VerificationError("illegal object constant: " + node); + } } } return true; diff -r a1ddf86f5d79 -r a0c31f940950 graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java --- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java Thu Mar 13 01:33:50 2014 +0100 +++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java Thu Mar 13 11:37:24 2014 +0100 @@ -825,7 +825,7 @@ * calls). Also, interfaces are initialized only under special circumstances, so that * this assertion would often fail for interface calls. */ - assert !graphBuilderConfig.unresolvedIsError() || (result instanceof ResolvedJavaMethod && (opcode != INVOKESTATIC || ((ResolvedJavaMethod) result).getDeclaringClass().isInitialized())); + assert !graphBuilderConfig.unresolvedIsError() || (result instanceof ResolvedJavaMethod && (opcode != INVOKESTATIC || ((ResolvedJavaMethod) result).getDeclaringClass().isInitialized())) : result; return result; } diff -r a1ddf86f5d79 -r a0c31f940950 graal/com.oracle.graal.phases/src/com/oracle/graal/phases/VerifyPhase.java --- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/VerifyPhase.java Thu Mar 13 01:33:50 2014 +0100 +++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/VerifyPhase.java Thu Mar 13 11:37:24 2014 +0100 @@ -27,15 +27,35 @@ /*** * This phase serves as a verification, in order to check the graph for certain properties. The * {@link #verify(StructuredGraph, Object)} method will be used as an assertion, and implements the - * actual check. Instead of returning false, it is also valid to throw an {@link AssertionError} in - * the implemented {@link #verify(StructuredGraph, Object)} method. + * actual check. Instead of returning false, it is also valid to throw an {@link VerificationError} + * in the implemented {@link #verify(StructuredGraph, Object)} method. */ public abstract class VerifyPhase extends BasePhase { + /** + * Thrown when verification performed by a {@link VerifyPhase} fails. + */ + @SuppressWarnings("serial") + public static class VerificationError extends AssertionError { + + public VerificationError(String message) { + super(message); + } + + public VerificationError(String message, Throwable cause) { + super(message, cause); + } + } + @Override protected final void run(StructuredGraph graph, C context) { assert verify(graph, context); } + /** + * Performs the actual verification. + * + * @throws VerificationError if the verification fails + */ protected abstract boolean verify(StructuredGraph graph, C context); } diff -r a1ddf86f5d79 -r a0c31f940950 graal/com.oracle.graal.phases/src/com/oracle/graal/phases/verify/VerifyUsageWithEquals.java --- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/verify/VerifyUsageWithEquals.java Thu Mar 13 01:33:50 2014 +0100 +++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/verify/VerifyUsageWithEquals.java Thu Mar 13 11:37:24 2014 +0100 @@ -66,8 +66,10 @@ protected boolean verify(StructuredGraph graph, PhaseContext context) { for (ObjectEqualsNode cn : graph.getNodes().filter(ObjectEqualsNode.class)) { // bail out if we compare an object of type klass with == or != (except null checks) - assert !(checkUsage(cn.x(), cn.y(), context.getMetaAccess()) && checkUsage(cn.y(), cn.x(), context.getMetaAccess())) : "Verification of " + klass.getName() + " usage failed: Comparing " + - cn.x() + " and " + cn.y() + " in " + graph.method() + " must use .equals() for object equality, not '==' or '!='"; + if (checkUsage(cn.x(), cn.y(), context.getMetaAccess()) && checkUsage(cn.y(), cn.x(), context.getMetaAccess())) { + throw new VerificationError("Verification of " + klass.getName() + " usage failed: Comparing " + cn.x() + " and " + cn.y() + " in " + graph.method() + + " must use .equals() for object equality, not '==' or '!='"); + } } return true; }