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
  /**
   * 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()]);
  }