예제 #1
0
파일: GraphUtil.java 프로젝트: smarr/graal
  /**
   * 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()]);
  }
예제 #2
0
파일: GraphUtil.java 프로젝트: smarr/graal
 public void deleteBranch(Node branch) {
   branch.predecessor().replaceFirstSuccessor(branch, null);
   GraphUtil.killCFG(branch, this);
 }