# HG changeset patch # User Doug Simon # Date 1379493094 -7200 # Node ID 528ab536b403a9270bf7f6b10b3973de3d90d0a0 # Parent 03fe11f5f18694f13be20e67f1912f4f3da1ff37 changed iteration over InvokeNodes in a graph to avoid Graph.getNodes() (GRAAL-471) diff -r 03fe11f5f186 -r 528ab536b403 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/ForeignCallStub.java --- 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 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. */ diff -r 03fe11f5f186 -r 528ab536b403 graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/MacroNode.java --- 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; }