# HG changeset patch # User Mick Jordan # Date 1378847205 25200 # Node ID c47153857827c558bc3710201be819ad919aa0a9 # Parent 4dbd3e3adda6444c35de48c8bd9b29afe2cdcd0f# Parent a8132e3fd0d87bc45f16ef7a5ce572c156249b51 Merge - CR1368: add beforeInline callback to snippet instantiation diff -r a8132e3fd0d8 -r c47153857827 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 21:30:46 2013 +0200 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/NodeIntrinsificationPhase.java Tue Sep 10 14:06:45 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 a8132e3fd0d8 -r c47153857827 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 21:30:46 2013 +0200 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsImpl.java Tue Sep 10 14:06:45 2013 -0700 @@ -161,7 +161,7 @@ /** * Registers a method substitution. - * + * * @param originalMember a method or constructor being substituted * @param substituteMethod the substitute method * @return the original method @@ -182,7 +182,7 @@ /** * Registers a macro substitution. - * + * * @param originalMethod a method or constructor being substituted * @param macro the substitute macro node class * @return the original method @@ -216,7 +216,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 @@ -339,13 +339,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(true).apply(caller, new PhaseContext(runtime, assumptions, ReplacementsImpl.this)); @@ -381,7 +386,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); @@ -398,9 +403,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); } } } @@ -428,7 +434,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