Mercurial > hg > graal-jvmci-8
changeset 19762:223e1d7b15b7
Make conditional elimination more robust wrt deleted begin nodes.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Tue, 10 Mar 2015 19:19:33 +0100 |
parents | 37969636e6f8 |
children | d03352ba2efb 287f7c223d58 |
files | graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/DominatorConditionalEliminationPhase.java |
diffstat | 1 files changed, 17 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/DominatorConditionalEliminationPhase.java Tue Mar 10 15:52:16 2015 +0100 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/DominatorConditionalEliminationPhase.java Tue Mar 10 19:19:33 2015 +0100 @@ -108,7 +108,17 @@ } else { ControlFlowGraph cfg = ControlFlowGraph.compute(graph, true, false, true, true); cfg.computePostdominators(); - blockToNodes = b -> b.getNodes(); + BlockMap<List<FixedNode>> nodes = new BlockMap<>(cfg); + for (Block b : cfg.getBlocks()) { + ArrayList<FixedNode> curNodes = new ArrayList<>(); + for (FixedNode node : b.getNodes()) { + if (node instanceof AbstractBeginNode || node instanceof FixedGuardNode || node instanceof CheckCastNode || node instanceof ConditionAnchorNode || node instanceof IfNode) { + curNodes.add(node); + } + } + nodes.put(b, curNodes); + } + blockToNodes = b -> nodes.get(b); nodeToBlock = n -> cfg.blockFor(n); startBlock = cfg.getStartBlock(); } @@ -186,7 +196,7 @@ } else if (node instanceof ConditionAnchorNode) { processConditionAnchor((ConditionAnchorNode) node); } else if (node instanceof IfNode) { - processIf((IfNode) node); + processIf((IfNode) node, undoOperations); } else { return; } @@ -207,7 +217,7 @@ }); } - private void processIf(IfNode node) { + private void processIf(IfNode node, List<Runnable> undoOperations) { tryProofCondition(node.condition(), (guard, result) -> { AbstractBeginNode survivingSuccessor = node.getSuccessor(result); survivingSuccessor.replaceAtUsages(InputType.Guard, guard); @@ -215,7 +225,7 @@ node.replaceAtPredecessor(survivingSuccessor); GraphUtil.killCFG(node); if (survivingSuccessor instanceof BeginNode) { - ((BeginNode) survivingSuccessor).trySimplify(); + undoOperations.add(() -> ((BeginNode) survivingSuccessor).trySimplify()); } }); } @@ -386,8 +396,9 @@ } else { DeoptimizeNode deopt = node.graph().add(new DeoptimizeNode(node.action(), node.reason())); Block block = nodeToBlock.apply(node); - FixedNode next = block.getBeginNode().next(); - block.getBeginNode().setNext(deopt); + AbstractBeginNode beginNode = block.getBeginNode(); + FixedNode next = beginNode.next(); + beginNode.setNext(deopt); GraphUtil.killCFG(next); } })) {