Search in sources :

Example 1 with LoopsData

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));
    }
}
Also used : FieldLocationIdentity(org.graalvm.compiler.nodes.FieldLocationIdentity) LoopsData(org.graalvm.compiler.nodes.loop.LoopsData) LoopEx(org.graalvm.compiler.nodes.loop.LoopEx) Node(org.graalvm.compiler.graph.Node) FieldLocationIdentity(org.graalvm.compiler.nodes.FieldLocationIdentity) LocationIdentity(org.graalvm.word.LocationIdentity) MemoryAccess(org.graalvm.compiler.nodes.memory.MemoryAccess) ResolvedJavaField(jdk.vm.ci.meta.ResolvedJavaField)

Example 2 with LoopsData

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();
}
Also used : LoopsData(org.graalvm.compiler.nodes.loop.LoopsData) LoopBeginNode(org.graalvm.compiler.nodes.LoopBeginNode) Block(org.graalvm.compiler.nodes.cfg.Block)

Example 3 with LoopsData

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);
    }
}
Also used : LoopsData(org.graalvm.compiler.nodes.loop.LoopsData) LoopEx(org.graalvm.compiler.nodes.loop.LoopEx) HashSet(java.util.HashSet) Test(org.junit.Test) GraalCompilerTest(org.graalvm.compiler.core.test.GraalCompilerTest)

Example 4 with LoopsData

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()));
        }
    }
}
Also used : LoopsData(org.graalvm.compiler.nodes.loop.LoopsData) LoopEx(org.graalvm.compiler.nodes.loop.LoopEx) DebugContext(org.graalvm.compiler.debug.DebugContext)

Example 5 with LoopsData

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);
        }
    }
}
Also used : LoopsData(org.graalvm.compiler.nodes.loop.LoopsData) LoopEx(org.graalvm.compiler.nodes.loop.LoopEx) DebugContext(org.graalvm.compiler.debug.DebugContext)

Aggregations

LoopsData (org.graalvm.compiler.nodes.loop.LoopsData)23 LoopEx (org.graalvm.compiler.nodes.loop.LoopEx)19 DebugContext (org.graalvm.compiler.debug.DebugContext)8 Block (org.graalvm.compiler.nodes.cfg.Block)5 Node (org.graalvm.compiler.graph.Node)4 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)4 GraalCompilerTest (org.graalvm.compiler.core.test.GraalCompilerTest)3 LoopBeginNode (org.graalvm.compiler.nodes.LoopBeginNode)3 ValueNode (org.graalvm.compiler.nodes.ValueNode)3 DeadCodeEliminationPhase (org.graalvm.compiler.phases.common.DeadCodeEliminationPhase)3 HashSet (java.util.HashSet)2 SpeculationLog (jdk.vm.ci.meta.SpeculationLog)2 DebugCloseable (org.graalvm.compiler.debug.DebugCloseable)2 FixedGuardNode (org.graalvm.compiler.nodes.FixedGuardNode)2 FixedNode (org.graalvm.compiler.nodes.FixedNode)2 FrameState (org.graalvm.compiler.nodes.FrameState)2 LogicNode (org.graalvm.compiler.nodes.LogicNode)2 LoopEndNode (org.graalvm.compiler.nodes.LoopEndNode)2 Test (org.junit.Test)2 BytecodePosition (jdk.vm.ci.code.BytecodePosition)1