Search in sources :

Example 6 with InvocationPlugins

use of org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins 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 7 with InvocationPlugins

use of org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins 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 8 with InvocationPlugins

use of org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins in project graal by oracle.

the class UnbalancedMonitorsTest method checkForBailout.

private void checkForBailout(String name) throws ClassNotFoundException {
    ResolvedJavaMethod method = getResolvedJavaMethod(LOADER.findClass(INNER_CLASS_NAME), name);
    try {
        OptionValues options = getInitialOptions();
        StructuredGraph graph = new StructuredGraph.Builder(options, getDebugContext(options, null, method)).method(method).build();
        Plugins plugins = new Plugins(new InvocationPlugins());
        GraphBuilderConfiguration graphBuilderConfig = GraphBuilderConfiguration.getDefault(plugins).withEagerResolving(true).withUnresolvedIsError(true);
        OptimisticOptimizations optimisticOpts = OptimisticOptimizations.NONE;
        GraphBuilderPhase.Instance graphBuilder = new GraphBuilderPhase.Instance(getMetaAccess(), getProviders().getStampProvider(), null, null, graphBuilderConfig, optimisticOpts, null);
        graphBuilder.apply(graph);
    } catch (BailoutException e) {
        if (e.getMessage().contains("unbalanced monitors")) {
            return;
        }
        throw e;
    }
    assertTrue("should have bailed out", false);
}
Also used : BailoutException(jdk.vm.ci.code.BailoutException) InvocationPlugins(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins) OptionValues(org.graalvm.compiler.options.OptionValues) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) GraphBuilderConfiguration(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration) OptimisticOptimizations(org.graalvm.compiler.phases.OptimisticOptimizations) GraphBuilderPhase(org.graalvm.compiler.java.GraphBuilderPhase) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod) InvocationPlugins(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins) Plugins(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins)

Example 9 with InvocationPlugins

use of org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins in project graal by oracle.

the class SubstrateReplacements method makeInvocationPlugins.

@Platforms(Platform.HOSTED_ONLY.class)
private static InvocationPlugins makeInvocationPlugins(GraphBuilderConfiguration.Plugins plugins, Builder builder, Function<Object, Object> objectReplacer) {
    Map<ResolvedJavaMethod, InvocationPlugin> result = new HashMap<>(builder.delayedInvocationPluginMethods.size());
    for (ResolvedJavaMethod method : builder.delayedInvocationPluginMethods) {
        ResolvedJavaMethod replacedMethod = (ResolvedJavaMethod) objectReplacer.apply(method);
        InvocationPlugin plugin = plugins.getInvocationPlugins().lookupInvocation(replacedMethod);
        assert plugin != null : "expected invocation plugin for " + replacedMethod;
        result.put(replacedMethod, plugin);
    }
    return new InvocationPlugins(result, null);
}
Also used : InvocationPlugins(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins) HashMap(java.util.HashMap) InvocationPlugin(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod) Platforms(org.graalvm.nativeimage.Platforms)

Example 10 with InvocationPlugins

use of org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins in project graal by oracle.

the class SPARCGraphBuilderPlugins method register.

public static void register(Plugins plugins, BytecodeProvider bytecodeProvider) {
    InvocationPlugins invocationPlugins = plugins.getInvocationPlugins();
    invocationPlugins.defer(new Runnable() {

        @Override
        public void run() {
            registerIntegerLongPlugins(invocationPlugins, IntegerSubstitutions.class, JavaKind.Int, bytecodeProvider);
            registerIntegerLongPlugins(invocationPlugins, LongSubstitutions.class, JavaKind.Long, bytecodeProvider);
            registerMathPlugins(invocationPlugins);
        }
    });
}
Also used : InvocationPlugins(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins) LongSubstitutions(org.graalvm.compiler.replacements.LongSubstitutions) IntegerSubstitutions(org.graalvm.compiler.replacements.IntegerSubstitutions)

Aggregations

InvocationPlugins (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins)23 Plugins (org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins)13 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)12 GraphBuilderPhase (org.graalvm.compiler.java.GraphBuilderPhase)9 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)9 GraphBuilderConfiguration (org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration)9 OptionValues (org.graalvm.compiler.options.OptionValues)9 HighTierContext (org.graalvm.compiler.phases.tiers.HighTierContext)7 RuntimeProvider (org.graalvm.compiler.runtime.RuntimeProvider)7 Method (java.lang.reflect.Method)6 MetaAccessProvider (jdk.vm.ci.meta.MetaAccessProvider)6 DebugContext (org.graalvm.compiler.debug.DebugContext)6 PhaseSuite (org.graalvm.compiler.phases.PhaseSuite)6 Providers (org.graalvm.compiler.phases.util.Providers)6 DebugCloseable (org.graalvm.compiler.debug.DebugCloseable)5 InvocationPlugin (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin)5 ArrayList (java.util.ArrayList)2 List (java.util.List)2 BailoutException (jdk.vm.ci.code.BailoutException)2 HotSpotVMConfigStore (jdk.vm.ci.hotspot.HotSpotVMConfigStore)2