# HG changeset patch # User Doug Simon # Date 1337025915 -7200 # Node ID a3d6ea4241e5bc3be11d00148d8fce1c947642c5 # Parent c3de4d2988c7aeacf846401e7f2f98de79b31df3 made lowering repeat processing of fixed nodes until no new fixed nodes are added before lowering floating nodes diff -r c3de4d2988c7 -r a3d6ea4241e5 graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/LoweringPhase.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/LoweringPhase.java Mon May 14 21:52:32 2012 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/LoweringPhase.java Mon May 14 22:05:15 2012 +0200 @@ -44,9 +44,56 @@ this.runtime = runtime; this.assumptions = assumptions; } - @Override protected void run(final StructuredGraph graph) { + // Step 1: repeatedly lower fixed nodes until no new ones are created + NodeBitMap processed = graph.createNodeBitMap(); + while (true) { + int mark = graph.getMark(); + ControlFlowGraph cfg = ControlFlowGraph.compute(graph, true, false, true, true); + processBlock(cfg.getStartBlock(), graph.createNodeBitMap(), processed, null); + + if (graph.getNewNodes(mark).filter(FixedNode.class).isEmpty()) { + break; + } + graph.verify(); + processed.grow(); + } + + // Step 2: lower the floating nodes + processed.negate(); + final CiLoweringTool loweringTool = new CiLoweringTool() { + + @Override + public Node getGuardAnchor() { + throw new UnsupportedOperationException(); + } + + @Override + public GraalRuntime getRuntime() { + return runtime; + } + + @Override + public Node createGuard(Node condition, RiDeoptReason deoptReason, RiDeoptAction action, long leafGraphId) { + // TODO (thomaswue): Document why this must not be called on floating nodes. + throw new UnsupportedOperationException(); + } + + @Override + public CiAssumptions assumptions() { + return assumptions; + } + }; + for (Node node : processed) { + if (node instanceof Lowerable) { + assert !(node instanceof FixedNode) || node.predecessor() == null : node; + ((Lowerable) node).lower(loweringTool); + } + } + } + + protected void run0(final StructuredGraph graph) { ControlFlowGraph cfg = ControlFlowGraph.compute(graph, true, false, true, true); NodeBitMap processed = graph.createNodeBitMap(); @@ -138,7 +185,7 @@ FixedNode guardAnchor = (FixedNode) getGuardAnchor(); if (GraalOptions.OptEliminateGuards) { for (Node usage : condition.usages()) { - if (activeGuards.isMarked(usage)) { + if (!activeGuards.isNew(usage) && activeGuards.isMarked(usage)) { return usage; } } @@ -157,9 +204,11 @@ // Lower the instructions of this block. for (Node node : b.getNodes()) { - processed.mark(node); - if (node instanceof Lowerable) { - ((Lowerable) node).lower(loweringTool); + if (!processed.isMarked(node)) { + processed.mark(node); + if (node instanceof Lowerable) { + ((Lowerable) node).lower(loweringTool); + } } } }