Search in sources :

Example 51 with LoopBeginNode

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

the class DefaultLoopPolicies method shouldTryUnswitch.

@Override
public boolean shouldTryUnswitch(LoopEx loop) {
    LoopBeginNode loopBegin = loop.loopBegin();
    double loopFrequency = loopBegin.loopFrequency();
    if (loopFrequency <= 1.0) {
        return false;
    }
    OptionValues options = loop.entryPoint().getOptions();
    return loopBegin.unswitches() <= LoopMaxUnswitch.getValue(options);
}
Also used : LoopBeginNode(org.graalvm.compiler.nodes.LoopBeginNode) OptionValues(org.graalvm.compiler.options.OptionValues)

Example 52 with LoopBeginNode

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

the class MonitorDeoptTest method removeLoopSafepoint.

/**
 * Remove the safepoint from the first loop in the test method, so only the safepoints on
 * MonitorEnter and MonitorExit remain in the loop. That way, we can make sure it deopts inside
 * the MonitorEnter by invalidating the code while holding the lock.
 */
private static void removeLoopSafepoint(StructuredGraph graph) {
    LoopBeginNode loopBegin = findFirstLoop(graph);
    loopBegin.disableSafepoint();
}
Also used : LoopBeginNode(org.graalvm.compiler.nodes.LoopBeginNode)

Example 53 with LoopBeginNode

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

the class ComputeInliningRelevance method createLoopScope.

/**
 * Determines the parent of the given loop and creates a {@link Scope} object for each one. This
 * method will call itself recursively if no {@link Scope} for the parent loop exists.
 */
private Scope createLoopScope(LoopBeginNode loopBegin, EconomicMap<LoopBeginNode, Scope> loops, Scope topScope) {
    Scope scope = loops.get(loopBegin);
    if (scope == null) {
        final Scope parent;
        // look for the parent scope
        FixedNode current = loopBegin.forwardEnd();
        while (true) {
            if (current.predecessor() == null) {
                if (current instanceof LoopBeginNode) {
                    // if we reach a LoopBeginNode then we're within this loop
                    parent = createLoopScope((LoopBeginNode) current, loops, topScope);
                    break;
                } else if (current instanceof StartNode) {
                    // we're within the outermost scope
                    parent = topScope;
                    break;
                } else {
                    assert current instanceof MergeNode : current;
                    // follow any path upwards - it doesn't matter which one
                    current = ((AbstractMergeNode) current).forwardEndAt(0);
                }
            } else if (current instanceof LoopExitNode) {
                // if we reach a loop exit then we follow this loop and have the same parent
                parent = createLoopScope(((LoopExitNode) current).loopBegin(), loops, topScope).parent;
                break;
            } else {
                current = (FixedNode) current.predecessor();
            }
        }
        scope = new Scope(loopBegin, parent);
        loops.put(loopBegin, scope);
    }
    return scope;
}
Also used : AbstractMergeNode(org.graalvm.compiler.nodes.AbstractMergeNode) MergeNode(org.graalvm.compiler.nodes.MergeNode) StartNode(org.graalvm.compiler.nodes.StartNode) LoopBeginNode(org.graalvm.compiler.nodes.LoopBeginNode) LoopExitNode(org.graalvm.compiler.nodes.LoopExitNode) FixedNode(org.graalvm.compiler.nodes.FixedNode) AbstractMergeNode(org.graalvm.compiler.nodes.AbstractMergeNode)

Example 54 with LoopBeginNode

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

the class InliningIterator method apply.

public LinkedList<Invoke> apply() {
    LinkedList<Invoke> invokes = new LinkedList<>();
    FixedNode current;
    forcedQueue(start);
    while ((current = nextQueuedNode()) != null) {
        assert current.isAlive();
        if (current instanceof Invoke && ((Invoke) current).callTarget() instanceof MethodCallTargetNode) {
            if (current != start) {
                invokes.addLast((Invoke) current);
            }
            queueSuccessors(current);
        } else if (current instanceof LoopBeginNode) {
            queueSuccessors(current);
        } else if (current instanceof LoopEndNode) {
        // nothing to do
        } else if (current instanceof AbstractMergeNode) {
            queueSuccessors(current);
        } else if (current instanceof FixedWithNextNode) {
            queueSuccessors(current);
        } else if (current instanceof EndNode) {
            queueMerge((EndNode) current);
        } else if (current instanceof ControlSinkNode) {
        // nothing to do
        } else if (current instanceof ControlSplitNode) {
            queueSuccessors(current);
        } else {
            assert false : current;
        }
    }
    assert invokes.size() == count(start.graph().getInvokes());
    return invokes;
}
Also used : FixedWithNextNode(org.graalvm.compiler.nodes.FixedWithNextNode) LoopBeginNode(org.graalvm.compiler.nodes.LoopBeginNode) MethodCallTargetNode(org.graalvm.compiler.nodes.java.MethodCallTargetNode) AbstractEndNode(org.graalvm.compiler.nodes.AbstractEndNode) LoopEndNode(org.graalvm.compiler.nodes.LoopEndNode) EndNode(org.graalvm.compiler.nodes.EndNode) ControlSplitNode(org.graalvm.compiler.nodes.ControlSplitNode) FixedNode(org.graalvm.compiler.nodes.FixedNode) AbstractMergeNode(org.graalvm.compiler.nodes.AbstractMergeNode) ControlSinkNode(org.graalvm.compiler.nodes.ControlSinkNode) LinkedList(java.util.LinkedList) Invoke(org.graalvm.compiler.nodes.Invoke) LoopEndNode(org.graalvm.compiler.nodes.LoopEndNode)

Example 55 with LoopBeginNode

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

the class ReentrantBlockIterator method recurseIntoLoop.

private static <StateT> void recurseIntoLoop(BlockIteratorClosure<StateT> closure, Deque<Block> blockQueue, EconomicMap<FixedNode, StateT> states, StateT state, Block successor) {
    // recurse into the loop
    Loop<Block> loop = successor.getLoop();
    LoopBeginNode loopBegin = (LoopBeginNode) loop.getHeader().getBeginNode();
    assert successor.getBeginNode() == loopBegin;
    List<StateT> exitStates = closure.processLoop(loop, state);
    int i = 0;
    assert loop.getExits().size() == exitStates.size();
    for (Block exit : loop.getExits()) {
        states.put(exit.getBeginNode(), exitStates.get(i++));
        blockQueue.addFirst(exit);
    }
}
Also used : LoopBeginNode(org.graalvm.compiler.nodes.LoopBeginNode) Block(org.graalvm.compiler.nodes.cfg.Block)

Aggregations

LoopBeginNode (org.graalvm.compiler.nodes.LoopBeginNode)61 FixedNode (org.graalvm.compiler.nodes.FixedNode)30 AbstractMergeNode (org.graalvm.compiler.nodes.AbstractMergeNode)26 LoopExitNode (org.graalvm.compiler.nodes.LoopExitNode)24 LoopEndNode (org.graalvm.compiler.nodes.LoopEndNode)23 AbstractBeginNode (org.graalvm.compiler.nodes.AbstractBeginNode)22 Node (org.graalvm.compiler.graph.Node)21 FixedWithNextNode (org.graalvm.compiler.nodes.FixedWithNextNode)21 EndNode (org.graalvm.compiler.nodes.EndNode)20 PhiNode (org.graalvm.compiler.nodes.PhiNode)20 ValueNode (org.graalvm.compiler.nodes.ValueNode)20 AbstractEndNode (org.graalvm.compiler.nodes.AbstractEndNode)19 ControlSplitNode (org.graalvm.compiler.nodes.ControlSplitNode)14 ConstantNode (org.graalvm.compiler.nodes.ConstantNode)13 MergeNode (org.graalvm.compiler.nodes.MergeNode)11 ProxyNode (org.graalvm.compiler.nodes.ProxyNode)10 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)10 ArrayList (java.util.ArrayList)9 IfNode (org.graalvm.compiler.nodes.IfNode)9 LogicNode (org.graalvm.compiler.nodes.LogicNode)9