< prev index next >

src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.loop/src/org/graalvm/compiler/loop/LoopEx.java

Print this page

        

*** 74,92 **** import org.graalvm.compiler.nodes.cfg.ControlFlowGraph; import org.graalvm.compiler.nodes.debug.ControlFlowAnchored; import org.graalvm.compiler.nodes.extended.ValueAnchorNode; import org.graalvm.compiler.nodes.util.GraphUtil; - import jdk.vm.ci.code.BytecodeFrame; - public class LoopEx { private final Loop<Block> loop; private LoopFragmentInside inside; private LoopFragmentWhole whole; private CountedLoopInfo counted; private LoopsData data; private EconomicMap<Node, InductionVariable> ivs; LoopEx(Loop<Block> loop, LoopsData data) { this.loop = loop; this.data = data; } --- 74,91 ---- import org.graalvm.compiler.nodes.cfg.ControlFlowGraph; import org.graalvm.compiler.nodes.debug.ControlFlowAnchored; import org.graalvm.compiler.nodes.extended.ValueAnchorNode; import org.graalvm.compiler.nodes.util.GraphUtil; public class LoopEx { private final Loop<Block> loop; private LoopFragmentInside inside; private LoopFragmentWhole whole; private CountedLoopInfo counted; private LoopsData data; private EconomicMap<Node, InductionVariable> ivs; + private boolean countedLoopChecked; LoopEx(Loop<Block> loop, LoopsData data) { this.loop = loop; this.data = data; }
*** 141,154 **** --- 140,155 ---- public FixedNode entryPoint() { return loopBegin().forwardEnd(); } public boolean isCounted() { + assert countedLoopChecked; return counted != null; } public CountedLoopInfo counted() { + assert countedLoopChecked; return counted; } public LoopEx parent() { if (loop.getParent() == null) {
*** 209,228 **** } return count != 0; } public boolean detectCounted() { LoopBeginNode loopBegin = loopBegin(); FixedNode next = loopBegin.next(); while (next instanceof FixedGuardNode || next instanceof ValueAnchorNode || next instanceof FullInfopointNode) { next = ((FixedWithNextNode) next).next(); } if (next instanceof IfNode) { IfNode ifNode = (IfNode) next; boolean negated = false; ! if (!loopBegin.isLoopExit(ifNode.falseSuccessor())) { ! if (!loopBegin.isLoopExit(ifNode.trueSuccessor())) { return false; } negated = true; } LogicNode ifTest = ifNode.condition(); --- 210,233 ---- } return count != 0; } public boolean detectCounted() { + if (countedLoopChecked) { + return isCounted(); + } + countedLoopChecked = true; LoopBeginNode loopBegin = loopBegin(); FixedNode next = loopBegin.next(); while (next instanceof FixedGuardNode || next instanceof ValueAnchorNode || next instanceof FullInfopointNode) { next = ((FixedWithNextNode) next).next(); } if (next instanceof IfNode) { IfNode ifNode = (IfNode) next; boolean negated = false; ! if (!isCfgLoopExit(ifNode.falseSuccessor())) { ! if (!isCfgLoopExit(ifNode.trueSuccessor())) { return false; } negated = true; } LogicNode ifTest = ifNode.condition();
*** 299,316 **** if (iv.direction() != Direction.Down) { return false; } break; default: ! throw GraalError.shouldNotReachHere(); } counted = new CountedLoopInfo(this, iv, ifNode, limit, oneOff, negated ? ifNode.falseSuccessor() : ifNode.trueSuccessor()); return true; } return false; } public LoopsData loopsData() { return data; } public void nodesInLoopBranch(NodeBitMap branchNodes, AbstractBeginNode branch) { --- 304,326 ---- if (iv.direction() != Direction.Down) { return false; } break; default: ! throw GraalError.shouldNotReachHere(condition.toString()); } counted = new CountedLoopInfo(this, iv, ifNode, limit, oneOff, negated ? ifNode.falseSuccessor() : ifNode.trueSuccessor()); return true; } return false; } + private boolean isCfgLoopExit(AbstractBeginNode begin) { + Block block = data.getCFG().blockFor(begin); + return loop.getDepth() > block.getLoopDepth() || loop.isNaturalExit(block); + } + public LoopsData loopsData() { return data; } public void nodesInLoopBranch(NodeBitMap branchNodes, AbstractBeginNode branch) {
*** 319,329 **** Queue<Block> work = new LinkedList<>(); ControlFlowGraph cfg = loopsData().getCFG(); work.add(cfg.blockFor(branch)); while (!work.isEmpty()) { Block b = work.remove(); ! if (loop().getExits().contains(b)) { assert !exits.contains(b.getBeginNode()); exits.add(b.getBeginNode()); } else if (blocks.add(b.getBeginNode())) { Block d = b.getDominatedSibling(); while (d != null) { --- 329,339 ---- Queue<Block> work = new LinkedList<>(); ControlFlowGraph cfg = loopsData().getCFG(); work.add(cfg.blockFor(branch)); while (!work.isEmpty()) { Block b = work.remove(); ! if (loop().isLoopExit(b)) { assert !exits.contains(b.getBeginNode()); exits.add(b.getBeginNode()); } else if (blocks.add(b.getBeginNode())) { Block d = b.getDominatedSibling(); while (d != null) {
*** 463,473 **** if (node instanceof ControlFlowAnchored) { return false; } if (node instanceof FrameState) { FrameState frameState = (FrameState) node; ! if (frameState.bci == BytecodeFrame.AFTER_EXCEPTION_BCI || frameState.bci == BytecodeFrame.UNWIND_BCI) { return false; } } } return true; --- 473,483 ---- if (node instanceof ControlFlowAnchored) { return false; } if (node instanceof FrameState) { FrameState frameState = (FrameState) node; ! if (frameState.isExceptionHandlingBCI()) { return false; } } } return true;
< prev index next >