Search in sources :

Example 1 with RetryableBailoutException

use of org.graalvm.compiler.core.common.RetryableBailoutException in project graal by oracle.

the class IterativeConditionalEliminationPhase method run.

@Override
@SuppressWarnings("try")
protected void run(StructuredGraph graph, PhaseContext context) {
    HashSetNodeEventListener listener = new HashSetNodeEventListener().exclude(NODE_ADDED);
    int count = 0;
    while (true) {
        try (NodeEventScope nes = graph.trackNodeEvents(listener)) {
            new ConditionalEliminationPhase(fullSchedule).apply(graph, context);
        }
        if (listener.getNodes().isEmpty()) {
            break;
        }
        for (Node node : graph.getNodes()) {
            if (node instanceof Simplifiable) {
                listener.getNodes().add(node);
            }
        }
        canonicalizer.applyIncremental(graph, context, listener.getNodes());
        listener.getNodes().clear();
        if (++count > MAX_ITERATIONS) {
            throw new RetryableBailoutException("Number of iterations in ConditionalEliminationPhase phase exceeds %d", MAX_ITERATIONS);
        }
    }
}
Also used : HashSetNodeEventListener(org.graalvm.compiler.phases.common.util.HashSetNodeEventListener) NodeEventScope(org.graalvm.compiler.graph.Graph.NodeEventScope) RetryableBailoutException(org.graalvm.compiler.core.common.RetryableBailoutException) Node(org.graalvm.compiler.graph.Node) Simplifiable(org.graalvm.compiler.graph.spi.Simplifiable)

Example 2 with RetryableBailoutException

use of org.graalvm.compiler.core.common.RetryableBailoutException in project graal by oracle.

the class ReentrantBlockIterator method apply.

public static <StateT> EconomicMap<FixedNode, StateT> apply(BlockIteratorClosure<StateT> closure, Block start, StateT initialState, Predicate<Block> stopAtBlock) {
    Deque<Block> blockQueue = new ArrayDeque<>();
    /*
         * States are stored on EndNodes before merges, and on BeginNodes after ControlSplitNodes.
         */
    EconomicMap<FixedNode, StateT> states = EconomicMap.create(Equivalence.IDENTITY);
    StateT state = initialState;
    Block current = start;
    StructuredGraph graph = start.getBeginNode().graph();
    CompilationAlarm compilationAlarm = CompilationAlarm.current();
    while (true) {
        if (compilationAlarm.hasExpired()) {
            int period = CompilationAlarm.Options.CompilationExpirationPeriod.getValue(graph.getOptions());
            if (period > 120) {
                throw new PermanentBailoutException("Compilation exceeded %d seconds during CFG traversal", period);
            } else {
                throw new RetryableBailoutException("Compilation exceeded %d seconds during CFG traversal", period);
            }
        }
        Block next = null;
        if (stopAtBlock != null && stopAtBlock.test(current)) {
            states.put(current.getBeginNode(), state);
        } else {
            state = closure.processBlock(current, state);
            Block[] successors = current.getSuccessors();
            if (successors.length == 0) {
            // nothing to do...
            } else if (successors.length == 1) {
                Block successor = successors[0];
                if (successor.isLoopHeader()) {
                    if (current.isLoopEnd()) {
                        // nothing to do... loop ends only lead to loop begins we've already
                        // visited
                        states.put(current.getEndNode(), state);
                    } else {
                        recurseIntoLoop(closure, blockQueue, states, state, successor);
                    }
                } else if (current.getEndNode() instanceof AbstractEndNode) {
                    AbstractEndNode end = (AbstractEndNode) current.getEndNode();
                    // add the end node and see if the merge is ready for processing
                    AbstractMergeNode merge = end.merge();
                    if (allEndsVisited(states, current, merge)) {
                        ArrayList<StateT> mergedStates = mergeStates(states, state, current, successor, merge);
                        state = closure.merge(successor, mergedStates);
                        next = successor;
                    } else {
                        assert !states.containsKey(end);
                        states.put(end, state);
                    }
                } else {
                    next = successor;
                }
            } else {
                next = processMultipleSuccessors(closure, blockQueue, states, state, successors);
            }
        }
        // get next queued block
        if (next != null) {
            current = next;
        } else if (blockQueue.isEmpty()) {
            return states;
        } else {
            current = blockQueue.removeFirst();
            assert current.getPredecessorCount() == 1;
            assert states.containsKey(current.getBeginNode());
            state = states.removeKey(current.getBeginNode());
        }
    }
}
Also used : CompilationAlarm(org.graalvm.compiler.core.common.util.CompilationAlarm) FixedNode(org.graalvm.compiler.nodes.FixedNode) AbstractMergeNode(org.graalvm.compiler.nodes.AbstractMergeNode) ArrayDeque(java.util.ArrayDeque) RetryableBailoutException(org.graalvm.compiler.core.common.RetryableBailoutException) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) AbstractEndNode(org.graalvm.compiler.nodes.AbstractEndNode) Block(org.graalvm.compiler.nodes.cfg.Block) PermanentBailoutException(org.graalvm.compiler.core.common.PermanentBailoutException)

Example 3 with RetryableBailoutException

use of org.graalvm.compiler.core.common.RetryableBailoutException in project graal by oracle.

the class LoopTransformations method fullUnroll.

public static void fullUnroll(LoopEx loop, PhaseContext context, CanonicalizerPhase canonicalizer) {
    // assert loop.isCounted(); //TODO (gd) strengthen : counted with known trip count
    LoopBeginNode loopBegin = loop.loopBegin();
    StructuredGraph graph = loopBegin.graph();
    int initialNodeCount = graph.getNodeCount();
    while (!loopBegin.isDeleted()) {
        Mark mark = graph.getMark();
        peel(loop);
        canonicalizer.applyIncremental(graph, context, mark);
        loop.invalidateFragments();
        if (graph.getNodeCount() > initialNodeCount + MaximumDesiredSize.getValue(graph.getOptions()) * 2) {
            throw new RetryableBailoutException("FullUnroll : Graph seems to grow out of proportion");
        }
    }
}
Also used : LoopBeginNode(org.graalvm.compiler.nodes.LoopBeginNode) RetryableBailoutException(org.graalvm.compiler.core.common.RetryableBailoutException) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) Mark(org.graalvm.compiler.graph.Graph.Mark)

Aggregations

RetryableBailoutException (org.graalvm.compiler.core.common.RetryableBailoutException)3 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)2 ArrayDeque (java.util.ArrayDeque)1 PermanentBailoutException (org.graalvm.compiler.core.common.PermanentBailoutException)1 CompilationAlarm (org.graalvm.compiler.core.common.util.CompilationAlarm)1 Mark (org.graalvm.compiler.graph.Graph.Mark)1 NodeEventScope (org.graalvm.compiler.graph.Graph.NodeEventScope)1 Node (org.graalvm.compiler.graph.Node)1 Simplifiable (org.graalvm.compiler.graph.spi.Simplifiable)1 AbstractEndNode (org.graalvm.compiler.nodes.AbstractEndNode)1 AbstractMergeNode (org.graalvm.compiler.nodes.AbstractMergeNode)1 FixedNode (org.graalvm.compiler.nodes.FixedNode)1 LoopBeginNode (org.graalvm.compiler.nodes.LoopBeginNode)1 Block (org.graalvm.compiler.nodes.cfg.Block)1 HashSetNodeEventListener (org.graalvm.compiler.phases.common.util.HashSetNodeEventListener)1