Search in sources :

Example 1 with SchedulePhase

use of org.graalvm.compiler.phases.schedule.SchedulePhase in project graal by oracle.

the class AArch64HotSpotSuitesProvider method createSuites.

@Override
public Suites createSuites(OptionValues options) {
    Suites suites = super.createSuites(options);
    ListIterator<BasePhase<? super LowTierContext>> findPhase = suites.getLowTier().findPhase(FixReadsPhase.class);
    if (findPhase == null) {
        findPhase = suites.getLowTier().findPhase(ExpandLogicPhase.class);
    }
    findPhase.add(new AddressLoweringByUsePhase(addressLoweringByUse));
    // Put AArch64ReadReplacementPhase right before the SchedulePhase
    findPhase = suites.getLowTier().findPhase(SchedulePhase.class);
    while (PhaseSuite.findNextPhase(findPhase, SchedulePhase.class)) {
    // Search for last occurrence of SchedulePhase
    }
    findPhase.previous();
    findPhase.add(new AArch64ReadReplacementPhase());
    return suites;
}
Also used : LowTierContext(org.graalvm.compiler.phases.tiers.LowTierContext) SchedulePhase(org.graalvm.compiler.phases.schedule.SchedulePhase) AArch64ReadReplacementPhase(org.graalvm.compiler.replacements.aarch64.AArch64ReadReplacementPhase) ExpandLogicPhase(org.graalvm.compiler.phases.common.ExpandLogicPhase) AddressLoweringByUsePhase(org.graalvm.compiler.phases.common.AddressLoweringByUsePhase) BasePhase(org.graalvm.compiler.phases.BasePhase) Suites(org.graalvm.compiler.phases.tiers.Suites)

Example 2 with SchedulePhase

use of org.graalvm.compiler.phases.schedule.SchedulePhase in project graal by oracle.

the class ProfileCompiledMethodsPhase method run.

@Override
protected void run(StructuredGraph graph) {
    SchedulePhase schedule = new SchedulePhase(graph.getOptions());
    schedule.apply(graph, false);
    ControlFlowGraph cfg = ControlFlowGraph.compute(graph, true, true, true, true);
    for (Loop<Block> loop : cfg.getLoops()) {
        double loopProbability = cfg.blockFor(loop.getHeader().getBeginNode()).probability();
        if (loopProbability > (1D / Integer.MAX_VALUE)) {
            addSectionCounters(loop.getHeader().getBeginNode(), loop.getBlocks(), loop.getChildren(), graph.getLastSchedule(), cfg);
        }
    }
    // don't put the counter increase directly after the start (problems with OSR)
    FixedWithNextNode current = graph.start();
    while (current.next() instanceof FixedWithNextNode) {
        current = (FixedWithNextNode) current.next();
    }
    addSectionCounters(current, Arrays.asList(cfg.getBlocks()), cfg.getLoops(), graph.getLastSchedule(), cfg);
    if (WITH_INVOKES) {
        for (Node node : graph.getNodes()) {
            if (node instanceof Invoke) {
                Invoke invoke = (Invoke) node;
                DynamicCounterNode.addCounterBefore(GROUP_NAME_INVOKES, invoke.callTarget().targetName(), 1, true, invoke.asNode());
            }
        }
    }
}
Also used : FixedWithNextNode(org.graalvm.compiler.nodes.FixedWithNextNode) SchedulePhase(org.graalvm.compiler.phases.schedule.SchedulePhase) ControlFlowGraph(org.graalvm.compiler.nodes.cfg.ControlFlowGraph) ConstantNode(org.graalvm.compiler.nodes.ConstantNode) ReinterpretNode(org.graalvm.compiler.nodes.calc.ReinterpretNode) RemNode(org.graalvm.compiler.nodes.calc.RemNode) AbstractMergeNode(org.graalvm.compiler.nodes.AbstractMergeNode) IntegerDivRemNode(org.graalvm.compiler.nodes.calc.IntegerDivRemNode) BinaryNode(org.graalvm.compiler.nodes.calc.BinaryNode) SwitchNode(org.graalvm.compiler.nodes.extended.SwitchNode) NotNode(org.graalvm.compiler.nodes.calc.NotNode) MonitorIdNode(org.graalvm.compiler.nodes.java.MonitorIdNode) ParameterNode(org.graalvm.compiler.nodes.ParameterNode) AccessMonitorNode(org.graalvm.compiler.nodes.java.AccessMonitorNode) AbstractNewObjectNode(org.graalvm.compiler.nodes.java.AbstractNewObjectNode) DeoptimizeNode(org.graalvm.compiler.nodes.DeoptimizeNode) ReturnNode(org.graalvm.compiler.nodes.ReturnNode) CallTargetNode(org.graalvm.compiler.nodes.CallTargetNode) FixedNode(org.graalvm.compiler.nodes.FixedNode) IfNode(org.graalvm.compiler.nodes.IfNode) VirtualObjectNode(org.graalvm.compiler.nodes.virtual.VirtualObjectNode) AbstractBeginNode(org.graalvm.compiler.nodes.AbstractBeginNode) AbstractEndNode(org.graalvm.compiler.nodes.AbstractEndNode) LogicNode(org.graalvm.compiler.nodes.LogicNode) SafepointNode(org.graalvm.compiler.nodes.SafepointNode) UnwindNode(org.graalvm.compiler.nodes.UnwindNode) Node(org.graalvm.compiler.graph.Node) ConvertNode(org.graalvm.compiler.nodes.calc.ConvertNode) MulNode(org.graalvm.compiler.nodes.calc.MulNode) FixedWithNextNode(org.graalvm.compiler.nodes.FixedWithNextNode) DynamicCounterNode(org.graalvm.compiler.nodes.debug.DynamicCounterNode) FloatDivNode(org.graalvm.compiler.nodes.calc.FloatDivNode) Block(org.graalvm.compiler.nodes.cfg.Block) Invoke(org.graalvm.compiler.nodes.Invoke)

Example 3 with SchedulePhase

use of org.graalvm.compiler.phases.schedule.SchedulePhase in project graal by oracle.

the class ReentrantBlockIteratorTest method getVisitedBlocksInOrder.

private List<Block> getVisitedBlocksInOrder(String snippet) {
    StructuredGraph graph = parseEager(snippet, AllowAssumptions.YES);
    // after FSA to ensure HIR loop data structure does not contain loop exits
    graph.setGuardsStage(GuardsStage.AFTER_FSA);
    ArrayList<Block> blocks = new ArrayList<>();
    class VoidState {
    }
    final VoidState voidState = new VoidState();
    BlockIteratorClosure<VoidState> closure = new BlockIteratorClosure<VoidState>() {

        @Override
        protected VoidState getInitialState() {
            return voidState;
        }

        @Override
        protected VoidState processBlock(Block block, VoidState currentState) {
            // remember the visit order
            blocks.add(block);
            return currentState;
        }

        @Override
        protected VoidState merge(Block merge, List<VoidState> states) {
            return voidState;
        }

        @Override
        protected VoidState cloneState(VoidState oldState) {
            return voidState;
        }

        @Override
        protected List<VoidState> processLoop(Loop<Block> loop, VoidState initialState) {
            return ReentrantBlockIterator.processLoop(this, loop, initialState).exitStates;
        }
    };
    ControlFlowGraph cfg = ControlFlowGraph.compute(graph, true, true, true, false);
    ReentrantBlockIterator.apply(closure, cfg.getStartBlock());
    // schedule for IGV
    new SchedulePhase(graph.getOptions()).apply(graph);
    return blocks;
}
Also used : Loop(org.graalvm.compiler.core.common.cfg.Loop) BlockIteratorClosure(org.graalvm.compiler.phases.graph.ReentrantBlockIterator.BlockIteratorClosure) SchedulePhase(org.graalvm.compiler.phases.schedule.SchedulePhase) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) ControlFlowGraph(org.graalvm.compiler.nodes.cfg.ControlFlowGraph) ArrayList(java.util.ArrayList) Block(org.graalvm.compiler.nodes.cfg.Block) ArrayList(java.util.ArrayList) List(java.util.List)

Example 4 with SchedulePhase

use of org.graalvm.compiler.phases.schedule.SchedulePhase in project graal by oracle.

the class TypeSystemTest method outputGraph.

public static void outputGraph(StructuredGraph graph, String message) {
    TTY.println("========================= " + message);
    SchedulePhase schedulePhase = new SchedulePhase(graph.getOptions());
    schedulePhase.apply(graph);
    ScheduleResult schedule = graph.getLastSchedule();
    for (Block block : schedule.getCFG().getBlocks()) {
        TTY.print("Block " + block + " ");
        if (block == schedule.getCFG().getStartBlock()) {
            TTY.print("* ");
        }
        TTY.print("-> ");
        for (Block succ : block.getSuccessors()) {
            TTY.print(succ + " ");
        }
        TTY.println();
        for (Node node : schedule.getBlockToNodesMap().get(block)) {
            outputNode(node);
        }
    }
}
Also used : SchedulePhase(org.graalvm.compiler.phases.schedule.SchedulePhase) ScheduleResult(org.graalvm.compiler.nodes.StructuredGraph.ScheduleResult) AbstractMergeNode(org.graalvm.compiler.nodes.AbstractMergeNode) InstanceOfNode(org.graalvm.compiler.nodes.java.InstanceOfNode) Node(org.graalvm.compiler.graph.Node) PhiNode(org.graalvm.compiler.nodes.PhiNode) Block(org.graalvm.compiler.nodes.cfg.Block)

Example 5 with SchedulePhase

use of org.graalvm.compiler.phases.schedule.SchedulePhase in project graal by oracle.

the class LongNodeChainTest method longAddChain.

private void longAddChain(boolean reverse) {
    HighTierContext context = getDefaultHighTierContext();
    OptionValues options = getInitialOptions();
    StructuredGraph graph = new StructuredGraph.Builder(options, DebugContext.create(options, DebugHandlersFactory.LOADER)).build();
    ValueNode constant = graph.unique(ConstantNode.forPrimitive(JavaConstant.INT_1));
    ValueNode value = null;
    if (reverse) {
        // Make sure the constant's stamp is not used to infer the add node's stamp.
        OpaqueNode opaque = graph.unique(new OpaqueNode(constant));
        constant = opaque;
        AddNode addNode = graph.unique(new AddNode(constant, constant));
        value = addNode;
        for (int i = 1; i < N; ++i) {
            AddNode newAddNode = graph.addWithoutUnique(new AddNode(constant, constant));
            addNode.setY(newAddNode);
            addNode = newAddNode;
        }
        opaque.replaceAndDelete(opaque.getValue());
    } else {
        value = constant;
        for (int i = 0; i < N; ++i) {
            value = graph.unique(new AddNode(constant, value));
        }
    }
    ReturnNode returnNode = graph.add(new ReturnNode(value));
    graph.start().setNext(returnNode);
    for (SchedulingStrategy s : Strategies) {
        new SchedulePhase(s).apply(graph);
    }
    new CanonicalizerPhase().apply(graph, context);
    JavaConstant asConstant = (JavaConstant) returnNode.result().asConstant();
    Assert.assertEquals(N + 1, asConstant.asInt());
}
Also used : SchedulePhase(org.graalvm.compiler.phases.schedule.SchedulePhase) OptionValues(org.graalvm.compiler.options.OptionValues) JavaConstant(jdk.vm.ci.meta.JavaConstant) OpaqueNode(org.graalvm.compiler.nodes.debug.OpaqueNode) ReturnNode(org.graalvm.compiler.nodes.ReturnNode) SchedulingStrategy(org.graalvm.compiler.phases.schedule.SchedulePhase.SchedulingStrategy) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) ValueNode(org.graalvm.compiler.nodes.ValueNode) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase) HighTierContext(org.graalvm.compiler.phases.tiers.HighTierContext) AddNode(org.graalvm.compiler.nodes.calc.AddNode)

Aggregations

SchedulePhase (org.graalvm.compiler.phases.schedule.SchedulePhase)20 Block (org.graalvm.compiler.nodes.cfg.Block)10 Node (org.graalvm.compiler.graph.Node)9 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)8 ScheduleResult (org.graalvm.compiler.nodes.StructuredGraph.ScheduleResult)8 DebugContext (org.graalvm.compiler.debug.DebugContext)5 ReturnNode (org.graalvm.compiler.nodes.ReturnNode)5 ArrayList (java.util.ArrayList)4 List (java.util.List)4 ConstantNode (org.graalvm.compiler.nodes.ConstantNode)4 ParameterNode (org.graalvm.compiler.nodes.ParameterNode)4 ProxyNode (org.graalvm.compiler.nodes.ProxyNode)4 ValueNode (org.graalvm.compiler.nodes.ValueNode)4 ControlFlowGraph (org.graalvm.compiler.nodes.cfg.ControlFlowGraph)4 VirtualObjectNode (org.graalvm.compiler.nodes.virtual.VirtualObjectNode)4 AbstractMergeNode (org.graalvm.compiler.nodes.AbstractMergeNode)3 FixedNode (org.graalvm.compiler.nodes.FixedNode)3 FixedWithNextNode (org.graalvm.compiler.nodes.FixedWithNextNode)3 FrameState (org.graalvm.compiler.nodes.FrameState)3 FullInfopointNode (org.graalvm.compiler.nodes.FullInfopointNode)3