# HG changeset patch # User Lukas Stadler # Date 1399024947 -7200 # Node ID 4e3c2247daf4dd5cfe0214ebc61e4e642f4888ae # Parent 4b75c567aa62de98b698bff865c4ee4e8f1c5d57 simplify ReentrantNodeIterator diff -r 4b75c567aa62 -r 4e3c2247daf4 graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/WriteBarrierVerificationTest.java --- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/WriteBarrierVerificationTest.java Fri May 02 11:33:47 2014 +0200 +++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/WriteBarrierVerificationTest.java Fri May 02 12:02:27 2014 +0200 @@ -693,7 +693,7 @@ DebugConfig debugConfig = DebugScope.getConfig(); DebugConfig fixedConfig = Debug.fixedConfig(false, false, false, false, debugConfig.dumpHandlers(), debugConfig.output()); try (DebugConfigScope s = Debug.setConfig(fixedConfig)) { - ReentrantNodeIterator.apply(closure, graph.start(), false, null); + ReentrantNodeIterator.apply(closure, graph.start(), false); new WriteBarrierVerificationPhase().apply(graph); } catch (AssertionError error) { /* diff -r 4b75c567aa62 -r 4e3c2247daf4 graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/FloatingReadPhase.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/FloatingReadPhase.java Fri May 02 11:33:47 2014 +0200 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/FloatingReadPhase.java Fri May 02 12:02:27 2014 +0200 @@ -113,8 +113,8 @@ @Override protected void run(StructuredGraph graph) { Map> modifiedInLoops = new IdentityHashMap<>(); - ReentrantNodeIterator.apply(new CollectMemoryCheckpointsClosure(modifiedInLoops), graph.start(), new HashSet(), null); - ReentrantNodeIterator.apply(new FloatingReadClosure(modifiedInLoops, execmode), graph.start(), new MemoryMapImpl(graph.start()), null); + ReentrantNodeIterator.apply(new CollectMemoryCheckpointsClosure(modifiedInLoops), graph.start(), new HashSet()); + ReentrantNodeIterator.apply(new FloatingReadClosure(modifiedInLoops, execmode), graph.start(), new MemoryMapImpl(graph.start())); if (execmode == ExecutionMode.CREATE_FLOATING_READS) { assert !graph.isAfterFloatingReadPhase(); graph.setAfterFloatingReadPhase(true); diff -r 4b75c567aa62 -r 4e3c2247daf4 graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/FrameStateAssignmentPhase.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/FrameStateAssignmentPhase.java Fri May 02 11:33:47 2014 +0200 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/FrameStateAssignmentPhase.java Fri May 02 12:02:27 2014 +0200 @@ -107,7 +107,7 @@ protected void run(StructuredGraph graph) { assert graph.getGuardsStage().ordinal() >= GuardsStage.FIXED_DEOPTS.ordinal() && checkFixedDeopts(graph); if (graph.getGuardsStage().ordinal() < GuardsStage.AFTER_FSA.ordinal()) { - ReentrantNodeIterator.apply(new FrameStateAssignmentClosure(), graph.start(), null, null); + ReentrantNodeIterator.apply(new FrameStateAssignmentClosure(), graph.start(), null); graph.setGuardsStage(GuardsStage.AFTER_FSA); } } diff -r 4b75c567aa62 -r 4e3c2247daf4 graal/com.oracle.graal.phases/src/com/oracle/graal/phases/graph/ReentrantNodeIterator.java --- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/graph/ReentrantNodeIterator.java Fri May 02 11:33:47 2014 +0200 +++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/graph/ReentrantNodeIterator.java Fri May 02 12:02:27 2014 +0200 @@ -47,7 +47,7 @@ /** * Determine whether iteration should continue in the current state. - * + * * @param currentState */ protected boolean continueIteration(StateT currentState) { @@ -60,11 +60,7 @@ } public static LoopInfo processLoop(NodeIteratorClosure closure, LoopBeginNode loop, StateT initialState) { - HashSet boundary = new HashSet<>(); - for (LoopExitNode exit : loop.loopExits()) { - boundary.add(exit); - } - Map blockEndStates = apply(closure, loop, initialState, boundary); + Map blockEndStates = apply(closure, loop, initialState, loop); LoopInfo info = new LoopInfo<>(); for (LoopEndNode end : loop.loopEnds()) { @@ -80,7 +76,11 @@ return info; } - public static Map apply(NodeIteratorClosure closure, FixedNode start, StateT initialState, Set boundary) { + public static Map apply(NodeIteratorClosure closure, FixedNode start, StateT initialState) { + return apply(closure, start, initialState, null); + } + + private static Map apply(NodeIteratorClosure closure, FixedNode start, StateT initialState, LoopBeginNode boundary) { Deque nodeQueue = new ArrayDeque<>(); IdentityHashMap blockEndStates = new IdentityHashMap<>(); @@ -88,7 +88,7 @@ FixedNode current = start; do { while (current instanceof FixedWithNextNode) { - if (boundary != null && boundary.contains(current)) { + if (boundary != null && current instanceof LoopExitNode && ((LoopExitNode) current).loopBegin() == boundary) { blockEndStates.put(current, state); current = null; } else { diff -r 4b75c567aa62 -r 4e3c2247daf4 graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/CollapseFrameForSingleSideEffectPhase.java --- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/CollapseFrameForSingleSideEffectPhase.java Fri May 02 11:33:47 2014 +0200 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/CollapseFrameForSingleSideEffectPhase.java Fri May 02 12:02:27 2014 +0200 @@ -36,11 +36,11 @@ /** * This phase ensures that there's a single {@linkplain BytecodeFrame#AFTER_BCI collapsed frame * state} per path. - * + * * Removes other frame states from {@linkplain StateSplit#hasSideEffect() non-side-effecting} nodes * in the graph, and replaces them with {@linkplain BytecodeFrame#INVALID_FRAMESTATE_BCI invalid * frame states}. - * + * * The invalid frame states ensure that no deoptimization to a snippet frame state will happen. */ public class CollapseFrameForSingleSideEffectPhase extends Phase { @@ -112,7 +112,7 @@ @Override protected void run(StructuredGraph graph) { CollapseFrameForSingleSideEffectClosure closure = new CollapseFrameForSingleSideEffectClosure(); - ReentrantNodeIterator.apply(closure, graph.start(), new IterationState(), null); + ReentrantNodeIterator.apply(closure, graph.start(), new IterationState()); closure.finishProcessing(graph); }