Esempio n. 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);
 }
Esempio n. 2
0
 @Test
 public void testValueProxyInputs() {
   StructuredGraph graph = parseEager("testValueProxyInputsSnippet", AllowAssumptions.YES);
   for (FrameState fs : graph.getNodes().filter(FrameState.class).snapshot()) {
     fs.replaceAtUsages(null);
     GraphUtil.killWithUnusedFloatingInputs(fs);
   }
   SchedulePhase schedulePhase = new SchedulePhase(SchedulingStrategy.LATEST);
   schedulePhase.apply(graph);
   ScheduleResult schedule = graph.getLastSchedule();
   NodeMap<Block> nodeToBlock = schedule.getCFG().getNodeToBlock();
   assertTrue(graph.getNodes().filter(LoopExitNode.class).count() == 1);
   LoopExitNode loopExit = graph.getNodes().filter(LoopExitNode.class).first();
   List<Node> list = schedule.nodesFor(nodeToBlock.get(loopExit));
   for (BinaryArithmeticNode<?> node : graph.getNodes().filter(BinaryArithmeticNode.class)) {
     if (!(node instanceof AddNode)) {
       assertTrue(node.toString(), nodeToBlock.get(node) == nodeToBlock.get(loopExit));
       assertTrue(
           list.indexOf(node) + " < " + list.indexOf(loopExit) + ", " + node + ", " + loopExit,
           list.indexOf(node) < list.indexOf(loopExit));
     }
   }
 }
Esempio n. 3
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()]);
  }
 @Override
 public void setStateAfter(FrameState x) {
   assert x == null || x.isAlive() : "frame state must be in a graph";
   updateUsages(stateAfter, x);
   stateAfter = x;
 }