Ejemplo n.º 1
0
 private static void killEnd(AbstractEndNode end) {
   MergeNode merge = end.merge();
   if (merge != null) {
     merge.removeEnd(end);
     StructuredGraph graph = end.graph();
     if (merge instanceof LoopBeginNode && merge.forwardEndCount() == 0) { // dead loop
       for (PhiNode phi : merge.phis().snapshot()) {
         propagateKill(phi);
       }
       LoopBeginNode begin = (LoopBeginNode) merge;
       // disconnect and delete loop ends & loop exits
       for (LoopEndNode loopend : begin.loopEnds().snapshot()) {
         loopend.predecessor().replaceFirstSuccessor(loopend, null);
         loopend.safeDelete();
       }
       begin.removeExits();
       FixedNode loopBody = begin.next();
       if (loopBody != null) { // for small infinite loops, the body may be killed while
         // killing the loop ends
         killCFG(loopBody);
       }
       begin.safeDelete();
     } else if (merge instanceof LoopBeginNode
         && ((LoopBeginNode) merge).loopEnds().isEmpty()) { // not
       // a
       // loop
       // anymore
       graph.reduceDegenerateLoopBegin((LoopBeginNode) merge);
     } else if (merge.phiPredecessorCount() == 1) { // not a merge anymore
       graph.reduceTrivialMerge(merge);
     }
   }
 }
 @Override
 protected boolean checkMidTierGraph(StructuredGraph graph) {
   int count = 0;
   for (IsNullNode isNull : graph.getNodes().filter(IsNullNode.class).snapshot()) {
     ValueNode value = isNull.getValue();
     if (value instanceof CompressionNode) {
       count++;
       isNull.replaceFirstInput(value, ((CompressionNode) value).getValue());
     }
   }
   Assert.assertEquals("graph should contain exactly one IsNullNode", 1, count);
   return super.checkMidTierGraph(graph);
 }