Search in sources :

Example 1 with GraphBuilderPhase

use of org.graalvm.compiler.java.GraphBuilderPhase in project graal by oracle.

the class HotSpotGraalCompiler method configGraphBuilderSuite.

/**
 * Reconfigures a given graph builder suite (GBS) if one of the given GBS parameter values is
 * not the default.
 *
 * @param suite the graph builder suite
 * @param shouldDebugNonSafepoints specifies if extra debug info should be generated (default is
 *            false)
 * @param isOSR specifies if extra OSR-specific post-processing is required (default is false)
 * @return a new suite derived from {@code suite} if any of the GBS parameters did not have a
 *         default value otherwise {@code suite}
 */
protected PhaseSuite<HighTierContext> configGraphBuilderSuite(PhaseSuite<HighTierContext> suite, boolean shouldDebugNonSafepoints, boolean isOSR) {
    if (shouldDebugNonSafepoints || isOSR) {
        PhaseSuite<HighTierContext> newGbs = suite.copy();
        if (shouldDebugNonSafepoints) {
            GraphBuilderPhase graphBuilderPhase = (GraphBuilderPhase) newGbs.findPhase(GraphBuilderPhase.class).previous();
            GraphBuilderConfiguration graphBuilderConfig = graphBuilderPhase.getGraphBuilderConfig();
            graphBuilderConfig = graphBuilderConfig.withNodeSourcePosition(true);
            GraphBuilderPhase newGraphBuilderPhase = new GraphBuilderPhase(graphBuilderConfig);
            newGbs.findPhase(GraphBuilderPhase.class).set(newGraphBuilderPhase);
        }
        if (isOSR) {
            // We must not clear non liveness for OSR compilations.
            GraphBuilderPhase graphBuilderPhase = (GraphBuilderPhase) newGbs.findPhase(GraphBuilderPhase.class).previous();
            GraphBuilderConfiguration graphBuilderConfig = graphBuilderPhase.getGraphBuilderConfig();
            GraphBuilderPhase newGraphBuilderPhase = new GraphBuilderPhase(graphBuilderConfig);
            newGbs.findPhase(GraphBuilderPhase.class).set(newGraphBuilderPhase);
            newGbs.appendPhase(new OnStackReplacementPhase());
        }
        return newGbs;
    }
    return suite;
}
Also used : GraphBuilderConfiguration(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration) HighTierContext(org.graalvm.compiler.phases.tiers.HighTierContext) GraphBuilderPhase(org.graalvm.compiler.java.GraphBuilderPhase) OnStackReplacementPhase(org.graalvm.compiler.hotspot.phases.OnStackReplacementPhase)

Example 2 with GraphBuilderPhase

use of org.graalvm.compiler.java.GraphBuilderPhase in project graal by oracle.

the class HotSpotTruffleCompilerImpl method create.

public static HotSpotTruffleCompilerImpl create(TruffleCompilerRuntime runtime) {
    HotSpotGraalRuntimeProvider hotspotGraalRuntime = (HotSpotGraalRuntimeProvider) runtime.getGraalRuntime();
    Backend backend = hotspotGraalRuntime.getHostBackend();
    OptionValues options = TruffleCompilerOptions.getOptions();
    Suites suites = backend.getSuites().getDefaultSuites(options);
    LIRSuites lirSuites = backend.getSuites().getDefaultLIRSuites(options);
    GraphBuilderPhase phase = (GraphBuilderPhase) backend.getSuites().getDefaultGraphBuilderSuite().findPhase(GraphBuilderPhase.class).previous();
    Plugins plugins = phase.getGraphBuilderConfig().getPlugins();
    SnippetReflectionProvider snippetReflection = hotspotGraalRuntime.getRequiredCapability(SnippetReflectionProvider.class);
    return new HotSpotTruffleCompilerImpl(hotspotGraalRuntime, runtime, plugins, suites, lirSuites, backend, snippetReflection);
}
Also used : Backend(org.graalvm.compiler.core.target.Backend) SnippetReflectionProvider(org.graalvm.compiler.api.replacements.SnippetReflectionProvider) OptionValues(org.graalvm.compiler.options.OptionValues) LIRSuites(org.graalvm.compiler.lir.phases.LIRSuites) HotSpotGraalRuntimeProvider(org.graalvm.compiler.hotspot.HotSpotGraalRuntimeProvider) GraphBuilderPhase(org.graalvm.compiler.java.GraphBuilderPhase) LIRSuites(org.graalvm.compiler.lir.phases.LIRSuites) Suites(org.graalvm.compiler.phases.tiers.Suites) InvocationPlugins(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins) Plugins(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins)

Example 3 with GraphBuilderPhase

use of org.graalvm.compiler.java.GraphBuilderPhase in project graal by oracle.

the class VerifyDebugUsageTest method testDebugUsageClass.

@SuppressWarnings("try")
private static void testDebugUsageClass(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 VerifyDebugUsage().apply(graph, context);
            }
        }
    }
}
Also used : InvocationPlugins(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins) OptionValues(org.graalvm.compiler.options.OptionValues) 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) VerifyDebugUsage(org.graalvm.compiler.phases.verify.VerifyDebugUsage) 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)

Example 4 with GraphBuilderPhase

use of org.graalvm.compiler.java.GraphBuilderPhase in project graal by oracle.

the class VerifyVirtualizableTest method testVirtualizableEffects.

@SuppressWarnings("try")
private static void testVirtualizableEffects(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 VerifyVirtualizableUsage().apply(graph, context);
            }
        }
    }
}
Also used : InvocationPlugins(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins) OptionValues(org.graalvm.compiler.options.OptionValues) 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) VerifyVirtualizableUsage(org.graalvm.compiler.phases.verify.VerifyVirtualizableUsage) 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)

Example 5 with GraphBuilderPhase

use of org.graalvm.compiler.java.GraphBuilderPhase in project graal by oracle.

the class GraalCompilerTest method getCustomGraphBuilderSuite.

protected PhaseSuite<HighTierContext> getCustomGraphBuilderSuite(GraphBuilderConfiguration gbConf) {
    PhaseSuite<HighTierContext> suite = getDefaultGraphBuilderSuite();
    ListIterator<BasePhase<? super HighTierContext>> iterator = suite.findPhase(GraphBuilderPhase.class);
    initializeInvocationPluginExtensions();
    GraphBuilderConfiguration gbConfCopy = editGraphBuilderConfiguration(gbConf.copy());
    iterator.remove();
    iterator.add(new GraphBuilderPhase(gbConfCopy));
    return suite;
}
Also used : GraphBuilderConfiguration(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration) HighTierContext(org.graalvm.compiler.phases.tiers.HighTierContext) GraphBuilderPhase(org.graalvm.compiler.java.GraphBuilderPhase) BasePhase(org.graalvm.compiler.phases.BasePhase)

Aggregations

GraphBuilderPhase (org.graalvm.compiler.java.GraphBuilderPhase)12 HighTierContext (org.graalvm.compiler.phases.tiers.HighTierContext)10 Plugins (org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins)9 InvocationPlugins (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins)9 GraphBuilderConfiguration (org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration)8 Method (java.lang.reflect.Method)6 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)6 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)6 OptionValues (org.graalvm.compiler.options.OptionValues)6 PhaseSuite (org.graalvm.compiler.phases.PhaseSuite)6 MetaAccessProvider (jdk.vm.ci.meta.MetaAccessProvider)5 DebugCloseable (org.graalvm.compiler.debug.DebugCloseable)5 DebugContext (org.graalvm.compiler.debug.DebugContext)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