Ejemplo n.º 1
0
 /**
  * Applies {@linkplain LoweringPhase lowering} to a replacement graph.
  *
  * @param replacementGraph a replacement (i.e., snippet or method substitution) graph
  */
 @SuppressWarnings("try")
 protected StructuredGraph lowerReplacement(
     final StructuredGraph replacementGraph, LoweringTool tool) {
   final PhaseContext c =
       new PhaseContext(
           tool.getMetaAccess(),
           tool.getConstantReflection(),
           tool.getConstantFieldProvider(),
           tool.getLowerer(),
           tool.getReplacements(),
           tool.getStampProvider(),
           tool.getNodeCostProvider());
   if (!graph().hasValueProxies()) {
     new RemoveValueProxyPhase().apply(replacementGraph);
   }
   GuardsStage guardsStage = graph().getGuardsStage();
   if (!guardsStage.allowsFloatingGuards()) {
     new GuardLoweringPhase().apply(replacementGraph, null);
     if (guardsStage.areFrameStatesAtDeopts()) {
       new FrameStateAssignmentPhase().apply(replacementGraph);
     }
   }
   try (Scope s = Debug.scope("LoweringSnippetTemplate", replacementGraph)) {
     new LoweringPhase(new CanonicalizerPhase(), tool.getLoweringStage())
         .apply(replacementGraph, c);
   } catch (Throwable e) {
     throw Debug.handle(e);
   }
   return replacementGraph;
 }
Ejemplo n.º 2
0
 @Override
 void walk() {
   try (Scope s = Debug.scope("OptimizingLinearScanWalker")) {
     for (AbstractBlock<?> block : allocator.sortedBlocks) {
       optimizeBlock(block);
     }
   }
   super.walk();
 }
Ejemplo n.º 3
0
 @SuppressWarnings("try")
 public boolean verify() {
   try (Scope s = Debug.scope("SSAVerifier", lir)) {
     for (AbstractBlockBase<?> block : lir.getControlFlowGraph().getBlocks()) {
       doBlock(block);
     }
   } catch (Throwable e) {
     throw Debug.handle(e);
   }
   return true;
 }
Ejemplo n.º 4
0
  private void optimizeBlock(AbstractBlock<?> block) {
    if (block.getPredecessorCount() == 1) {
      int nextBlock = allocator.getFirstLirInstructionId(block);
      try (Scope s1 = Debug.scope("LSRAOptimization")) {
        Debug.log("next block: %s (%d)", block, nextBlock);
      }
      try (Indent indent0 = Debug.indent()) {
        walkTo(nextBlock);

        try (Scope s1 = Debug.scope("LSRAOptimization")) {
          boolean changed = true;
          // we need to do this because the active lists might change
          loop:
          while (changed) {
            changed = false;
            try (Indent indent1 =
                Debug.logAndIndent("Active intervals: (block %s [%d])", block, nextBlock)) {
              for (Interval active = activeLists.get(RegisterBinding.Any);
                  active != Interval.EndMarker;
                  active = active.next) {
                Debug.log("active   (any): %s", active);
                if (optimize(nextBlock, block, active, RegisterBinding.Any)) {
                  changed = true;
                  break loop;
                }
              }
              for (Interval active = activeLists.get(RegisterBinding.Stack);
                  active != Interval.EndMarker;
                  active = active.next) {
                Debug.log("active (stack): %s", active);
                if (optimize(nextBlock, block, active, RegisterBinding.Stack)) {
                  changed = true;
                  break loop;
                }
              }
            }
          }
        }
      }
    }
  }
Ejemplo n.º 5
0
 @Override
 protected void handleSpillSlot(Interval interval) {
   assert interval.location() != null : "interval  not assigned " + interval;
   if (interval.canMaterialize()) {
     assert !isStackSlot(interval.location())
         : "interval can materialize but assigned to a stack slot " + interval;
     return;
   }
   assert isStackSlot(interval.location()) : "interval not assigned to a stack slot " + interval;
   try (Scope s1 = Debug.scope("LSRAOptimization")) {
     Debug.log("adding stack to unhandled list %s", interval);
     unhandledLists.addToListSortedByStartAndUsePositions(RegisterBinding.Stack, interval);
   }
 }
Ejemplo n.º 6
0
  @SuppressWarnings("try")
  private ScheduleResult getFinalSchedule(
      final String snippet, final TestMode mode, final SchedulingStrategy schedulingStrategy) {
    final StructuredGraph graph = parseEager(snippet, AllowAssumptions.NO);
    try (Scope d = Debug.scope("FloatingReadTest", graph)) {
      try (OverrideScope s =
          OptionValue.override(
              OptScheduleOutOfLoops,
              schedulingStrategy == SchedulingStrategy.LATEST_OUT_OF_LOOPS,
              OptImplicitNullChecks,
              false)) {
        HighTierContext context = getDefaultHighTierContext();
        CanonicalizerPhase canonicalizer = new CanonicalizerPhase();
        canonicalizer.apply(graph, context);
        if (mode == TestMode.INLINED_WITHOUT_FRAMESTATES) {
          new InliningPhase(canonicalizer).apply(graph, context);
        }
        new LoweringPhase(canonicalizer, LoweringTool.StandardLoweringStage.HIGH_TIER)
            .apply(graph, context);
        if (mode == TestMode.WITHOUT_FRAMESTATES || mode == TestMode.INLINED_WITHOUT_FRAMESTATES) {
          graph.clearAllStateAfter();
        }
        Debug.dump(graph, "after removal of framestates");

        new FloatingReadPhase().apply(graph);
        new RemoveValueProxyPhase().apply(graph);

        MidTierContext midContext =
            new MidTierContext(
                getProviders(),
                getTargetProvider(),
                OptimisticOptimizations.ALL,
                graph.getProfilingInfo());
        new GuardLoweringPhase().apply(graph, midContext);
        new LoweringPhase(canonicalizer, LoweringTool.StandardLoweringStage.MID_TIER)
            .apply(graph, midContext);
        new LoweringPhase(canonicalizer, LoweringTool.StandardLoweringStage.LOW_TIER)
            .apply(graph, midContext);

        SchedulePhase schedule = new SchedulePhase(schedulingStrategy);
        schedule.apply(graph);
        assertDeepEquals(1, graph.getNodes().filter(StartNode.class).count());
        return graph.getLastSchedule();
      }
    } catch (Throwable e) {
      throw Debug.handle(e);
    }
  }
Ejemplo n.º 7
0
  public LoopsData(final StructuredGraph graph) {
    cfg =
        Debug.scope(
            "ControlFlowGraph",
            new Callable<ControlFlowGraph>() {

              @Override
              public ControlFlowGraph call() throws Exception {
                return ControlFlowGraph.compute(graph, true, true, true, true);
              }
            });
    for (Loop lirLoop : cfg.getLoops()) {
      LoopEx ex = new LoopEx(lirLoop, this);
      lirLoopToEx.put(lirLoop, ex);
      loopBeginToEx.put(ex.loopBegin(), ex);
    }
  }
Ejemplo n.º 8
0
  @SuppressWarnings("try")
  protected LIRGenerationResult getLIRGenerationResult(final StructuredGraph graph) {
    try (Scope s = Debug.scope("FrontEnd")) {
      GraalCompiler.emitFrontEnd(
          getProviders(),
          getBackend(),
          graph,
          getDefaultGraphBuilderSuite(),
          OptimisticOptimizations.NONE,
          graph.getProfilingInfo(),
          getSuites());
    } catch (Throwable e) {
      throw Debug.handle(e);
    }

    LIRGenerationResult lirGen =
        GraalCompiler.emitLIR(getBackend(), graph, null, null, getLIRSuites(), null);
    return lirGen;
  }
Ejemplo n.º 9
0
 public static void scope(String name, Object context, Runnable runnable) {
   scope(name, new Object[] {context}, runnable);
 }
Ejemplo n.º 10
0
 public static void scope(String name, Runnable runnable) {
   scope(name, new Object[0], runnable);
 }