Search in sources :

Example 1 with Phase

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

the class GraalCompilerTest method createSuites.

protected Suites createSuites(OptionValues opts) {
    Suites ret = backend.getSuites().getDefaultSuites(opts).copy();
    ListIterator<BasePhase<? super HighTierContext>> iter = ret.getHighTier().findPhase(ConvertDeoptimizeToGuardPhase.class, true);
    if (iter == null) {
        /*
             * in the economy configuration, we don't have the ConvertDeoptimizeToGuard phase, so we
             * just select the first CanonicalizerPhase in HighTier
             */
        iter = ret.getHighTier().findPhase(CanonicalizerPhase.class);
    }
    iter.add(new Phase() {

        @Override
        protected void run(StructuredGraph graph) {
            ComputeLoopFrequenciesClosure.compute(graph);
        }

        @Override
        public float codeSizeIncrease() {
            return NodeSize.IGNORE_SIZE_CONTRACT_FACTOR;
        }

        @Override
        protected CharSequence getName() {
            return "ComputeLoopFrequenciesPhase";
        }
    });
    ret.getHighTier().appendPhase(new Phase() {

        @Override
        protected void run(StructuredGraph graph) {
            assert checkHighTierGraph(graph) : "failed HighTier graph check";
        }

        @Override
        public float codeSizeIncrease() {
            return NodeSize.IGNORE_SIZE_CONTRACT_FACTOR;
        }

        @Override
        protected CharSequence getName() {
            return "CheckGraphPhase";
        }
    });
    ret.getMidTier().appendPhase(new Phase() {

        @Override
        protected void run(StructuredGraph graph) {
            assert checkMidTierGraph(graph) : "failed MidTier graph check";
        }

        @Override
        public float codeSizeIncrease() {
            return NodeSize.IGNORE_SIZE_CONTRACT_FACTOR;
        }

        @Override
        protected CharSequence getName() {
            return "CheckGraphPhase";
        }
    });
    ret.getLowTier().appendPhase(new Phase() {

        @Override
        protected void run(StructuredGraph graph) {
            assert checkLowTierGraph(graph) : "failed LowTier graph check";
        }

        @Override
        public float codeSizeIncrease() {
            return NodeSize.IGNORE_SIZE_CONTRACT_FACTOR;
        }

        @Override
        protected CharSequence getName() {
            return "CheckGraphPhase";
        }
    });
    return ret;
}
Also used : BasePhase(org.graalvm.compiler.phases.BasePhase) SchedulePhase(org.graalvm.compiler.phases.schedule.SchedulePhase) GraphBuilderPhase(org.graalvm.compiler.java.GraphBuilderPhase) Phase(org.graalvm.compiler.phases.Phase) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase) ConvertDeoptimizeToGuardPhase(org.graalvm.compiler.phases.common.ConvertDeoptimizeToGuardPhase) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase) HighTierContext(org.graalvm.compiler.phases.tiers.HighTierContext) BasePhase(org.graalvm.compiler.phases.BasePhase) LIRSuites(org.graalvm.compiler.lir.phases.LIRSuites) Suites(org.graalvm.compiler.phases.tiers.Suites)

Example 2 with Phase

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

the class EnumSwitchTest method createSuites.

@Override
protected Suites createSuites(OptionValues options) {
    Suites ret = super.createSuites(options);
    ret.getHighTier().prependPhase(new Phase() {

        @Override
        protected void run(StructuredGraph graph) {
            /* Array load from the enum switch map. */
            assertTrue(graph.getNodes().filter(LoadIndexedNode.class).count() == 1);
            /* The actual switch. */
            assertTrue(graph.getNodes().filter(IntegerSwitchNode.class).count() == 1);
        }

        @Override
        protected CharSequence getName() {
            return "CheckGraphPhase";
        }
    });
    ret.getHighTier().findPhase(RemoveValueProxyPhase.class).add(new Phase() {

        @Override
        protected void run(StructuredGraph graph) {
            /* Re-writing of the switch cases eliminates the array load. */
            assertTrue(graph.getNodes().filter(LoadIndexedNode.class).count() == 0);
            /* The switch is still there. */
            assertTrue(graph.getNodes().filter(IntegerSwitchNode.class).count() == 1);
        }

        @Override
        protected CharSequence getName() {
            return "CheckGraphPhase";
        }
    });
    return ret;
}
Also used : Phase(org.graalvm.compiler.phases.Phase) RemoveValueProxyPhase(org.graalvm.compiler.phases.common.RemoveValueProxyPhase) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) RemoveValueProxyPhase(org.graalvm.compiler.phases.common.RemoveValueProxyPhase) Suites(org.graalvm.compiler.phases.tiers.Suites)

Aggregations

StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)2 Phase (org.graalvm.compiler.phases.Phase)2 Suites (org.graalvm.compiler.phases.tiers.Suites)2 GraphBuilderPhase (org.graalvm.compiler.java.GraphBuilderPhase)1 LIRSuites (org.graalvm.compiler.lir.phases.LIRSuites)1 BasePhase (org.graalvm.compiler.phases.BasePhase)1 CanonicalizerPhase (org.graalvm.compiler.phases.common.CanonicalizerPhase)1 ConvertDeoptimizeToGuardPhase (org.graalvm.compiler.phases.common.ConvertDeoptimizeToGuardPhase)1 RemoveValueProxyPhase (org.graalvm.compiler.phases.common.RemoveValueProxyPhase)1 SchedulePhase (org.graalvm.compiler.phases.schedule.SchedulePhase)1 HighTierContext (org.graalvm.compiler.phases.tiers.HighTierContext)1