コード例 #1
0
ファイル: MonitorGraphTest.java プロジェクト: headius/graal
 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;
 }
コード例 #2
0
ファイル: MonitorGraphTest.java プロジェクト: headius/graal
 @Test
 public void test2() {
   StructuredGraph graph = parseAndProcess("test2Snippet");
   NodeIterable<MonitorExitNode> monitors = graph.getNodes(MonitorExitNode.class);
   Assert.assertEquals(1, monitors.count());
   Assert.assertEquals(monitors.first().stateAfter().bci, 3);
 }
コード例 #3
0
 private void test(String snippet) {
   StructuredGraph graph = parseProfiled(snippet, AllowAssumptions.NO);
   Map<Invoke, Double> hints = new HashMap<>();
   for (Invoke invoke : graph.getInvokes()) {
     hints.put(invoke, 1000d);
   }
   HighTierContext context =
       new HighTierContext(
           getProviders(), null, getDefaultGraphBuilderSuite(), OptimisticOptimizations.ALL);
   new InliningPhase(hints, new CanonicalizerPhase(true)).apply(graph, context);
   new CanonicalizerPhase(true).apply(graph, context);
   new DeadCodeEliminationPhase().apply(graph);
 }