Search in sources :

Example 1 with NodeIntrinsicPluginFactory

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

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

the class NativeImageGenerator method registerGraphBuilderPlugins.

public static void registerGraphBuilderPlugins(FeatureHandler featureHandler, RuntimeConfiguration runtimeConfig, HostedProviders providers, AnalysisMetaAccess aMetaAccess, AnalysisUniverse aUniverse, HostedMetaAccess hMetaAccess, HostedUniverse hUniverse, NativeLibraries nativeLibs, ImageClassLoader loader, boolean analysis, boolean hosted) {
    assert !analysis || hosted : "analysis must always be hosted";
    GraphBuilderConfiguration.Plugins plugins = new GraphBuilderConfiguration.Plugins(new SubstitutionInvocationPlugins());
    WordOperationPlugin wordOperationPlugin = new WordOperationPlugin(providers.getSnippetReflection(), providers.getWordTypes());
    SubstrateReplacements replacements = (SubstrateReplacements) providers.getReplacements();
    plugins.appendInlineInvokePlugin(replacements);
    plugins.appendNodePlugin(new IntrinsifyMethodHandlesInvocationPlugin(providers, aUniverse, hUniverse));
    plugins.appendNodePlugin(new DeletedFieldsPlugin());
    plugins.appendNodePlugin(new InjectedAccessorsPlugin());
    plugins.appendNodePlugin(new ConstantFoldLoadFieldPlugin());
    plugins.appendNodePlugin(new CInterfaceInvocationPlugin(providers.getMetaAccess(), providers.getSnippetReflection(), providers.getWordTypes(), nativeLibs));
    plugins.appendNodePlugin(new LocalizationFeature.CharsetNodePlugin());
    plugins.appendInlineInvokePlugin(wordOperationPlugin);
    plugins.appendTypePlugin(wordOperationPlugin);
    plugins.appendTypePlugin(new TrustedInterfaceTypePlugin());
    plugins.appendNodePlugin(wordOperationPlugin);
    plugins.appendNodePlugin(new ImplicitExceptionsPlugin(providers.getMetaAccess(), providers.getForeignCalls()));
    featureHandler.forEachGraalFeature(feature -> feature.registerNodePlugins(analysis ? aMetaAccess : hMetaAccess, plugins, analysis, hosted));
    HostedSnippetReflectionProvider hostedSnippetReflection = new HostedSnippetReflectionProvider((SVMHost) aUniverse.getHostVM());
    NodeIntrinsificationProvider nodeIntrinsificationProvider = new NodeIntrinsificationProvider(providers.getMetaAccess(), hostedSnippetReflection, providers.getForeignCalls(), providers.getLowerer(), providers.getWordTypes());
    for (Class<? extends NodeIntrinsicPluginFactory> factoryClass : loader.findSubclasses(NodeIntrinsicPluginFactory.class)) {
        if (!Modifier.isAbstract(factoryClass.getModifiers()) && !factoryClass.getName().contains("hotspot")) {
            NodeIntrinsicPluginFactory factory;
            try {
                factory = factoryClass.newInstance();
            } catch (InstantiationException | IllegalAccessException ex) {
                throw VMError.shouldNotReachHere(ex);
            }
            factory.registerPlugins(plugins.getInvocationPlugins(), nodeIntrinsificationProvider);
        }
    }
    BytecodeProvider replacementBytecodeProvider = replacements.getDefaultReplacementBytecodeProvider();
    StandardGraphBuilderPlugins.registerInvocationPlugins(providers.getMetaAccess(), providers.getSnippetReflection(), plugins.getInvocationPlugins(), replacementBytecodeProvider, !hosted);
    AMD64GraphBuilderPlugins.register(plugins, replacementBytecodeProvider, (AMD64) ConfigurationValues.getTarget().arch, true);
    /*
         * When the context is hosted, i.e., ahead-of-time compilation, and after the analysis we
         * need the hosted meta access.
         */
    MetaAccessProvider pluginsMetaAccess = hosted && !analysis ? hMetaAccess : aMetaAccess;
    assert pluginsMetaAccess != null;
    SubstrateGraphBuilderPlugins.registerInvocationPlugins(pluginsMetaAccess, providers.getConstantReflection(), hostedSnippetReflection, plugins.getInvocationPlugins(), replacementBytecodeProvider, analysis);
    featureHandler.forEachGraalFeature(feature -> feature.registerInvocationPlugins(providers, hostedSnippetReflection, plugins.getInvocationPlugins(), hosted));
    providers.setGraphBuilderPlugins(plugins);
    replacements.setGraphBuilderPlugins(plugins);
    if (runtimeConfig != null && runtimeConfig.getProviders() instanceof HostedProviders) {
        ((HostedProviders) runtimeConfig.getProviders()).setGraphBuilderPlugins(plugins);
        for (Backend backend : runtimeConfig.getBackends()) {
            ((HostedProviders) backend.getProviders()).setGraphBuilderPlugins(plugins);
        }
    }
}
Also used : CInterfaceInvocationPlugin(com.oracle.svm.hosted.phases.CInterfaceInvocationPlugin) DeletedFieldsPlugin(com.oracle.svm.hosted.substitute.DeletedFieldsPlugin) IntrinsifyMethodHandlesInvocationPlugin(com.oracle.svm.hosted.phases.IntrinsifyMethodHandlesInvocationPlugin) HostedSnippetReflectionProvider(com.oracle.svm.hosted.meta.HostedSnippetReflectionProvider) HostedProviders(com.oracle.graal.pointsto.meta.HostedProviders) ConstantFoldLoadFieldPlugin(com.oracle.svm.hosted.phases.ConstantFoldLoadFieldPlugin) SubstrateGraphBuilderPlugins(com.oracle.svm.hosted.snippets.SubstrateGraphBuilderPlugins) AMD64GraphBuilderPlugins(org.graalvm.compiler.replacements.amd64.AMD64GraphBuilderPlugins) StandardGraphBuilderPlugins(org.graalvm.compiler.replacements.StandardGraphBuilderPlugins) InvocationPlugins(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins) LocalizationFeature(com.oracle.svm.core.jdk.LocalizationFeature) NodeIntrinsicPluginFactory(org.graalvm.compiler.nodes.graphbuilderconf.NodeIntrinsicPluginFactory) InjectedAccessorsPlugin(com.oracle.svm.hosted.phases.InjectedAccessorsPlugin) GraphBuilderConfiguration(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration) BytecodeProvider(org.graalvm.compiler.bytecode.BytecodeProvider) ResolvedJavaMethodBytecodeProvider(org.graalvm.compiler.bytecode.ResolvedJavaMethodBytecodeProvider) TrustedInterfaceTypePlugin(com.oracle.svm.core.graal.phases.TrustedInterfaceTypePlugin) ImplicitExceptionsPlugin(com.oracle.svm.hosted.phases.ImplicitExceptionsPlugin) Backend(org.graalvm.compiler.core.target.Backend) SubstrateAMD64Backend(com.oracle.svm.core.graal.code.amd64.SubstrateAMD64Backend) SubstrateReplacements(com.oracle.svm.core.graal.meta.SubstrateReplacements) NodeIntrinsificationProvider(org.graalvm.compiler.replacements.NodeIntrinsificationProvider) MetaAccessProvider(jdk.vm.ci.meta.MetaAccessProvider) WordOperationPlugin(org.graalvm.compiler.word.WordOperationPlugin)

Aggregations

BytecodeProvider (org.graalvm.compiler.bytecode.BytecodeProvider)2 InvocationPlugins (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins)2 NodeIntrinsicPluginFactory (org.graalvm.compiler.nodes.graphbuilderconf.NodeIntrinsicPluginFactory)2 NodeIntrinsificationProvider (org.graalvm.compiler.replacements.NodeIntrinsificationProvider)2 StandardGraphBuilderPlugins (org.graalvm.compiler.replacements.StandardGraphBuilderPlugins)2 HostedProviders (com.oracle.graal.pointsto.meta.HostedProviders)1 SubstrateAMD64Backend (com.oracle.svm.core.graal.code.amd64.SubstrateAMD64Backend)1 SubstrateReplacements (com.oracle.svm.core.graal.meta.SubstrateReplacements)1 TrustedInterfaceTypePlugin (com.oracle.svm.core.graal.phases.TrustedInterfaceTypePlugin)1 LocalizationFeature (com.oracle.svm.core.jdk.LocalizationFeature)1 HostedSnippetReflectionProvider (com.oracle.svm.hosted.meta.HostedSnippetReflectionProvider)1 CInterfaceInvocationPlugin (com.oracle.svm.hosted.phases.CInterfaceInvocationPlugin)1 ConstantFoldLoadFieldPlugin (com.oracle.svm.hosted.phases.ConstantFoldLoadFieldPlugin)1 ImplicitExceptionsPlugin (com.oracle.svm.hosted.phases.ImplicitExceptionsPlugin)1 InjectedAccessorsPlugin (com.oracle.svm.hosted.phases.InjectedAccessorsPlugin)1 IntrinsifyMethodHandlesInvocationPlugin (com.oracle.svm.hosted.phases.IntrinsifyMethodHandlesInvocationPlugin)1 SubstrateGraphBuilderPlugins (com.oracle.svm.hosted.snippets.SubstrateGraphBuilderPlugins)1 DeletedFieldsPlugin (com.oracle.svm.hosted.substitute.DeletedFieldsPlugin)1 MetaAccessProvider (jdk.vm.ci.meta.MetaAccessProvider)1 ResolvedJavaMethodBytecodeProvider (org.graalvm.compiler.bytecode.ResolvedJavaMethodBytecodeProvider)1