Search in sources :

Example 1 with WriteBarrierAdditionPhase

use of org.graalvm.compiler.phases.common.WriteBarrierAdditionPhase in project graal by oracle.

the class DeferredBarrierAdditionTest method testHelper.

@SuppressWarnings("try")
protected void testHelper(final String snippetName, final int expectedBarriers, OptionValues options) {
    ResolvedJavaMethod snippet = getResolvedJavaMethod(snippetName);
    DebugContext debug = getDebugContext(options, null, snippet);
    try (DebugContext.Scope s = debug.scope("WriteBarrierAdditionTest", snippet)) {
        StructuredGraph graph = parseEager(snippet, AllowAssumptions.NO, debug);
        HighTierContext highContext = getDefaultHighTierContext();
        MidTierContext midContext = new MidTierContext(getProviders(), getTargetProvider(), OptimisticOptimizations.ALL, graph.getProfilingInfo());
        new InliningPhase(new InlineEverythingPolicy(), createCanonicalizerPhase()).apply(graph, highContext);
        this.createCanonicalizerPhase().apply(graph, highContext);
        new PartialEscapePhase(false, createCanonicalizerPhase(), debug.getOptions()).apply(graph, highContext);
        new LoweringPhase(createCanonicalizerPhase(), LoweringTool.StandardLoweringStage.HIGH_TIER).apply(graph, highContext);
        new GuardLoweringPhase().apply(graph, midContext);
        new LoweringPhase(createCanonicalizerPhase(), LoweringTool.StandardLoweringStage.MID_TIER).apply(graph, midContext);
        new WriteBarrierAdditionPhase().apply(graph, midContext);
        debug.dump(DebugContext.BASIC_LEVEL, graph, "After Write Barrier Addition");
        checkAssumptions(graph);
        int barriers = 0;
        if (config.useG1GC) {
            barriers = graph.getNodes().filter(G1ReferentFieldReadBarrier.class).count() + graph.getNodes().filter(G1PreWriteBarrier.class).count() + graph.getNodes().filter(G1PostWriteBarrier.class).count();
        } else {
            barriers = graph.getNodes().filter(SerialWriteBarrier.class).count();
        }
        if (expectedBarriers != barriers) {
            Assert.assertEquals(getScheduledGraphString(graph), expectedBarriers, barriers);
        }
    } catch (Throwable e) {
        throw debug.handle(e);
    }
}
Also used : PartialEscapePhase(org.graalvm.compiler.virtual.phases.ea.PartialEscapePhase) InlineEverythingPolicy(org.graalvm.compiler.phases.common.inlining.policy.InlineEverythingPolicy) GuardLoweringPhase(org.graalvm.compiler.phases.common.GuardLoweringPhase) LoweringPhase(org.graalvm.compiler.phases.common.LoweringPhase) WriteBarrierAdditionPhase(org.graalvm.compiler.phases.common.WriteBarrierAdditionPhase) DebugContext(org.graalvm.compiler.debug.DebugContext) MidTierContext(org.graalvm.compiler.phases.tiers.MidTierContext) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) HighTierContext(org.graalvm.compiler.phases.tiers.HighTierContext) G1PostWriteBarrier(org.graalvm.compiler.nodes.gc.G1PostWriteBarrier) InliningPhase(org.graalvm.compiler.phases.common.inlining.InliningPhase) GuardLoweringPhase(org.graalvm.compiler.phases.common.GuardLoweringPhase) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Aggregations

ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)1 DebugContext (org.graalvm.compiler.debug.DebugContext)1 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)1 G1PostWriteBarrier (org.graalvm.compiler.nodes.gc.G1PostWriteBarrier)1 GuardLoweringPhase (org.graalvm.compiler.phases.common.GuardLoweringPhase)1 LoweringPhase (org.graalvm.compiler.phases.common.LoweringPhase)1 WriteBarrierAdditionPhase (org.graalvm.compiler.phases.common.WriteBarrierAdditionPhase)1 InliningPhase (org.graalvm.compiler.phases.common.inlining.InliningPhase)1 InlineEverythingPolicy (org.graalvm.compiler.phases.common.inlining.policy.InlineEverythingPolicy)1 HighTierContext (org.graalvm.compiler.phases.tiers.HighTierContext)1 MidTierContext (org.graalvm.compiler.phases.tiers.MidTierContext)1 PartialEscapePhase (org.graalvm.compiler.virtual.phases.ea.PartialEscapePhase)1