Example #1
0
 public static void removeFixedWithUnusedInputs(FixedWithNextNode fixed) {
   if (fixed instanceof StateSplit) {
     FrameState stateAfter = ((StateSplit) fixed).stateAfter();
     ((StateSplit) fixed).setStateAfter(null);
     if (stateAfter.usages().isEmpty()) {
       killWithUnusedFloatingInputs(stateAfter);
     }
   }
   unlinkFixedNode(fixed);
   killWithUnusedFloatingInputs(fixed);
 }
Example #2
0
 public void reduceTrivialMerge(AbstractMergeNode merge) {
   assert merge.forwardEndCount() == 1;
   assert !(merge instanceof LoopBeginNode) || ((LoopBeginNode) merge).loopEnds().isEmpty();
   for (PhiNode phi : merge.phis().snapshot()) {
     assert phi.valueCount() == 1;
     ValueNode singleValue = phi.valueAt(0);
     phi.replaceAtUsagesAndDelete(singleValue);
   }
   // remove loop exits
   if (merge instanceof LoopBeginNode) {
     ((LoopBeginNode) merge).removeExits();
   }
   AbstractEndNode singleEnd = merge.forwardEndAt(0);
   FixedNode sux = merge.next();
   FrameState stateAfter = merge.stateAfter();
   // evacuateGuards
   merge.prepareDelete((FixedNode) singleEnd.predecessor());
   merge.safeDelete();
   if (stateAfter != null && stateAfter.isAlive() && stateAfter.hasNoUsages()) {
     GraphUtil.killWithUnusedFloatingInputs(stateAfter);
   }
   if (sux == null) {
     singleEnd.replaceAtPredecessor(null);
     singleEnd.safeDelete();
   } else {
     singleEnd.replaceAndDelete(sux);
   }
 }
Example #3
0
 public static boolean tryKillUnused(Node node) {
   if (node.isAlive() && isFloatingNode().apply(node) && node.usages().isEmpty()) {
     killWithUnusedFloatingInputs(node);
     return true;
   }
   return false;
 }
Example #4
0
  public static void killWithUnusedFloatingInputs(Node node) {
    List<Node> floatingInputs = node.inputs().filter(isFloatingNode()).snapshot();
    node.safeDelete();

    for (Node in : floatingInputs) {
      if (in.isAlive() && in.usages().isEmpty()) {
        killWithUnusedFloatingInputs(in);
      }
    }
  }
Example #5
0
 public final void clearAllStateAfter() {
   for (Node node : getNodes()) {
     if (node instanceof StateSplit) {
       FrameState stateAfter = ((StateSplit) node).stateAfter();
       if (stateAfter != null) {
         ((StateSplit) node).setStateAfter(null);
         GraphUtil.killWithUnusedFloatingInputs(stateAfter);
       }
     }
   }
 }
Example #6
0
  public static void propagateKill(Node node) {
    if (node != null && node.isAlive()) {
      List<Node> usagesSnapshot = node.usages().filter(isFloatingNode()).snapshot();

      // null out remaining usages
      node.replaceAtUsages(null);
      node.replaceAtPredecessor(null);
      killWithUnusedFloatingInputs(node);

      for (Node usage : usagesSnapshot) {
        if (!usage.isDeleted()) {
          if (usage instanceof PhiNode) {
            usage.replaceFirstInput(node, null);
          } else {
            propagateKill(usage);
          }
        }
      }
    }
  }
Example #7
0
 @Test
 public void testValueProxyInputs() {
   StructuredGraph graph = parseEager("testValueProxyInputsSnippet", AllowAssumptions.YES);
   for (FrameState fs : graph.getNodes().filter(FrameState.class).snapshot()) {
     fs.replaceAtUsages(null);
     GraphUtil.killWithUnusedFloatingInputs(fs);
   }
   SchedulePhase schedulePhase = new SchedulePhase(SchedulingStrategy.LATEST);
   schedulePhase.apply(graph);
   ScheduleResult schedule = graph.getLastSchedule();
   NodeMap<Block> nodeToBlock = schedule.getCFG().getNodeToBlock();
   assertTrue(graph.getNodes().filter(LoopExitNode.class).count() == 1);
   LoopExitNode loopExit = graph.getNodes().filter(LoopExitNode.class).first();
   List<Node> list = schedule.nodesFor(nodeToBlock.get(loopExit));
   for (BinaryArithmeticNode<?> node : graph.getNodes().filter(BinaryArithmeticNode.class)) {
     if (!(node instanceof AddNode)) {
       assertTrue(node.toString(), nodeToBlock.get(node) == nodeToBlock.get(loopExit));
       assertTrue(
           list.indexOf(node) + " < " + list.indexOf(loopExit) + ", " + node + ", " + loopExit,
           list.indexOf(node) < list.indexOf(loopExit));
     }
   }
 }