changeset 11700:528ab536b403

changed iteration over InvokeNodes in a graph to avoid Graph.getNodes() (GRAAL-471)
author Doug Simon <doug.simon@oracle.com>
date Wed, 18 Sep 2013 10:31:34 +0200
parents 03fe11f5f186
children e29743466d00
files graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/ForeignCallStub.java graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/MacroNode.java
diffstat 2 files changed, 10 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/ForeignCallStub.java	Tue Sep 17 23:35:42 2013 -0400
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/ForeignCallStub.java	Wed Sep 18 10:31:34 2013 +0200
@@ -29,6 +29,7 @@
 import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*;
 
 import java.lang.reflect.*;
+import java.util.*;
 
 import com.oracle.graal.api.code.*;
 import com.oracle.graal.api.meta.*;
@@ -223,13 +224,16 @@
         boolean isObjectResult = linkage.getOutgoingCallingConvention().getReturn().getKind() == Kind.Object;
         GraphBuilder builder = new GraphBuilder(this);
         LocalNode[] locals = createLocals(builder, args);
+        List<InvokeNode> invokes = new ArrayList<>(3);
 
         ReadRegisterNode thread = prependThread || isObjectResult ? builder.append(new ReadRegisterNode(runtime.threadRegister(), true, false)) : null;
         ValueNode result = createTargetCall(builder, locals, thread);
-        createInvoke(builder, StubUtil.class, "handlePendingException", ConstantNode.forBoolean(isObjectResult, builder.graph));
+        invokes.add(createInvoke(builder, StubUtil.class, "handlePendingException", ConstantNode.forBoolean(isObjectResult, builder.graph)));
         if (isObjectResult) {
             InvokeNode object = createInvoke(builder, HotSpotReplacementsUtil.class, "getAndClearObjectResult", thread);
             result = createInvoke(builder, StubUtil.class, "verifyObject", object);
+            invokes.add(object);
+            invokes.add((InvokeNode) result);
         }
         builder.append(new ReturnNode(linkage.getDescriptor().getResultType() == void.class ? null : result));
 
@@ -240,7 +244,7 @@
         /* Rewrite all word types that can come in from the method argument types. */
         new WordTypeRewriterPhase(runtime, wordKind()).apply(builder.graph);
         /* Inline all method calls that are create above. */
-        for (InvokeNode invoke : builder.graph.getNodes().filter(InvokeNode.class).snapshot()) {
+        for (InvokeNode invoke : invokes) {
             inline(invoke);
         }
         /* Clean up all code that is now dead after inlining. */
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/MacroNode.java	Tue Sep 17 23:35:42 2013 -0400
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/MacroNode.java	Wed Sep 18 10:31:34 2013 +0200
@@ -110,14 +110,15 @@
     }
 
     protected void replaceSnippetInvokes(StructuredGraph snippetGraph) {
-        for (InvokeNode invoke : snippetGraph.getNodes().filter(InvokeNode.class)) {
-            if (((MethodCallTargetNode) invoke.callTarget()).targetMethod() != getTargetMethod()) {
+        for (MethodCallTargetNode call : snippetGraph.getNodes(MethodCallTargetNode.class)) {
+            Invoke invoke = call.invoke();
+            if (call.targetMethod() != getTargetMethod()) {
                 throw new GraalInternalError("unexpected invoke %s in snippet", getClass().getSimpleName());
             }
             if (invoke.stateAfter().bci == FrameState.INVALID_FRAMESTATE_BCI) {
                 InvokeNode newInvoke = snippetGraph.add(new InvokeNode(invoke.callTarget(), getBci()));
                 newInvoke.setStateAfter(snippetGraph.add(new FrameState(FrameState.AFTER_BCI)));
-                snippetGraph.replaceFixedWithFixed(invoke, newInvoke);
+                snippetGraph.replaceFixedWithFixed((InvokeNode) invoke.asNode(), newInvoke);
             } else {
                 assert invoke.stateAfter().bci == FrameState.AFTER_BCI : invoke;
             }