Mercurial > hg > truffle
changeset 9302:c78ef1df7b06
made verification of node intrinsification always be run, independent of whether assertions are enabled
improved error message when verification of node intrinsification fails
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Thu, 25 Apr 2013 18:36:23 +0200 |
parents | ba441e21796f |
children | e26191d535a7 |
files | graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/NodeIntrinsificationVerificationPhase.java graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsImpl.java graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java |
diffstat | 3 files changed, 17 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- 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"); + } }
--- 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);
--- 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];