use of org.graalvm.compiler.nodes.loop.LoopsData in project graal by oracle.
the class ReferenceGetLoopTest method checkMidTierGraph.
@Override
protected void checkMidTierGraph(StructuredGraph graph) {
final LoopsData loops = getDefaultMidTierContext().getLoopsDataProvider().getLoopsData(graph);
boolean found = false;
for (LoopEx loop : loops.loops()) {
for (Node node : loop.inside().nodes()) {
if (node instanceof MemoryAccess) {
MemoryAccess access = (MemoryAccess) node;
LocationIdentity location = access.getLocationIdentity();
if (location instanceof FieldLocationIdentity) {
ResolvedJavaField field = ((FieldLocationIdentity) location).getField();
if (field.getName().equals("referent") && field.getDeclaringClass().equals(getMetaAccess().lookupJavaType(Reference.class))) {
found = true;
}
}
}
}
}
if (!found) {
assertTrue(false, "Reference.referent not found in loop: " + getCanonicalGraphString(graph, true, false));
}
}
use of org.graalvm.compiler.nodes.loop.LoopsData in project graal by oracle.
the class OnStackReplacementPhase method osrLoop.
private static LoopBeginNode osrLoop(EntryMarkerNode osr, CoreProviders providers) {
// Check that there is an OSR loop for the OSR begin
LoopsData loops = providers.getLoopsDataProvider().getLoopsData(osr.graph());
Loop<Block> l = loops.getCFG().getNodeToBlock().get(osr).getLoop();
if (l == null) {
return null;
}
return (LoopBeginNode) l.getHeader().getBeginNode();
}
use of org.graalvm.compiler.nodes.loop.LoopsData in project graal by oracle.
the class LoopsDataTest method testouterFirst.
@Test
public void testouterFirst() {
LoopsData loops = getLoopsData();
Set<LoopEx> seen = new HashSet<>();
for (LoopEx loop : loops.outerFirst()) {
assertFalse(seen.contains(loop), "%s has already been seen", loop);
if (loop.parent() != null) {
assertTrue(seen.contains(loop.parent()), "%s's parent (%s) should have already been seen", loop, loop.parent());
}
seen.add(loop);
}
}
use of org.graalvm.compiler.nodes.loop.LoopsData in project graal by oracle.
the class LoopFullUnrollPhase method run.
@Override
protected void run(StructuredGraph graph, CoreProviders context) {
if (GraalOptions.FullUnroll.getValue(graph.getOptions())) {
DebugContext debug = graph.getDebug();
if (graph.hasLoops()) {
boolean peeled;
int applications = 0;
do {
peeled = false;
final LoopsData dataCounted = context.getLoopsDataProvider().getLoopsData(graph);
dataCounted.detectedCountedLoops();
List<LoopEx> countedLoops = dataCounted.countedLoops();
countedLoops.sort(LOOP_COMPARATOR);
for (LoopEx loop : countedLoops) {
if (getPolicies().shouldFullUnroll(loop)) {
debug.log("FullUnroll %s", loop);
LoopTransformations.fullUnroll(loop, context, canonicalizer);
FULLY_UNROLLED_LOOPS.increment(debug);
debug.dump(DebugContext.DETAILED_LEVEL, graph, "FullUnroll %s", loop);
peeled = true;
break;
}
}
dataCounted.deleteUnusedNodes();
applications++;
} while (peeled && applications < Options.FullUnrollMaxApplication.getValue(graph.getOptions()));
}
}
}
use of org.graalvm.compiler.nodes.loop.LoopsData in project graal by oracle.
the class LoopPeelingPhase method run.
@Override
@SuppressWarnings("try")
protected void run(StructuredGraph graph, CoreProviders context) {
DebugContext debug = graph.getDebug();
if (graph.hasLoops()) {
LoopsData data = context.getLoopsDataProvider().getLoopsData(graph);
try (DebugContext.Scope s = debug.scope("peeling", data.getCFG())) {
for (LoopEx loop : data.outerFirst()) {
if (canPeel(loop)) {
if (LoopPolicies.Options.PeelALot.getValue(graph.getOptions()) || getPolicies().shouldPeel(loop, data.getCFG(), context)) {
debug.log("Peeling %s", loop);
PEELED.increment(debug);
LoopTransformations.peel(loop);
debug.dump(DebugContext.DETAILED_LEVEL, graph, "Peeling %s", loop);
}
}
}
data.deleteUnusedNodes();
} catch (Throwable t) {
throw debug.handle(t);
}
}
}
Aggregations