コード例 #1
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);
   }
 }
コード例 #2
0
 /**
  * The {@link com.oracle.graal.nodes.AbstractEndNode} at the end of the current code path
  * contributes values to {@link com.oracle.graal.nodes.PhiNode}s. Now is a good time to {@link
  * EquationalReasoner#deverbosify(com.oracle.graal.graph.Node) EquationalReasoner#deverbosify}
  * those values.
  *
  * <p>Precondition: inputs haven't been deverbosified yet.
  */
 private void visitAbstractEndNode(AbstractEndNode endNode) {
   MergeNode merge = endNode.merge();
   for (PhiNode phi : merge.phis()) {
     if (phi instanceof ValuePhiNode && phi.getKind() == Kind.Object) {
       assert phi.verify();
       int index = merge.phiPredecessorIndex(endNode);
       ValueNode original = phi.valueAt(index);
       ValueNode reduced = (ValueNode) reasoner.deverbosify(original);
       if (reduced != original) {
         phi.setValueAt(index, reduced);
         // `original` if unused will be removed in finished()
       }
     }
   }
 }
コード例 #3
0
ファイル: GraphUtil.java プロジェクト: rjsingh/graal
  public static void checkRedundantPhi(PhiNode phiNode) {
    if (phiNode.isDeleted() || phiNode.valueCount() == 1) {
      return;
    }

    ValueNode singleValue = phiNode.singleValue();
    if (singleValue != null) {
      Collection<PhiNode> phiUsages = phiNode.usages().filter(PhiNode.class).snapshot();
      Collection<ProxyNode> proxyUsages = phiNode.usages().filter(ProxyNode.class).snapshot();
      phiNode.graph().replaceFloating(phiNode, singleValue);
      for (PhiNode phi : phiUsages) {
        checkRedundantPhi(phi);
      }
      for (ProxyNode proxy : proxyUsages) {
        checkRedundantProxy(proxy);
      }
    }
  }