# HG changeset patch # User Gilles Duboscq # Date 1379430099 -7200 # Node ID bffe5758c20904a74fd6940df58c8875b2bd43aa # Parent 100e196f87285776b3ad1d97ec4543403b4ca475 Snippets processing in ArrayCopyNode and ObjectCloneNode need proper scoping diff -r 100e196f8728 -r bffe5758c209 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ArrayCopyNode.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ArrayCopyNode.java Tue Sep 17 16:43:26 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ArrayCopyNode.java Tue Sep 17 17:01:39 2013 +0200 @@ -24,6 +24,8 @@ import static com.oracle.graal.compiler.GraalCompiler.*; +import java.util.concurrent.*; + import com.oracle.graal.api.meta.*; import com.oracle.graal.debug.*; import com.oracle.graal.loop.phases.*; @@ -62,7 +64,7 @@ return arguments.get(4); } - private StructuredGraph selectSnippet(LoweringTool tool, Replacements replacements) { + private StructuredGraph selectSnippet(LoweringTool tool, final Replacements replacements) { ResolvedJavaType srcType = ObjectStamp.typeOrNull(getSource().stamp()); ResolvedJavaType destType = ObjectStamp.typeOrNull(getDestination().stamp()); @@ -73,8 +75,15 @@ return null; } Kind componentKind = srcType.getComponentType().getKind(); - ResolvedJavaMethod snippetMethod = tool.getRuntime().lookupJavaMethod(ArrayCopySnippets.getSnippetForKind(componentKind)); - return replacements.getSnippet(snippetMethod); + final ResolvedJavaMethod snippetMethod = tool.getRuntime().lookupJavaMethod(ArrayCopySnippets.getSnippetForKind(componentKind)); + return Debug.scope("ArrayCopySnippet", snippetMethod, new Callable() { + + @Override + public StructuredGraph call() throws Exception { + return replacements.getSnippet(snippetMethod); + } + }); + } private static void unrollFixedLengthLoop(StructuredGraph snippetGraph, int length, LoweringTool tool) { @@ -91,23 +100,37 @@ } @Override - protected StructuredGraph getSnippetGraph(LoweringTool tool) { + protected StructuredGraph getSnippetGraph(final LoweringTool tool) { if (!shouldIntrinsify(getTargetMethod())) { return null; } - Replacements replacements = tool.getReplacements(); + final Replacements replacements = tool.getReplacements(); StructuredGraph snippetGraph = selectSnippet(tool, replacements); if (snippetGraph == null) { - ResolvedJavaMethod snippetMethod = tool.getRuntime().lookupJavaMethod(ArrayCopySnippets.genericArraycopySnippet); - snippetGraph = replacements.getSnippet(snippetMethod).copy(); + final ResolvedJavaMethod snippetMethod = tool.getRuntime().lookupJavaMethod(ArrayCopySnippets.genericArraycopySnippet); + snippetGraph = Debug.scope("ArrayCopySnippet", snippetMethod, new Callable() { + + @Override + public StructuredGraph call() throws Exception { + return replacements.getSnippet(snippetMethod).copy(); + } + }); replaceSnippetInvokes(snippetGraph); } else { assert snippetGraph != null : "ArrayCopySnippets should be installed"; if (getLength().isConstant() && getLength().asConstant().asInt() <= GraalOptions.MaximumEscapeAnalysisArrayLength.getValue()) { - snippetGraph = snippetGraph.copy(); - unrollFixedLengthLoop(snippetGraph, getLength().asConstant().asInt(), tool); + final StructuredGraph copy = snippetGraph.copy(); + snippetGraph = copy; + Debug.scope("ArrayCopySnippetSpecialization", snippetGraph.method(), new Runnable() { + + @Override + public void run() { + unrollFixedLengthLoop(copy, getLength().asConstant().asInt(), tool); + } + }); + } } return snippetGraph; diff -r 100e196f8728 -r bffe5758c209 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ObjectCloneNode.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ObjectCloneNode.java Tue Sep 17 16:43:26 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ObjectCloneNode.java Tue Sep 17 17:01:39 2013 +0200 @@ -25,9 +25,11 @@ import static com.oracle.graal.compiler.GraalCompiler.*; import java.lang.reflect.*; +import java.util.concurrent.*; import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; +import com.oracle.graal.debug.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.java.*; import com.oracle.graal.nodes.spi.*; @@ -69,9 +71,15 @@ } else { method = ObjectCloneSnippets.instanceCloneMethod; } - ResolvedJavaMethod snippetMethod = tool.getRuntime().lookupJavaMethod(method); - Replacements replacements = tool.getReplacements(); - StructuredGraph snippetGraph = replacements.getSnippet(snippetMethod); + final ResolvedJavaMethod snippetMethod = tool.getRuntime().lookupJavaMethod(method); + final Replacements replacements = tool.getReplacements(); + StructuredGraph snippetGraph = Debug.scope("ArrayCopySnippet", snippetMethod, new Callable() { + + @Override + public StructuredGraph call() throws Exception { + return replacements.getSnippet(snippetMethod); + } + }); assert snippetGraph != null : "ObjectCloneSnippets should be installed"; return snippetGraph;