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);
}
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();
}
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;
}
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;
}
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);
}
}
Aggregations