# HG changeset patch # User Doug Simon # Date 1366907783 -7200 # Node ID c78ef1df7b067567ddacda1a9a0d939c1815c451 # Parent ba441e21796f23ef67fe040a9eadb4a1dd8e18ad made verification of node intrinsification always be run, independent of whether assertions are enabled improved error message when verification of node intrinsification fails diff -r ba441e21796f -r c78ef1df7b06 graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/NodeIntrinsificationVerificationPhase.java --- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/NodeIntrinsificationVerificationPhase.java Thu Apr 25 17:46:35 2013 +0200 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/NodeIntrinsificationVerificationPhase.java Thu Apr 25 18:36:23 2013 +0200 @@ -24,20 +24,20 @@ import com.oracle.graal.api.meta.*; import com.oracle.graal.graph.*; +import com.oracle.graal.graph.Node.ConstantNodeParameter; import com.oracle.graal.graph.Node.NodeIntrinsic; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.java.*; import com.oracle.graal.phases.*; -import com.oracle.graal.replacements.Snippet.*; +import com.oracle.graal.replacements.Snippet.Fold; /** * Checks that a graph contains no calls to {@link NodeIntrinsic} or {@link Fold} methods. */ public class NodeIntrinsificationVerificationPhase extends Phase { - public static boolean verify(StructuredGraph graph) { + public static void verify(StructuredGraph graph) { new NodeIntrinsificationVerificationPhase().apply(graph); - return true; } @Override @@ -49,11 +49,17 @@ private static void checkInvoke(MethodCallTargetNode n) { ResolvedJavaMethod target = n.targetMethod(); - NodeIntrinsic intrinsic = target.getAnnotation(Node.NodeIntrinsic.class); - if (intrinsic != null) { - throw new GraalInternalError("Illegal call to node intrinsic in " + n.graph() + ": " + n.invoke()); + if (target.getAnnotation(Node.NodeIntrinsic.class) != null) { + error(n, "Intrinsification"); } else if (target.getAnnotation(Fold.class) != null) { - throw new GraalInternalError("Illegal call to foldable method in " + n.graph() + ": " + n.invoke()); + error(n, "Folding"); } } + + private static void error(MethodCallTargetNode n, String failedAction) throws GraalInternalError { + String context = MetaUtil.format("%H.%n", ((StructuredGraph) n.graph()).method()); + String target = n.invoke().callTarget().targetName(); + throw new GraalInternalError(failedAction + " of call to '" + target + "' in '" + context + "' failed, most likely due to a parameter annotated with @" + + ConstantNodeParameter.class.getSimpleName() + " not being resolvable to a constant during compilation"); + } } diff -r ba441e21796f -r c78ef1df7b06 graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsImpl.java --- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsImpl.java Thu Apr 25 17:46:35 2013 +0200 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsImpl.java Thu Apr 25 18:36:23 2013 +0200 @@ -279,7 +279,9 @@ */ protected void finalizeGraph(StructuredGraph graph) { new NodeIntrinsificationPhase(runtime).apply(graph); - assert SnippetTemplate.hasConstantParameter(method) || NodeIntrinsificationVerificationPhase.verify(graph); + if (!SnippetTemplate.hasConstantParameter(method)) { + NodeIntrinsificationVerificationPhase.verify(graph); + } if (original == null) { new SnippetFrameStateCleanupPhase().apply(graph); diff -r ba441e21796f -r c78ef1df7b06 graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java --- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java Thu Apr 25 17:46:35 2013 +0200 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java Thu Apr 25 18:36:23 2013 +0200 @@ -378,7 +378,7 @@ new CanonicalizerPhase.Instance(runtime, replacements.getAssumptions(), 0, null).apply(snippetCopy); } - assert NodeIntrinsificationVerificationPhase.verify(snippetCopy); + NodeIntrinsificationVerificationPhase.verify(snippetCopy); // Gather the template parameters parameters = new Object[parameterCount];