Search in sources :

Example 1 with EarlyReadEliminationPhase

use of org.graalvm.compiler.virtual.phases.ea.EarlyReadEliminationPhase in project graal by oracle.

the class NestedLoopEffectsPhaseComplexityTest method testAndTime.

private void testAndTime(String snippet) {
    for (int i = InliningCountLowerBound; i < InliningCountUpperBound; i++) {
        StructuredGraph g1 = prepareGraph(snippet, i);
        StructuredGraph g2 = (StructuredGraph) g1.copy(g1.getDebug());
        ResolvedJavaMethod method = g1.method();
        long elapsedRE = runAndTimePhase(g1, new EarlyReadEliminationPhase(new CanonicalizerPhase()));
        long elapsedPEA = runAndTimePhase(g2, new PartialEscapePhase(true, new CanonicalizerPhase(), g1.getOptions()));
        if (LOG_PHASE_TIMINGS) {
            TTY.printf("Needed %dms to run early partial escape analysis on a graph with %d nested loops compiling method %s\n", elapsedPEA, i, method);
        }
        if (LOG_PHASE_TIMINGS) {
            TTY.printf("Needed %dms to run early read elimination on a graph with %d nested loops compiling method %s\n", elapsedRE, i, method);
        }
    }
}
Also used : PartialEscapePhase(org.graalvm.compiler.virtual.phases.ea.PartialEscapePhase) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod) EarlyReadEliminationPhase(org.graalvm.compiler.virtual.phases.ea.EarlyReadEliminationPhase)

Example 2 with EarlyReadEliminationPhase

use of org.graalvm.compiler.virtual.phases.ea.EarlyReadEliminationPhase in project graal by oracle.

the class EarlyReadEliminationTest method processMethod.

protected StructuredGraph processMethod(String snippet, boolean doLowering) {
    StructuredGraph graph = parseEager(getResolvedJavaMethod(snippet), AllowAssumptions.NO);
    HighTierContext context = getDefaultHighTierContext();
    new InliningPhase(new CanonicalizerPhase()).apply(graph, context);
    if (doLowering) {
        new LoweringPhase(new CanonicalizerPhase(), LoweringTool.StandardLoweringStage.HIGH_TIER).apply(graph, context);
    }
    new EarlyReadEliminationPhase(new CanonicalizerPhase()).apply(graph, context);
    return graph;
}
Also used : StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) LoweringPhase(org.graalvm.compiler.phases.common.LoweringPhase) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase) HighTierContext(org.graalvm.compiler.phases.tiers.HighTierContext) InliningPhase(org.graalvm.compiler.phases.common.inlining.InliningPhase) EarlyReadEliminationPhase(org.graalvm.compiler.virtual.phases.ea.EarlyReadEliminationPhase)

Example 3 with EarlyReadEliminationPhase

use of org.graalvm.compiler.virtual.phases.ea.EarlyReadEliminationPhase in project graal by oracle.

the class UnsafeReadEliminationTest method testEarlyReadElimination.

public void testEarlyReadElimination(StructuredGraph graph, int reads, int writes) {
    PhaseContext context = getDefaultHighTierContext();
    CanonicalizerPhase canonicalizer = new CanonicalizerPhase();
    canonicalizer.apply(graph, context);
    new EarlyReadEliminationPhase(canonicalizer).apply(graph, context);
    Assert.assertEquals(3, graph.getNodes().filter(UnsafeAccessNode.class).count());
    // after lowering the same applies for reads and writes
    new LoweringPhase(canonicalizer, LoweringTool.StandardLoweringStage.HIGH_TIER).apply(graph, context);
    canonicalizer.apply(graph, context);
    new EarlyReadEliminationPhase(canonicalizer).apply(graph, context);
    Assert.assertEquals(reads, graph.getNodes().filter(ReadNode.class).count());
    Assert.assertEquals(writes, graph.getNodes().filter(WriteNode.class).count());
}
Also used : PhaseContext(org.graalvm.compiler.phases.tiers.PhaseContext) LoweringPhase(org.graalvm.compiler.phases.common.LoweringPhase) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase) EarlyReadEliminationPhase(org.graalvm.compiler.virtual.phases.ea.EarlyReadEliminationPhase)

Aggregations

CanonicalizerPhase (org.graalvm.compiler.phases.common.CanonicalizerPhase)3 EarlyReadEliminationPhase (org.graalvm.compiler.virtual.phases.ea.EarlyReadEliminationPhase)3 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)2 LoweringPhase (org.graalvm.compiler.phases.common.LoweringPhase)2 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)1 InliningPhase (org.graalvm.compiler.phases.common.inlining.InliningPhase)1 HighTierContext (org.graalvm.compiler.phases.tiers.HighTierContext)1 PhaseContext (org.graalvm.compiler.phases.tiers.PhaseContext)1 PartialEscapePhase (org.graalvm.compiler.virtual.phases.ea.PartialEscapePhase)1