Search in sources :

Example 51 with Block

use of org.graalvm.compiler.nodes.cfg.Block in project graal by oracle.

the class ReentrantBlockIterator method processMultipleSuccessors.

private static <StateT> Block processMultipleSuccessors(BlockIteratorClosure<StateT> closure, Deque<Block> blockQueue, EconomicMap<FixedNode, StateT> states, StateT state, Block[] successors) {
    assert successors.length > 1;
    for (int i = 1; i < successors.length; i++) {
        Block successor = successors[i];
        blockQueue.addFirst(successor);
        states.put(successor.getBeginNode(), closure.cloneState(state));
    }
    return successors[0];
}
Also used : Block(org.graalvm.compiler.nodes.cfg.Block)

Example 52 with Block

use of org.graalvm.compiler.nodes.cfg.Block in project graal by oracle.

the class GuardLoweringPhase method run.

@Override
protected void run(StructuredGraph graph, MidTierContext context) {
    if (graph.getGuardsStage().allowsFloatingGuards()) {
        SchedulePhase schedulePhase = new SchedulePhase(SchedulingStrategy.EARLIEST_WITH_GUARD_ORDER);
        schedulePhase.apply(graph);
        ScheduleResult schedule = graph.getLastSchedule();
        for (Block block : schedule.getCFG().getBlocks()) {
            processBlock(block, schedule);
        }
        graph.setGuardsStage(GuardsStage.FIXED_DEOPTS);
    }
    assert assertNoGuardsLeft(graph);
}
Also used : SchedulePhase(org.graalvm.compiler.phases.schedule.SchedulePhase) ScheduleResult(org.graalvm.compiler.nodes.StructuredGraph.ScheduleResult) Block(org.graalvm.compiler.nodes.cfg.Block)

Example 53 with Block

use of org.graalvm.compiler.nodes.cfg.Block in project graal by oracle.

the class LoweringPhase method processBlockBounded.

public static void processBlockBounded(final Frame<?> rootFrame) {
    ProcessBlockState state = ST_PROCESS;
    Frame<?> f = rootFrame;
    while (f != null) {
        ProcessBlockState nextState;
        if (state == ST_PROCESS || state == ST_PROCESS_ALWAYS_REACHED) {
            f.preprocess();
            nextState = state == ST_PROCESS_ALWAYS_REACHED ? ST_ENTER : ST_ENTER_ALWAYS_REACHED;
        } else if (state == ST_ENTER_ALWAYS_REACHED) {
            if (f.alwaysReachedBlock != null && f.alwaysReachedBlock.getDominator() == f.block) {
                Frame<?> continueRecur = f.enterAlwaysReached(f.alwaysReachedBlock);
                if (continueRecur == null) {
                    // stop recursion here
                    f.postprocess();
                    f = f.parent;
                    state = ST_ENTER;
                    continue;
                }
                f = continueRecur;
                nextState = ST_PROCESS;
            } else {
                nextState = ST_ENTER;
            }
        } else if (state == ST_ENTER) {
            if (f.dominated != null) {
                Block n = f.dominated;
                f.dominated = n.getDominatedSibling();
                if (n == f.alwaysReachedBlock) {
                    if (f.dominated != null) {
                        n = f.dominated;
                        f.dominated = n.getDominatedSibling();
                    } else {
                        n = null;
                    }
                }
                if (n == null) {
                    nextState = ST_LEAVE;
                } else {
                    Frame<?> continueRecur = f.enter(n);
                    if (continueRecur == null) {
                        // stop recursion here
                        f.postprocess();
                        f = f.parent;
                        state = ST_ENTER;
                        continue;
                    }
                    f = continueRecur;
                    nextState = ST_PROCESS;
                }
            } else {
                nextState = ST_LEAVE;
            }
        } else if (state == ST_LEAVE) {
            f.postprocess();
            f = f.parent;
            nextState = ST_ENTER;
        } else {
            throw GraalError.shouldNotReachHere();
        }
        state = nextState;
    }
}
Also used : Block(org.graalvm.compiler.nodes.cfg.Block)

Example 54 with Block

use of org.graalvm.compiler.nodes.cfg.Block in project graal by oracle.

the class LoweringPhase method processBlock.

/**
 * This state-machine resembles the following recursion:
 *
 * <pre>
 * void processBlock(Block block) {
 *     preprocess();
 *     // Process always reached block first.
 *     Block alwaysReachedBlock = block.getPostdominator();
 *     if (alwaysReachedBlock != null &amp;&amp; alwaysReachedBlock.getDominator() == block) {
 *         processBlock(alwaysReachedBlock);
 *     }
 *
 *     // Now go for the other dominators.
 *     for (Block dominated : block.getDominated()) {
 *         if (dominated != alwaysReachedBlock) {
 *             assert dominated.getDominator() == block;
 *             processBlock(dominated);
 *         }
 *     }
 *     postprocess();
 * }
 * </pre>
 *
 * This is necessary, as the recursive implementation quickly exceed the stack depth on SPARC.
 *
 * @param rootFrame contains the starting block.
 */
public static void processBlock(final Frame<?> rootFrame) {
    ProcessBlockState state = ST_PROCESS;
    Frame<?> f = rootFrame;
    while (f != null) {
        ProcessBlockState nextState;
        if (state == ST_PROCESS || state == ST_PROCESS_ALWAYS_REACHED) {
            f.preprocess();
            nextState = state == ST_PROCESS_ALWAYS_REACHED ? ST_ENTER : ST_ENTER_ALWAYS_REACHED;
        } else if (state == ST_ENTER_ALWAYS_REACHED) {
            if (f.alwaysReachedBlock != null && f.alwaysReachedBlock.getDominator() == f.block) {
                f = f.enterAlwaysReached(f.alwaysReachedBlock);
                nextState = ST_PROCESS;
            } else {
                nextState = ST_ENTER;
            }
        } else if (state == ST_ENTER) {
            if (f.dominated != null) {
                Block n = f.dominated;
                f.dominated = n.getDominatedSibling();
                if (n == f.alwaysReachedBlock) {
                    if (f.dominated != null) {
                        n = f.dominated;
                        f.dominated = n.getDominatedSibling();
                    } else {
                        n = null;
                    }
                }
                if (n == null) {
                    nextState = ST_LEAVE;
                } else {
                    f = f.enter(n);
                    assert f.block.getDominator() == f.parent.block;
                    nextState = ST_PROCESS;
                }
            } else {
                nextState = ST_LEAVE;
            }
        } else if (state == ST_LEAVE) {
            f.postprocess();
            f = f.parent;
            nextState = ST_ENTER;
        } else {
            throw GraalError.shouldNotReachHere();
        }
        state = nextState;
    }
}
Also used : Block(org.graalvm.compiler.nodes.cfg.Block)

Aggregations

Block (org.graalvm.compiler.nodes.cfg.Block)54 Node (org.graalvm.compiler.graph.Node)20 FixedNode (org.graalvm.compiler.nodes.FixedNode)17 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)14 ScheduleResult (org.graalvm.compiler.nodes.StructuredGraph.ScheduleResult)14 ValueNode (org.graalvm.compiler.nodes.ValueNode)14 AbstractBeginNode (org.graalvm.compiler.nodes.AbstractBeginNode)13 AbstractMergeNode (org.graalvm.compiler.nodes.AbstractMergeNode)13 FixedWithNextNode (org.graalvm.compiler.nodes.FixedWithNextNode)13 LoopBeginNode (org.graalvm.compiler.nodes.LoopBeginNode)13 ControlFlowGraph (org.graalvm.compiler.nodes.cfg.ControlFlowGraph)12 SchedulePhase (org.graalvm.compiler.phases.schedule.SchedulePhase)11 ConstantNode (org.graalvm.compiler.nodes.ConstantNode)9 LoopExitNode (org.graalvm.compiler.nodes.LoopExitNode)9 PhiNode (org.graalvm.compiler.nodes.PhiNode)9 List (java.util.List)8 DebugContext (org.graalvm.compiler.debug.DebugContext)8 AbstractEndNode (org.graalvm.compiler.nodes.AbstractEndNode)8 ArrayList (java.util.ArrayList)7 ReturnNode (org.graalvm.compiler.nodes.ReturnNode)7