Search in sources :

Example 6 with PhaseSuite

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

the class VerifyBailoutUsageTest method testBailoutUsage.

@SuppressWarnings("try")
private static void testBailoutUsage(Class<?> c) {
    RuntimeProvider rt = Graal.getRequiredCapability(RuntimeProvider.class);
    Providers providers = rt.getHostBackend().getProviders();
    MetaAccessProvider metaAccess = providers.getMetaAccess();
    PhaseSuite<HighTierContext> graphBuilderSuite = new PhaseSuite<>();
    Plugins plugins = new Plugins(new InvocationPlugins());
    GraphBuilderConfiguration config = GraphBuilderConfiguration.getDefault(plugins).withEagerResolving(true).withUnresolvedIsError(true);
    graphBuilderSuite.appendPhase(new GraphBuilderPhase(config));
    HighTierContext context = new HighTierContext(providers, graphBuilderSuite, OptimisticOptimizations.NONE);
    OptionValues options = getInitialOptions();
    DebugContext debug = DebugContext.create(options, DebugHandlersFactory.LOADER);
    for (Method m : c.getDeclaredMethods()) {
        if (!Modifier.isNative(m.getModifiers()) && !Modifier.isAbstract(m.getModifiers())) {
            ResolvedJavaMethod method = metaAccess.lookupJavaMethod(m);
            StructuredGraph graph = new StructuredGraph.Builder(options, debug).method(method).build();
            graphBuilderSuite.apply(graph, context);
            try (DebugCloseable s = debug.disableIntercept()) {
                new VerifyBailoutUsage().apply(graph, context);
            }
        }
    }
}
Also used : InvocationPlugins(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins) OptionValues(org.graalvm.compiler.options.OptionValues) VerifyBailoutUsage(org.graalvm.compiler.phases.verify.VerifyBailoutUsage) RuntimeProvider(org.graalvm.compiler.runtime.RuntimeProvider) GraphBuilderConfiguration(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration) DebugContext(org.graalvm.compiler.debug.DebugContext) Method(java.lang.reflect.Method) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod) Providers(org.graalvm.compiler.phases.util.Providers) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) HighTierContext(org.graalvm.compiler.phases.tiers.HighTierContext) DebugCloseable(org.graalvm.compiler.debug.DebugCloseable) PhaseSuite(org.graalvm.compiler.phases.PhaseSuite) GraphBuilderPhase(org.graalvm.compiler.java.GraphBuilderPhase) MetaAccessProvider(jdk.vm.ci.meta.MetaAccessProvider) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod) InvocationPlugins(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins) Plugins(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins)

Aggregations

GraphBuilderPhase (org.graalvm.compiler.java.GraphBuilderPhase)6 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)6 Plugins (org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins)6 InvocationPlugins (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins)6 PhaseSuite (org.graalvm.compiler.phases.PhaseSuite)6 HighTierContext (org.graalvm.compiler.phases.tiers.HighTierContext)6 Method (java.lang.reflect.Method)5 MetaAccessProvider (jdk.vm.ci.meta.MetaAccessProvider)5 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)5 DebugCloseable (org.graalvm.compiler.debug.DebugCloseable)5 DebugContext (org.graalvm.compiler.debug.DebugContext)5 GraphBuilderConfiguration (org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration)5 OptionValues (org.graalvm.compiler.options.OptionValues)5 Providers (org.graalvm.compiler.phases.util.Providers)5 RuntimeProvider (org.graalvm.compiler.runtime.RuntimeProvider)5 VerifyPhase (org.graalvm.compiler.phases.VerifyPhase)2 File (java.io.File)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 ThreadPoolExecutor (java.util.concurrent.ThreadPoolExecutor)1