Exemple #1
0
 private StructuredGraph parseAndProcess(String snippet) {
   StructuredGraph graph = parse(snippet);
   LocalNode local = graph.getNodes(LocalNode.class).first();
   ConstantNode constant = ConstantNode.forInt(0, graph);
   for (Node n : local.usages().filter(isNotA(FrameState.class)).snapshot()) {
     n.replaceFirstInput(local, constant);
   }
   Map<Invoke, Double> hints = new HashMap<>();
   for (Invoke invoke : graph.getInvokes()) {
     hints.put(invoke, 1000d);
   }
   Assumptions assumptions = new Assumptions(false);
   new InliningPhase(
           runtime(),
           hints,
           replacements,
           assumptions,
           null,
           getDefaultPhasePlan(),
           OptimisticOptimizations.ALL)
       .apply(graph);
   new CanonicalizerPhase.Instance(runtime(), assumptions, true).apply(graph);
   new DeadCodeEliminationPhase().apply(graph);
   return graph;
 }
Exemple #2
0
  public static void propagateKill(Node node) {
    if (node != null && node.isAlive()) {
      List<Node> usagesSnapshot = node.usages().filter(isFloatingNode()).snapshot();

      // null out remaining usages
      node.replaceAtUsages(null);
      node.replaceAtPredecessor(null);
      killWithUnusedFloatingInputs(node);

      for (Node usage : usagesSnapshot) {
        if (!usage.isDeleted()) {
          if (usage instanceof PhiNode) {
            usage.replaceFirstInput(node, null);
          } else {
            propagateKill(usage);
          }
        }
      }
    }
  }