Search in sources :

Example 1 with BytecodeProvider

use of org.graalvm.compiler.bytecode.BytecodeProvider in project graal by oracle.

the class AMD64HotSpotBackendFactory method createBackend.

@Override
@SuppressWarnings("try")
public HotSpotBackend createBackend(HotSpotGraalRuntimeProvider graalRuntime, CompilerConfiguration compilerConfiguration, HotSpotJVMCIRuntimeProvider jvmciRuntime, HotSpotBackend host) {
    assert host == null;
    OptionValues options = graalRuntime.getOptions();
    JVMCIBackend jvmci = jvmciRuntime.getHostJVMCIBackend();
    GraalHotSpotVMConfig config = graalRuntime.getVMConfig();
    HotSpotProviders providers;
    HotSpotRegistersProvider registers;
    HotSpotCodeCacheProvider codeCache = (HotSpotCodeCacheProvider) jvmci.getCodeCache();
    TargetDescription target = codeCache.getTarget();
    HotSpotHostForeignCallsProvider foreignCalls;
    Value[] nativeABICallerSaveRegisters;
    HotSpotMetaAccessProvider metaAccess = (HotSpotMetaAccessProvider) jvmci.getMetaAccess();
    HotSpotConstantReflectionProvider constantReflection = (HotSpotConstantReflectionProvider) jvmci.getConstantReflection();
    ConstantFieldProvider constantFieldProvider = new HotSpotGraalConstantFieldProvider(config, metaAccess);
    HotSpotLoweringProvider lowerer;
    HotSpotSnippetReflectionProvider snippetReflection;
    HotSpotReplacementsImpl replacements;
    HotSpotSuitesProvider suites;
    HotSpotWordTypes wordTypes;
    Plugins plugins;
    BytecodeProvider bytecodeProvider;
    try (InitTimer t = timer("create providers")) {
        try (InitTimer rt = timer("create HotSpotRegisters provider")) {
            registers = createRegisters();
        }
        try (InitTimer rt = timer("create NativeABICallerSaveRegisters")) {
            nativeABICallerSaveRegisters = createNativeABICallerSaveRegisters(config, codeCache.getRegisterConfig());
        }
        try (InitTimer rt = timer("create WordTypes")) {
            wordTypes = new HotSpotWordTypes(metaAccess, target.wordJavaKind);
        }
        try (InitTimer rt = timer("create ForeignCalls provider")) {
            foreignCalls = createForeignCalls(jvmciRuntime, graalRuntime, metaAccess, codeCache, wordTypes, nativeABICallerSaveRegisters);
        }
        try (InitTimer rt = timer("create Lowerer provider")) {
            lowerer = createLowerer(graalRuntime, metaAccess, foreignCalls, registers, constantReflection, target);
        }
        HotSpotStampProvider stampProvider = new HotSpotStampProvider();
        Providers p = new Providers(metaAccess, codeCache, constantReflection, constantFieldProvider, foreignCalls, lowerer, null, stampProvider);
        try (InitTimer rt = timer("create SnippetReflection provider")) {
            snippetReflection = createSnippetReflection(graalRuntime, constantReflection, wordTypes);
        }
        try (InitTimer rt = timer("create Bytecode provider")) {
            bytecodeProvider = new ClassfileBytecodeProvider(metaAccess, snippetReflection);
        }
        try (InitTimer rt = timer("create Replacements provider")) {
            replacements = createReplacements(options, p, snippetReflection, bytecodeProvider);
        }
        try (InitTimer rt = timer("create GraphBuilderPhase plugins")) {
            plugins = createGraphBuilderPlugins(compilerConfiguration, config, options, target, constantReflection, foreignCalls, lowerer, metaAccess, snippetReflection, replacements, wordTypes, stampProvider);
            replacements.setGraphBuilderPlugins(plugins);
        }
        try (InitTimer rt = timer("create Suites provider")) {
            suites = createSuites(config, graalRuntime, compilerConfiguration, plugins, registers, replacements, options);
        }
        providers = new HotSpotProviders(metaAccess, codeCache, constantReflection, constantFieldProvider, foreignCalls, lowerer, replacements, suites, registers, snippetReflection, wordTypes, plugins);
    }
    try (InitTimer rt = timer("instantiate backend")) {
        return createBackend(config, graalRuntime, providers);
    }
}
Also used : InitTimer(jdk.vm.ci.common.InitTimer) OptionValues(org.graalvm.compiler.options.OptionValues) JVMCIBackend(jdk.vm.ci.runtime.JVMCIBackend) HotSpotProviders(org.graalvm.compiler.hotspot.meta.HotSpotProviders) TargetDescription(jdk.vm.ci.code.TargetDescription) HotSpotProviders(org.graalvm.compiler.hotspot.meta.HotSpotProviders) Providers(org.graalvm.compiler.phases.util.Providers) HotSpotReplacementsImpl(org.graalvm.compiler.hotspot.HotSpotReplacementsImpl) HotSpotRegistersProvider(org.graalvm.compiler.hotspot.meta.HotSpotRegistersProvider) HotSpotSuitesProvider(org.graalvm.compiler.hotspot.meta.HotSpotSuitesProvider) AddressLoweringHotSpotSuitesProvider(org.graalvm.compiler.hotspot.meta.AddressLoweringHotSpotSuitesProvider) GraalHotSpotVMConfig(org.graalvm.compiler.hotspot.GraalHotSpotVMConfig) HotSpotStampProvider(org.graalvm.compiler.hotspot.meta.HotSpotStampProvider) HotSpotGraphBuilderPlugins(org.graalvm.compiler.hotspot.meta.HotSpotGraphBuilderPlugins) Plugins(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins) AMD64GraphBuilderPlugins(org.graalvm.compiler.replacements.amd64.AMD64GraphBuilderPlugins) ClassfileBytecodeProvider(org.graalvm.compiler.replacements.classfile.ClassfileBytecodeProvider) HotSpotHostForeignCallsProvider(org.graalvm.compiler.hotspot.meta.HotSpotHostForeignCallsProvider) HotSpotCodeCacheProvider(jdk.vm.ci.hotspot.HotSpotCodeCacheProvider) BytecodeProvider(org.graalvm.compiler.bytecode.BytecodeProvider) ClassfileBytecodeProvider(org.graalvm.compiler.replacements.classfile.ClassfileBytecodeProvider) HotSpotMetaAccessProvider(jdk.vm.ci.hotspot.HotSpotMetaAccessProvider) HotSpotSnippetReflectionProvider(org.graalvm.compiler.hotspot.meta.HotSpotSnippetReflectionProvider) HotSpotLoweringProvider(org.graalvm.compiler.hotspot.meta.HotSpotLoweringProvider) HotSpotWordTypes(org.graalvm.compiler.hotspot.word.HotSpotWordTypes) Value(jdk.vm.ci.meta.Value) HotSpotConstantReflectionProvider(jdk.vm.ci.hotspot.HotSpotConstantReflectionProvider) HotSpotGraalConstantFieldProvider(org.graalvm.compiler.hotspot.meta.HotSpotGraalConstantFieldProvider) HotSpotGraalConstantFieldProvider(org.graalvm.compiler.hotspot.meta.HotSpotGraalConstantFieldProvider) ConstantFieldProvider(org.graalvm.compiler.core.common.spi.ConstantFieldProvider)

Example 2 with BytecodeProvider

use of org.graalvm.compiler.bytecode.BytecodeProvider in project graal by oracle.

the class AArch64HotSpotBackendFactory method createBackend.

@Override
@SuppressWarnings("try")
public HotSpotBackend createBackend(HotSpotGraalRuntimeProvider graalRuntime, CompilerConfiguration compilerConfiguration, HotSpotJVMCIRuntimeProvider jvmciRuntime, HotSpotBackend host) {
    assert host == null;
    JVMCIBackend jvmci = jvmciRuntime.getHostJVMCIBackend();
    GraalHotSpotVMConfig config = graalRuntime.getVMConfig();
    HotSpotProviders providers;
    HotSpotRegistersProvider registers;
    HotSpotCodeCacheProvider codeCache = (HotSpotCodeCacheProvider) jvmci.getCodeCache();
    TargetDescription target = codeCache.getTarget();
    HotSpotHostForeignCallsProvider foreignCalls;
    Value[] nativeABICallerSaveRegisters;
    HotSpotMetaAccessProvider metaAccess = (HotSpotMetaAccessProvider) jvmci.getMetaAccess();
    HotSpotConstantReflectionProvider constantReflection = (HotSpotConstantReflectionProvider) jvmci.getConstantReflection();
    HotSpotConstantFieldProvider constantFieldProvider = new HotSpotGraalConstantFieldProvider(config, metaAccess);
    HotSpotLoweringProvider lowerer;
    HotSpotSnippetReflectionProvider snippetReflection;
    HotSpotReplacementsImpl replacements;
    HotSpotSuitesProvider suites;
    HotSpotWordTypes wordTypes;
    Plugins plugins;
    BytecodeProvider bytecodeProvider;
    try (InitTimer t = timer("create providers")) {
        try (InitTimer rt = timer("create HotSpotRegisters provider")) {
            registers = createRegisters();
        }
        try (InitTimer rt = timer("create NativeABICallerSaveRegisters")) {
            nativeABICallerSaveRegisters = createNativeABICallerSaveRegisters(config, codeCache.getRegisterConfig());
        }
        try (InitTimer rt = timer("create WordTypes")) {
            wordTypes = new HotSpotWordTypes(metaAccess, target.wordJavaKind);
        }
        try (InitTimer rt = timer("create ForeignCalls provider")) {
            foreignCalls = createForeignCalls(jvmciRuntime, graalRuntime, metaAccess, codeCache, wordTypes, nativeABICallerSaveRegisters);
        }
        try (InitTimer rt = timer("create Lowerer provider")) {
            lowerer = createLowerer(graalRuntime, metaAccess, foreignCalls, registers, constantReflection, target);
        }
        HotSpotStampProvider stampProvider = new HotSpotStampProvider();
        Providers p = new Providers(metaAccess, codeCache, constantReflection, constantFieldProvider, foreignCalls, lowerer, null, stampProvider);
        try (InitTimer rt = timer("create SnippetReflection provider")) {
            snippetReflection = createSnippetReflection(graalRuntime, constantReflection, wordTypes);
        }
        try (InitTimer rt = timer("create Bytecode provider")) {
            bytecodeProvider = new ClassfileBytecodeProvider(metaAccess, snippetReflection);
        }
        try (InitTimer rt = timer("create Replacements provider")) {
            replacements = createReplacements(graalRuntime.getOptions(), p, snippetReflection, bytecodeProvider);
        }
        try (InitTimer rt = timer("create GraphBuilderPhase plugins")) {
            plugins = createGraphBuilderPlugins(compilerConfiguration, config, constantReflection, foreignCalls, lowerer, metaAccess, snippetReflection, replacements, wordTypes, stampProvider);
            replacements.setGraphBuilderPlugins(plugins);
        }
        try (InitTimer rt = timer("create Suites provider")) {
            suites = createSuites(config, graalRuntime, compilerConfiguration, plugins);
        }
        providers = new HotSpotProviders(metaAccess, codeCache, constantReflection, constantFieldProvider, foreignCalls, lowerer, replacements, suites, registers, snippetReflection, wordTypes, plugins);
    }
    try (InitTimer rt = timer("instantiate backend")) {
        return createBackend(config, graalRuntime, providers);
    }
}
Also used : ClassfileBytecodeProvider(org.graalvm.compiler.replacements.classfile.ClassfileBytecodeProvider) HotSpotHostForeignCallsProvider(org.graalvm.compiler.hotspot.meta.HotSpotHostForeignCallsProvider) HotSpotCodeCacheProvider(jdk.vm.ci.hotspot.HotSpotCodeCacheProvider) InitTimer(jdk.vm.ci.common.InitTimer) JVMCIBackend(jdk.vm.ci.runtime.JVMCIBackend) HotSpotProviders(org.graalvm.compiler.hotspot.meta.HotSpotProviders) TargetDescription(jdk.vm.ci.code.TargetDescription) BytecodeProvider(org.graalvm.compiler.bytecode.BytecodeProvider) ClassfileBytecodeProvider(org.graalvm.compiler.replacements.classfile.ClassfileBytecodeProvider) HotSpotConstantFieldProvider(org.graalvm.compiler.hotspot.meta.HotSpotConstantFieldProvider) HotSpotProviders(org.graalvm.compiler.hotspot.meta.HotSpotProviders) Providers(org.graalvm.compiler.phases.util.Providers) HotSpotMetaAccessProvider(jdk.vm.ci.hotspot.HotSpotMetaAccessProvider) HotSpotSnippetReflectionProvider(org.graalvm.compiler.hotspot.meta.HotSpotSnippetReflectionProvider) HotSpotReplacementsImpl(org.graalvm.compiler.hotspot.HotSpotReplacementsImpl) HotSpotLoweringProvider(org.graalvm.compiler.hotspot.meta.HotSpotLoweringProvider) HotSpotWordTypes(org.graalvm.compiler.hotspot.word.HotSpotWordTypes) HotSpotRegistersProvider(org.graalvm.compiler.hotspot.meta.HotSpotRegistersProvider) HotSpotSuitesProvider(org.graalvm.compiler.hotspot.meta.HotSpotSuitesProvider) Value(jdk.vm.ci.meta.Value) HotSpotConstantReflectionProvider(jdk.vm.ci.hotspot.HotSpotConstantReflectionProvider) HotSpotGraalConstantFieldProvider(org.graalvm.compiler.hotspot.meta.HotSpotGraalConstantFieldProvider) GraalHotSpotVMConfig(org.graalvm.compiler.hotspot.GraalHotSpotVMConfig) HotSpotStampProvider(org.graalvm.compiler.hotspot.meta.HotSpotStampProvider) AArch64GraphBuilderPlugins(org.graalvm.compiler.replacements.aarch64.AArch64GraphBuilderPlugins) HotSpotGraphBuilderPlugins(org.graalvm.compiler.hotspot.meta.HotSpotGraphBuilderPlugins) Plugins(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins)

Example 3 with BytecodeProvider

use of org.graalvm.compiler.bytecode.BytecodeProvider 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 4 with BytecodeProvider

use of org.graalvm.compiler.bytecode.BytecodeProvider 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)

Example 5 with BytecodeProvider

use of org.graalvm.compiler.bytecode.BytecodeProvider in project graal by oracle.

the class SubstrateReplacements method getSnippet.

@Override
public StructuredGraph getSnippet(ResolvedJavaMethod method, ResolvedJavaMethod recursiveEntry, Object[] args, boolean trackNodeSourcePosition, NodeSourcePosition replaceePosition) {
    Integer startOffset = snippetStartOffsets.get(method);
    if (startOffset == null) {
        throw VMError.shouldNotReachHere("snippet not found: " + method.format("%H.%n(%p)"));
    }
    ParameterPlugin parameterPlugin = null;
    if (args != null) {
        parameterPlugin = new ConstantBindingParameterPlugin(args, providers.getMetaAccess(), snippetReflection);
    }
    EncodedGraph encodedGraph = new EncodedGraph(snippetEncoding, startOffset, snippetObjects, snippetNodeClasses, null, null, null, false, trackNodeSourcePosition);
    try (DebugContext debug = openDebugContext("SVMSnippet_", method)) {
        StructuredGraph result = new StructuredGraph.Builder(options, debug).method(method).trackNodeSourcePosition(trackNodeSourcePosition).build();
        PEGraphDecoder graphDecoder = new PEGraphDecoder(ConfigurationValues.getTarget().arch, result, providers.getMetaAccess(), providers.getConstantReflection(), providers.getConstantFieldProvider(), providers.getStampProvider(), null, snippetInvocationPlugins, new InlineInvokePlugin[0], parameterPlugin, null, null, null) {

            @Override
            protected EncodedGraph lookupEncodedGraph(ResolvedJavaMethod lookupMethod, ResolvedJavaMethod originalMethod, BytecodeProvider intrinsicBytecodeProvider, boolean track) {
                if (lookupMethod.equals(method)) {
                    assert !track || encodedGraph.trackNodeSourcePosition();
                    return encodedGraph;
                } else {
                    throw VMError.shouldNotReachHere(method.format("%H.%n(%p)"));
                }
            }
        };
        graphDecoder.decode(method, trackNodeSourcePosition);
        assert result.verify();
        return result;
    }
}
Also used : ConstantBindingParameterPlugin(org.graalvm.compiler.replacements.ConstantBindingParameterPlugin) ParameterPlugin(org.graalvm.compiler.nodes.graphbuilderconf.ParameterPlugin) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) EncodedGraph(org.graalvm.compiler.nodes.EncodedGraph) PEGraphDecoder(org.graalvm.compiler.replacements.PEGraphDecoder) BytecodeProvider(org.graalvm.compiler.bytecode.BytecodeProvider) DebugContext(org.graalvm.compiler.debug.DebugContext) ConstantBindingParameterPlugin(org.graalvm.compiler.replacements.ConstantBindingParameterPlugin) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Aggregations

BytecodeProvider (org.graalvm.compiler.bytecode.BytecodeProvider)11 TargetDescription (jdk.vm.ci.code.TargetDescription)4 Providers (org.graalvm.compiler.phases.util.Providers)4 Plugins (org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins)3 NodeIntrinsicPluginFactory (org.graalvm.compiler.nodes.graphbuilderconf.NodeIntrinsicPluginFactory)3 HostedProviders (com.oracle.graal.pointsto.meta.HostedProviders)2 SubstrateReplacements (com.oracle.svm.core.graal.meta.SubstrateReplacements)2 InitTimer (jdk.vm.ci.common.InitTimer)2 HotSpotCodeCacheProvider (jdk.vm.ci.hotspot.HotSpotCodeCacheProvider)2 HotSpotConstantReflectionProvider (jdk.vm.ci.hotspot.HotSpotConstantReflectionProvider)2 HotSpotMetaAccessProvider (jdk.vm.ci.hotspot.HotSpotMetaAccessProvider)2 Value (jdk.vm.ci.meta.Value)2 JVMCIBackend (jdk.vm.ci.runtime.JVMCIBackend)2 GraalHotSpotVMConfig (org.graalvm.compiler.hotspot.GraalHotSpotVMConfig)2 HotSpotReplacementsImpl (org.graalvm.compiler.hotspot.HotSpotReplacementsImpl)2 HotSpotGraalConstantFieldProvider (org.graalvm.compiler.hotspot.meta.HotSpotGraalConstantFieldProvider)2 HotSpotGraphBuilderPlugins (org.graalvm.compiler.hotspot.meta.HotSpotGraphBuilderPlugins)2 HotSpotHostForeignCallsProvider (org.graalvm.compiler.hotspot.meta.HotSpotHostForeignCallsProvider)2 HotSpotLoweringProvider (org.graalvm.compiler.hotspot.meta.HotSpotLoweringProvider)2 HotSpotProviders (org.graalvm.compiler.hotspot.meta.HotSpotProviders)2