Search in sources :

Example 1 with InvocationPlugins

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

the class StubAVXTest method editGraphBuilderConfiguration.

@Override
protected GraphBuilderConfiguration editGraphBuilderConfiguration(GraphBuilderConfiguration conf) {
    InvocationPlugins invocationPlugins = conf.getPlugins().getInvocationPlugins();
    InvocationPlugins.Registration r = new InvocationPlugins.Registration(invocationPlugins, TestStub.class);
    r.register0("testStub", new InvocationPlugin() {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, InvocationPlugin.Receiver receiver) {
            b.add(new ForeignCallNode(getProviders().getForeignCalls(), TEST_STUB));
            return true;
        }
    });
    return super.editGraphBuilderConfiguration(conf);
}
Also used : InvocationPlugins(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins) ForeignCallNode(org.graalvm.compiler.nodes.extended.ForeignCallNode) GraphBuilderContext(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext) InvocationPlugin(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Example 2 with InvocationPlugins

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

the class HotSpotGraphBuilderPlugins method create.

/**
 * Creates a {@link Plugins} object that should be used when running on HotSpot.
 *
 * @param constantReflection
 * @param snippetReflection
 * @param foreignCalls
 * @param stampProvider
 */
public static Plugins create(CompilerConfiguration compilerConfiguration, GraalHotSpotVMConfig config, HotSpotWordTypes wordTypes, MetaAccessProvider metaAccess, ConstantReflectionProvider constantReflection, SnippetReflectionProvider snippetReflection, ForeignCallsProvider foreignCalls, LoweringProvider lowerer, StampProvider stampProvider, ReplacementsImpl replacements) {
    InvocationPlugins invocationPlugins = new HotSpotInvocationPlugins(config, compilerConfiguration);
    Plugins plugins = new Plugins(invocationPlugins);
    NodeIntrinsificationProvider nodeIntrinsificationProvider = new NodeIntrinsificationProvider(metaAccess, snippetReflection, foreignCalls, lowerer, wordTypes);
    HotSpotWordOperationPlugin wordOperationPlugin = new HotSpotWordOperationPlugin(snippetReflection, wordTypes);
    HotSpotNodePlugin nodePlugin = new HotSpotNodePlugin(wordOperationPlugin);
    plugins.appendTypePlugin(nodePlugin);
    plugins.appendNodePlugin(nodePlugin);
    OptionValues options = replacements.getOptions();
    if (!GeneratePIC.getValue(options)) {
        plugins.appendNodePlugin(new MethodHandlePlugin(constantReflection.getMethodHandleAccess(), true));
    }
    plugins.appendInlineInvokePlugin(replacements);
    if (InlineDuringParsing.getValue(options)) {
        plugins.appendInlineInvokePlugin(new InlineDuringParsingPlugin());
    }
    if (GeneratePIC.getValue(options)) {
        plugins.setClassInitializationPlugin(new HotSpotClassInitializationPlugin());
        if (TieredAOT.getValue(options)) {
            plugins.setProfilingPlugin(new HotSpotAOTProfilingPlugin());
        }
    }
    invocationPlugins.defer(new Runnable() {

        @Override
        public void run() {
            BytecodeProvider replacementBytecodeProvider = replacements.getDefaultReplacementBytecodeProvider();
            registerObjectPlugins(invocationPlugins, options, replacementBytecodeProvider);
            registerClassPlugins(plugins, config, replacementBytecodeProvider);
            registerSystemPlugins(invocationPlugins, foreignCalls);
            registerThreadPlugins(invocationPlugins, metaAccess, wordTypes, config, replacementBytecodeProvider);
            if (!GeneratePIC.getValue(options)) {
                registerCallSitePlugins(invocationPlugins);
            }
            registerReflectionPlugins(invocationPlugins, replacementBytecodeProvider);
            registerConstantPoolPlugins(invocationPlugins, wordTypes, config, replacementBytecodeProvider);
            registerAESPlugins(invocationPlugins, config, replacementBytecodeProvider);
            registerCRC32Plugins(invocationPlugins, config, replacementBytecodeProvider);
            registerCRC32CPlugins(invocationPlugins, config, replacementBytecodeProvider);
            registerBigIntegerPlugins(invocationPlugins, config, replacementBytecodeProvider);
            registerSHAPlugins(invocationPlugins, config, replacementBytecodeProvider);
            registerUnsafePlugins(invocationPlugins, replacementBytecodeProvider);
            StandardGraphBuilderPlugins.registerInvocationPlugins(metaAccess, snippetReflection, invocationPlugins, replacementBytecodeProvider, true);
            registerArrayPlugins(invocationPlugins, replacementBytecodeProvider);
            for (NodeIntrinsicPluginFactory factory : GraalServices.load(NodeIntrinsicPluginFactory.class)) {
                factory.registerPlugins(invocationPlugins, nodeIntrinsificationProvider);
            }
        }
    });
    return plugins;
}
Also used : InvocationPlugins(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins) OptionValues(org.graalvm.compiler.options.OptionValues) InlineDuringParsingPlugin(org.graalvm.compiler.replacements.InlineDuringParsingPlugin) NodeIntrinsicPluginFactory(org.graalvm.compiler.nodes.graphbuilderconf.NodeIntrinsicPluginFactory) BytecodeProvider(org.graalvm.compiler.bytecode.BytecodeProvider) NodeIntrinsificationProvider(org.graalvm.compiler.replacements.NodeIntrinsificationProvider) InvocationPlugins(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins) Plugins(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins) StandardGraphBuilderPlugins(org.graalvm.compiler.replacements.StandardGraphBuilderPlugins) MethodHandlePlugin(org.graalvm.compiler.replacements.MethodHandlePlugin)

Example 3 with InvocationPlugins

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

the class PartialEvaluator method createGraphDecoder.

@SuppressWarnings("unused")
protected PEGraphDecoder createGraphDecoder(StructuredGraph graph, final HighTierContext tierContext, LoopExplosionPlugin loopExplosionPlugin, InvocationPlugins invocationPlugins, InlineInvokePlugin[] inlineInvokePlugins, ParameterPlugin parameterPlugin, NodePlugin[] nodePluginList, ResolvedJavaMethod callInlined, SourceLanguagePositionProvider sourceLanguagePositionProvider) {
    final GraphBuilderConfiguration newConfig = configForParsing.copy();
    if (newConfig.trackNodeSourcePosition()) {
        graph.setTrackNodeSourcePosition();
    }
    InvocationPlugins parsingInvocationPlugins = newConfig.getPlugins().getInvocationPlugins();
    Plugins plugins = newConfig.getPlugins();
    ReplacementsImpl replacements = (ReplacementsImpl) providers.getReplacements();
    plugins.clearInlineInvokePlugins();
    plugins.appendInlineInvokePlugin(replacements);
    plugins.appendInlineInvokePlugin(new ParsingInlineInvokePlugin(replacements, parsingInvocationPlugins, loopExplosionPlugin));
    if (!TruffleCompilerOptions.getValue(PrintTruffleExpansionHistogram)) {
        plugins.appendInlineInvokePlugin(new InlineDuringParsingPlugin());
    }
    Providers compilationUnitProviders = providers.copyWith(new TruffleConstantFieldProvider(providers.getConstantFieldProvider(), providers.getMetaAccess()));
    return new CachingPEGraphDecoder(architecture, graph, compilationUnitProviders, newConfig, TruffleCompilerImpl.Optimizations, AllowAssumptions.ifNonNull(graph.getAssumptions()), loopExplosionPlugin, decodingInvocationPlugins, inlineInvokePlugins, parameterPlugin, nodePluginList, callInlined, sourceLanguagePositionProvider);
}
Also used : InvocationPlugins(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins) InlineDuringParsingPlugin(org.graalvm.compiler.replacements.InlineDuringParsingPlugin) ReplacementsImpl(org.graalvm.compiler.replacements.ReplacementsImpl) GraphBuilderConfiguration(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration) Providers(org.graalvm.compiler.phases.util.Providers) CachingPEGraphDecoder(org.graalvm.compiler.replacements.CachingPEGraphDecoder) TruffleGraphBuilderPlugins(org.graalvm.compiler.truffle.compiler.substitutions.TruffleGraphBuilderPlugins) InvocationPlugins(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins) Plugins(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins)

Example 4 with InvocationPlugins

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

the class PartialEvaluator method createDecodingInvocationPlugins.

protected InvocationPlugins createDecodingInvocationPlugins(Plugins parent) {
    @SuppressWarnings("hiding") InvocationPlugins decodingInvocationPlugins = new InvocationPlugins(parent.getInvocationPlugins());
    registerTruffleInvocationPlugins(decodingInvocationPlugins, false);
    decodingInvocationPlugins.closeRegistration();
    return decodingInvocationPlugins;
}
Also used : InvocationPlugins(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins)

Example 5 with InvocationPlugins

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

the class HotSpotTruffleCompilerImpl method compileTruffleCallBoundaryMethod.

/**
 * Compiles a method denoted as a
 * {@linkplain HotSpotTruffleCompilerRuntime#getTruffleCallBoundaryMethods() Truffle call
 * boundary}. The compiled code has a special entry point generated by an
 * {@link TruffleCallBoundaryInstrumentationFactory}.
 */
private CompilationResult compileTruffleCallBoundaryMethod(ResolvedJavaMethod javaMethod, CompilationIdentifier compilationId, DebugContext debug) {
    Suites newSuites = this.suites.copy();
    removeInliningPhase(newSuites);
    OptionValues options = TruffleCompilerOptions.getOptions();
    StructuredGraph graph = new StructuredGraph.Builder(options, debug, AllowAssumptions.NO).method(javaMethod).compilationId(compilationId).build();
    MetaAccessProvider metaAccess = providers.getMetaAccess();
    Plugins plugins = new Plugins(new InvocationPlugins());
    HotSpotCodeCacheProvider codeCache = (HotSpotCodeCacheProvider) providers.getCodeCache();
    boolean infoPoints = codeCache.shouldDebugNonSafepoints();
    GraphBuilderConfiguration newConfig = GraphBuilderConfiguration.getDefault(plugins).withEagerResolving(true).withUnresolvedIsError(true).withNodeSourcePosition(infoPoints);
    new GraphBuilderPhase.Instance(metaAccess, providers.getStampProvider(), providers.getConstantReflection(), providers.getConstantFieldProvider(), newConfig, OptimisticOptimizations.ALL, null).apply(graph);
    PhaseSuite<HighTierContext> graphBuilderSuite = getGraphBuilderSuite(codeCache, backend.getSuites());
    CompilationResultBuilderFactory factory = getTruffleCallBoundaryInstrumentationFactory(backend.getTarget().arch.getName());
    return compileGraph(graph, javaMethod, providers, backend, graphBuilderSuite, OptimisticOptimizations.ALL, graph.getProfilingInfo(), newSuites, lirSuites, new CompilationResult(compilationId), factory);
}
Also used : InvocationPlugins(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins) HotSpotCodeCacheProvider(jdk.vm.ci.hotspot.HotSpotCodeCacheProvider) OptionValues(org.graalvm.compiler.options.OptionValues) GraphBuilderConfiguration(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) HighTierContext(org.graalvm.compiler.phases.tiers.HighTierContext) CompilationResult(org.graalvm.compiler.code.CompilationResult) GraphBuilderPhase(org.graalvm.compiler.java.GraphBuilderPhase) CompilationResultBuilderFactory(org.graalvm.compiler.lir.asm.CompilationResultBuilderFactory) MetaAccessProvider(jdk.vm.ci.meta.MetaAccessProvider) 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)

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