# HG changeset patch # User Mick Jordan # Date 1378830609 25200 # Node ID 4dbd3e3adda6444c35de48c8bd9b29afe2cdcd0f # Parent e460aa80fa46c76304860e881f5f1347dbc1386b# Parent 4cf51b63004951449305c7158db01c3c2379c970 Merge diff -r 4cf51b630049 -r 4dbd3e3adda6 graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/NodeIntrinsificationPhase.java --- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/NodeIntrinsificationPhase.java Tue Sep 10 16:44:58 2013 +0200 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/NodeIntrinsificationPhase.java Tue Sep 10 09:30:09 2013 -0700 @@ -67,7 +67,7 @@ } } - private boolean tryIntrinsify(MethodCallTargetNode methodCallTargetNode, List cleanUpReturnList) { + protected boolean tryIntrinsify(MethodCallTargetNode methodCallTargetNode, List 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 diff -r 4cf51b630049 -r 4dbd3e3adda6 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 Tue Sep 10 16:44:58 2013 +0200 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsImpl.java Tue Sep 10 09:30:09 2013 -0700 @@ -160,7 +160,7 @@ /** * Registers a method substitution. - * + * * @param originalMember a method or constructor being substituted * @param substituteMethod the substitute method * @return the original method @@ -181,7 +181,7 @@ /** * Registers a macro substitution. - * + * * @param originalMethod a method or constructor being substituted * @param macro the substitute macro node class * @return the original method @@ -215,7 +215,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 @@ -338,13 +338,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); @@ -380,7 +385,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); @@ -397,9 +402,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); } } } @@ -427,7 +433,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