Mercurial > hg > truffle
changeset 11588:12f1d5fe0133
CR-1364
author | Mick Jordan <mick.jordan@oracle.com> |
---|---|
date | Tue, 03 Sep 2013 16:46:25 -0700 |
parents | 93c63975217e |
children | 2afda67175e9 |
files | graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/NodeIntrinsificationPhase.java graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsImpl.java |
diffstat | 2 files changed, 24 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/NodeIntrinsificationPhase.java Thu Aug 29 19:09:09 2013 +0200 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/NodeIntrinsificationPhase.java Tue Sep 03 16:46:25 2013 -0700 @@ -67,7 +67,7 @@ } } - private boolean tryIntrinsify(MethodCallTargetNode methodCallTargetNode, List<Node> cleanUpReturnList) { + protected boolean tryIntrinsify(MethodCallTargetNode methodCallTargetNode, List<Node> cleanUpReturnList) { ResolvedJavaMethod target = methodCallTargetNode.targetMethod(); NodeIntrinsic intrinsic = target.getAnnotation(Node.NodeIntrinsic.class); ResolvedJavaType declaringClass = target.getDeclaringClass(); @@ -94,7 +94,7 @@ // Clean up checkcast instructions inserted by javac if the return type is generic. cleanUpReturnList.add(newInstance); - } else if (target.getAnnotation(Fold.class) != null) { + } else if (isFoldable(target)) { ResolvedJavaType[] parameterTypes = MetaUtil.resolveJavaTypes(MetaUtil.signatureToTypes(target), declaringClass); // Prepare the arguments for the reflective method call @@ -128,9 +128,16 @@ } /** + * Permits a subclass to override the default definition of "foldable". + */ + protected boolean isFoldable(ResolvedJavaMethod method) { + return method.getAnnotation(Fold.class) != null; + } + + /** * Converts the arguments of an invoke node to object values suitable for use as the arguments * to a reflective invocation of a Java constructor or method. - * + * * @param folding specifies if the invocation is for handling a {@link Fold} annotation * @return the arguments for the reflective invocation or null if an argument of {@code invoke} * that is expected to be constant isn't
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsImpl.java Thu Aug 29 19:09:09 2013 +0200 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsImpl.java Tue Sep 03 16:46:25 2013 -0700 @@ -159,7 +159,7 @@ /** * Registers a method substitution. - * + * * @param originalMember a method or constructor being substituted * @param substituteMethod the substitute method * @return the original method @@ -180,7 +180,7 @@ /** * Registers a macro substitution. - * + * * @param originalMethod a method or constructor being substituted * @param macro the substitute macro node class * @return the original method @@ -214,7 +214,7 @@ /** * Creates a preprocessed graph for a snippet or method substitution. - * + * * @param method the snippet or method substitution for which a graph will be created * @param original the original method if {@code method} is a {@linkplain MethodSubstitution * substitution} otherwise null @@ -337,13 +337,18 @@ return graph; } + protected Object beforeInline(@SuppressWarnings("unused") MethodCallTargetNode callTarget, @SuppressWarnings("unused") StructuredGraph callee) { + return null; + } + /** * Called after a graph is inlined. - * + * * @param caller the graph into which {@code callee} was inlined * @param callee the graph that was inlined into {@code caller} + * @param beforeInlineData value returned by {@link #beforeInline}. */ - protected void afterInline(StructuredGraph caller, StructuredGraph callee) { + protected void afterInline(StructuredGraph caller, StructuredGraph callee, Object beforeInlineData) { if (OptCanonicalizer.getValue()) { new WordTypeRewriterPhase(runtime, target.wordKind).apply(caller); new CanonicalizerPhase.Instance(runtime, assumptions, true).apply(caller); @@ -379,7 +384,7 @@ InliningUtil.inline(callTarget.invoke(), originalGraph, true); Debug.dump(graph, "after inlining %s", callee); - afterInline(graph, originalGraph); + afterInline(graph, originalGraph, null); substituteCallsOriginal = true; } else { StructuredGraph intrinsicGraph = InliningUtil.getIntrinsicGraph(ReplacementsImpl.this, callee); @@ -396,9 +401,10 @@ } targetGraph = parseGraph(callee, policy); } + Object beforeInlineData = beforeInline(callTarget, targetGraph); InliningUtil.inline(callTarget.invoke(), targetGraph, true); Debug.dump(graph, "after inlining %s", callee); - afterInline(graph, targetGraph); + afterInline(graph, targetGraph, beforeInlineData); } } } @@ -426,7 +432,7 @@ /** * Resolves a name to a class. - * + * * @param className the name of the class to resolve * @param optional if true, resolution failure returns null * @return the resolved class or null if resolution fails and {@code optional} is true