Search in sources :

Example 1 with ConstantFoldLoadFieldPlugin

use of com.oracle.svm.hosted.phases.ConstantFoldLoadFieldPlugin 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

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 BytecodeProvider (org.graalvm.compiler.bytecode.BytecodeProvider)1 ResolvedJavaMethodBytecodeProvider (org.graalvm.compiler.bytecode.ResolvedJavaMethodBytecodeProvider)1 Backend (org.graalvm.compiler.core.target.Backend)1 GraphBuilderConfiguration (org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration)1 InvocationPlugins (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins)1 NodeIntrinsicPluginFactory (org.graalvm.compiler.nodes.graphbuilderconf.NodeIntrinsicPluginFactory)1