Esempio n. 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);
   }
 }
 /**
  * Sets state of the frame, i.e. the location and dimension of the frame for the next use.
  *
  * @param s State to update to, or {@code null} to reset
  */
 public void setFrameState(String s) {
   try {
     _lastState = new FrameState(s);
   } catch (IllegalArgumentException e) {
     _lastState = null;
   }
   if (_lastState != null) {
     setSize(_lastState.getDimension());
     setLocation(_lastState.getLocation());
     int index = _lastState.getCurrentStrategyIndex();
     if ((index >= 0) && (index < _strategies.size())) {
       _currentStrategy = _strategies.get(index);
       _strategyBox.setSelectedIndex(index);
     }
     selectStrategy();
     validate();
   } else {
     Dimension parentDim = (_owner != null) ? _owner.getSize() : getToolkit().getScreenSize();
     // int xs = (int)parentDim.getWidth()/3;
     int ys = (int) parentDim.getHeight() / 4;
     // in line below, parentDim was _owner.getSize(); changed because former could generate
     // NullPointerException
     setSize(
         new Dimension(
             (int) getSize().getWidth(),
             (int) Math.min(parentDim.getHeight(), Math.max(ys, 300))));
     if (_owner != null) {
       setLocationRelativeTo(_owner);
     }
     _currentStrategy = _strategies.get(0);
     _strategyBox.setSelectedIndex(0);
     selectStrategy();
   }
 }
Esempio n. 3
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);
 }
 /**
  * Sets state of the frame, i.e. the location and dimension of the frame for the next use.
  *
  * @param ds State to update to, or {@code null} to reset
  */
 public void setFrameState(FrameState ds) {
   _lastState = ds;
   if (_lastState != null) {
     setSize(_lastState.getDimension());
     setLocation(_lastState.getLocation());
     int index = _lastState.getCurrentStrategyIndex();
     if ((index >= 0) && (index < _strategies.size())) {
       _currentStrategy = _strategies.get(index);
       _strategyBox.setSelectedIndex(index);
     }
     selectStrategy();
     validate();
   }
 }
Esempio n. 5
0
  /**
   * Gets an approximate source code location for a node if possible.
   *
   * @return the StackTraceElements if an approximate source location is found, null otherwise
   */
  public static StackTraceElement[] approxSourceStackTraceElement(Node node) {
    ArrayList<StackTraceElement> elements = new ArrayList<>();
    Node n = node;
    while (n != null) {
      if (n instanceof MethodCallTargetNode) {
        elements.add(((MethodCallTargetNode) n).targetMethod().asStackTraceElement(-1));
        n = ((MethodCallTargetNode) n).invoke().asNode();
      }

      if (n instanceof StateSplit) {
        FrameState state = ((StateSplit) n).stateAfter();
        while (state != null) {
          ResolvedJavaMethod method = state.method();
          if (method != null) {
            elements.add(method.asStackTraceElement(state.bci - 1));
          }
          state = state.outerFrameState();
        }
        break;
      }
      n = n.predecessor();
    }
    return elements.toArray(new StackTraceElement[elements.size()]);
  }