private static Set<ControlFlowNode> findDominatedNodes(final Set<ControlFlowNode> scope, final ControlFlowNode head) { final Set<ControlFlowNode> agenda = new LinkedHashSet<>(); final Set<ControlFlowNode> result = new LinkedHashSet<>(); agenda.add(head); while (!agenda.isEmpty()) { final ControlFlowNode addNode = agenda.iterator().next(); agenda.remove(addNode); if (scope.contains(addNode) && head.dominates(addNode) && result.add(addNode)) { for (final ControlFlowNode successor : addNode.getSuccessors()) { agenda.add(successor); } } } return result; } }
private static Set<ControlFlowNode> findDominatedNodes(final Set<ControlFlowNode> scope, final ControlFlowNode head) { final Set<ControlFlowNode> agenda = new LinkedHashSet<>(); final Set<ControlFlowNode> result = new LinkedHashSet<>(); agenda.add(head); while (!agenda.isEmpty()) { final ControlFlowNode addNode = agenda.iterator().next(); agenda.remove(addNode); if (scope.contains(addNode) && head.dominates(addNode) && result.add(addNode)) { for (final ControlFlowNode successor : addNode.getSuccessors()) { agenda.add(successor); } } } return result; } }
private static Set<ControlFlowNode> findDominatedNodes(final Set<ControlFlowNode> scope, final ControlFlowNode head) { final Set<ControlFlowNode> agenda = new LinkedHashSet<>(); final Set<ControlFlowNode> result = new LinkedHashSet<>(); agenda.add(head); while (!agenda.isEmpty()) { final ControlFlowNode addNode = agenda.iterator().next(); agenda.remove(addNode); if (scope.contains(addNode) && head.dominates(addNode) && result.add(addNode)) { for (final ControlFlowNode successor : addNode.getSuccessors()) { agenda.add(successor); } } } return result; } }
private static Set<ControlFlowNode> findDominatedNodes(final ControlFlowGraph cfg, final ControlFlowNode head) { final Set<ControlFlowNode> agenda = new LinkedHashSet<>(); final Set<ControlFlowNode> result = new LinkedHashSet<>(); agenda.add(head); while (!agenda.isEmpty()) { final ControlFlowNode addNode = agenda.iterator().next(); agenda.remove(addNode); if (!head.dominates(addNode) && !shouldIncludeExceptionalExit(cfg, head, addNode)) { continue; } if (!result.add(addNode)) { continue; } for (final ControlFlowNode successor : addNode.getSuccessors()) { agenda.add(successor); } } return result; }
private static Set<ControlFlowNode> findDominatedNodes(final ControlFlowGraph cfg, final ControlFlowNode head) { final Set<ControlFlowNode> agenda = new LinkedHashSet<>(); final Set<ControlFlowNode> result = new LinkedHashSet<>(); agenda.add(head); while (!agenda.isEmpty()) { final ControlFlowNode addNode = agenda.iterator().next(); agenda.remove(addNode); if (!head.dominates(addNode) && !shouldIncludeExceptionalExit(cfg, head, addNode)) { continue; } if (!result.add(addNode)) { continue; } for (final ControlFlowNode successor : addNode.getSuccessors()) { agenda.add(successor); } } return result; }
private static Set<ControlFlowNode> findDominatedNodes(final ControlFlowGraph cfg, final ControlFlowNode head) { final Set<ControlFlowNode> agenda = new LinkedHashSet<>(); final Set<ControlFlowNode> result = new LinkedHashSet<>(); agenda.add(head); while (!agenda.isEmpty()) { final ControlFlowNode addNode = agenda.iterator().next(); agenda.remove(addNode); if (!head.dominates(addNode) && !shouldIncludeExceptionalExit(cfg, head, addNode)) { continue; } if (!result.add(addNode)) { continue; } for (final ControlFlowNode successor : addNode.getSuccessors()) { agenda.add(successor); } } return result; }
private static boolean hasSingleEdgeEnteringBlock(final ControlFlowNode node) { int count = 0; for (final ControlFlowEdge edge : node.getIncoming()) { if (!node.dominates(edge.getSource())) { if (++count > 1) { return false; } } } return count == 1; }
private static boolean hasSingleEdgeEnteringBlock(final ControlFlowNode node) { int count = 0; for (final ControlFlowEdge edge : node.getIncoming()) { if (!node.dominates(edge.getSource())) { if (++count > 1) { return false; } } } return count == 1; }
private static boolean hasSingleEdgeEnteringBlock(final ControlFlowNode node) { int count = 0; for (final ControlFlowEdge edge : node.getIncoming()) { if (!node.dominates(edge.getSource())) { if (++count > 1) { return false; } } } return count == 1; }
if (!head.dominates(addNode) && !shouldIncludeExceptionalExit(cfg, head, addNode)) {
if (!head.dominates(addNode) && !shouldIncludeExceptionalExit(cfg, head, addNode)) {
private static boolean shouldIncludeExceptionalExit(final ControlFlowGraph cfg, final ControlFlowNode head, final ControlFlowNode node) { if (node.getNodeType() != ControlFlowNodeType.Normal) { return false; } if (!node.getDominanceFrontier().contains(cfg.getExceptionalExit()) && !node.dominates(cfg.getExceptionalExit())) { final ControlFlowNode innermostHandlerNode = findInnermostExceptionHandlerNode(cfg, node.getStart().getOffset()); if (innermostHandlerNode == null || !node.getDominanceFrontier().contains(innermostHandlerNode)) { return false; } } if (node.getStart().getNext() != node.getEnd()) { return false; } if (head.getStart().getOpCode().isStore() && node.getStart().getOpCode().isLoad() && node.getEnd().getOpCode() == OpCode.ATHROW) { return InstructionHelper.getLoadOrStoreSlot(head.getStart()) == InstructionHelper.getLoadOrStoreSlot(node.getStart()); } return false; }
private static boolean shouldIncludeExceptionalExit(final ControlFlowGraph cfg, final ControlFlowNode head, final ControlFlowNode node) { if (node.getNodeType() != ControlFlowNodeType.Normal) { return false; } if (!node.getDominanceFrontier().contains(cfg.getExceptionalExit()) && !node.dominates(cfg.getExceptionalExit())) { final ControlFlowNode innermostHandlerNode = findInnermostExceptionHandlerNode(cfg, node.getStart().getOffset()); if (innermostHandlerNode == null || !node.getDominanceFrontier().contains(innermostHandlerNode)) { return false; } } if (node.getStart().getNext() != node.getEnd()) { return false; } if (head.getStart().getOpCode().isStore() && node.getStart().getOpCode().isLoad() && node.getEnd().getOpCode() == OpCode.ATHROW) { return InstructionHelper.getLoadOrStoreSlot(head.getStart()) == InstructionHelper.getLoadOrStoreSlot(node.getStart()); } return false; }
private static boolean shouldIncludeExceptionalExit(final ControlFlowGraph cfg, final ControlFlowNode head, final ControlFlowNode node) { if (node.getNodeType() != ControlFlowNodeType.Normal) { return false; } if (!node.getDominanceFrontier().contains(cfg.getExceptionalExit()) && !node.dominates(cfg.getExceptionalExit())) { final ControlFlowNode innermostHandlerNode = findInnermostExceptionHandlerNode(cfg, node.getStart().getOffset()); if (innermostHandlerNode == null || !node.getDominanceFrontier().contains(innermostHandlerNode)) { return false; } } if (node.getStart().getNext() != node.getEnd()) { return false; } if (head.getStart().getOpCode().isStore() && node.getStart().getOpCode().isLoad() && node.getEnd().getOpCode() == OpCode.ATHROW) { return InstructionHelper.getLoadOrStoreSlot(head.getStart()) == InstructionHelper.getLoadOrStoreSlot(node.getStart()); } return false; }
private static boolean shouldIncludeExceptionalExit( final ControlFlowGraph cfg, final ControlFlowNode head, final ControlFlowNode node) { if (node.getNodeType() != ControlFlowNodeType.Normal) { return false; } if (!node.getDominanceFrontier().contains(cfg.getExceptionalExit()) && !node.dominates(cfg.getExceptionalExit())) { final ControlFlowNode innermostHandlerNode = findInnermostExceptionHandlerNode(cfg, node.getEnd().getOffset(), false); if (innermostHandlerNode == null || !node.getDominanceFrontier().contains(innermostHandlerNode)) { return false; } } return head.getNodeType() == ControlFlowNodeType.Normal && node.getNodeType() == ControlFlowNodeType.Normal && node.getStart().getNext() == node.getEnd() && head.getStart().getOpCode().isStore() && node.getStart().getOpCode().isLoad() && node.getEnd().getOpCode() == OpCode.ATHROW && InstructionHelper.getLoadOrStoreSlot(head.getStart()) == InstructionHelper.getLoadOrStoreSlot(node.getStart()); }
private static boolean shouldIncludeExceptionalExit( final ControlFlowGraph cfg, final ControlFlowNode head, final ControlFlowNode node) { if (node.getNodeType() != ControlFlowNodeType.Normal) { return false; } if (!node.getDominanceFrontier().contains(cfg.getExceptionalExit()) && !node.dominates(cfg.getExceptionalExit())) { final ControlFlowNode innermostHandlerNode = findInnermostExceptionHandlerNode(cfg, node.getEnd().getOffset(), false); if (innermostHandlerNode == null || !node.getDominanceFrontier().contains(innermostHandlerNode)) { return false; } } return head.getNodeType() == ControlFlowNodeType.Normal && node.getNodeType() == ControlFlowNodeType.Normal && node.getStart().getNext() == node.getEnd() && head.getStart().getOpCode().isStore() && node.getStart().getOpCode().isLoad() && node.getEnd().getOpCode() == OpCode.ATHROW && InstructionHelper.getLoadOrStoreSlot(head.getStart()) == InstructionHelper.getLoadOrStoreSlot(node.getStart()); }
private static boolean shouldIncludeExceptionalExit( final ControlFlowGraph cfg, final ControlFlowNode head, final ControlFlowNode node) { if (node.getNodeType() != ControlFlowNodeType.Normal) { return false; } if (!node.getDominanceFrontier().contains(cfg.getExceptionalExit()) && !node.dominates(cfg.getExceptionalExit())) { final ControlFlowNode innermostHandlerNode = findInnermostExceptionHandlerNode(cfg, node.getEnd().getOffset(), false); if (innermostHandlerNode == null || !node.getDominanceFrontier().contains(innermostHandlerNode)) { return false; } } return head.getNodeType() == ControlFlowNodeType.Normal && node.getNodeType() == ControlFlowNodeType.Normal && node.getStart().getNext() == node.getEnd() && head.getStart().getOpCode().isStore() && node.getStart().getOpCode().isLoad() && node.getEnd().getOpCode() == OpCode.ATHROW && InstructionHelper.getLoadOrStoreSlot(head.getStart()) == InstructionHelper.getLoadOrStoreSlot(node.getStart()); }