Search in sources :

Example 1 with NodeLoweringProvider

use of com.oracle.svm.core.graal.snippets.NodeLoweringProvider in project graal by oracle.

the class NativeImageGenerator method registerReplacements.

@SuppressWarnings("try")
public static void registerReplacements(DebugContext debug, FeatureHandler featureHandler, RuntimeConfiguration runtimeConfig, Providers providers, SnippetReflectionProvider snippetReflection, boolean hosted) {
    OptionValues options = hosted ? HostedOptionValues.singleton() : RuntimeOptionValues.singleton();
    Providers runtimeCallProviders = runtimeConfig != null ? runtimeConfig.getBackendForNormalMethod().getProviders() : providers;
    SubstrateForeignCallsProvider foreignCallsProvider = (SubstrateForeignCallsProvider) providers.getForeignCalls();
    for (SubstrateForeignCallDescriptor descriptor : SnippetRuntime.getRuntimeCalls()) {
        foreignCallsProvider.getForeignCalls().put(descriptor, new SubstrateForeignCallLinkage(runtimeCallProviders, descriptor));
    }
    featureHandler.forEachGraalFeature(feature -> feature.registerForeignCalls(runtimeConfig, runtimeCallProviders, snippetReflection, foreignCallsProvider.getForeignCalls(), hosted));
    try (DebugContext.Scope s = debug.scope("RegisterLowerings", new DebugDumpScope("RegisterLowerings"))) {
        SubstrateLoweringProvider lowerer = (SubstrateLoweringProvider) providers.getLowerer();
        Map<Class<? extends Node>, NodeLoweringProvider<?>> lowerings = lowerer.getLowerings();
        Iterable<DebugHandlersFactory> factories = runtimeConfig != null ? runtimeConfig.getDebugHandlersFactories() : Collections.singletonList(new GraalDebugHandlersFactory(snippetReflection));
        lowerer.setConfiguration(runtimeConfig, options, factories, providers, snippetReflection);
        NonSnippetLowerings.registerLowerings(runtimeConfig, options, factories, providers, snippetReflection, lowerings);
        ArithmeticSnippets.registerLowerings(options, factories, providers, snippetReflection, lowerings);
        MonitorSnippets.registerLowerings(options, factories, providers, snippetReflection, lowerings);
        TypeSnippets.registerLowerings(runtimeConfig, options, factories, providers, snippetReflection, lowerings);
        ExceptionSnippets.registerLowerings(options, factories, providers, snippetReflection, lowerings);
        if (hosted) {
            AssertSnippets.registerLowerings(options, factories, providers, snippetReflection, lowerings);
            DeoptHostedSnippets.registerLowerings(options, factories, providers, snippetReflection, lowerings);
        } else {
            DeoptRuntimeSnippets.registerLowerings(options, factories, providers, snippetReflection, lowerings);
        }
        if (NativeImageOptions.DeoptimizeAll.getValue()) {
            DeoptTestSnippets.registerLowerings(options, factories, providers, snippetReflection, lowerings);
        }
        featureHandler.forEachGraalFeature(feature -> feature.registerLowerings(runtimeConfig, options, factories, providers, snippetReflection, lowerings, hosted));
    } catch (Throwable e) {
        throw debug.handle(e);
    }
    SubstrateReplacements replacements = (SubstrateReplacements) providers.getReplacements();
    assert checkInvocationPluginMethods(replacements);
    replacements.encodeSnippets();
}
Also used : SubstrateForeignCallDescriptor(com.oracle.svm.core.snippets.SnippetRuntime.SubstrateForeignCallDescriptor) HostedOptionValues(com.oracle.svm.core.option.HostedOptionValues) RuntimeOptionValues(com.oracle.svm.core.option.RuntimeOptionValues) OptionValues(org.graalvm.compiler.options.OptionValues) SubstrateLoweringProvider(com.oracle.svm.core.graal.meta.SubstrateLoweringProvider) DebugHandlersFactory(org.graalvm.compiler.debug.DebugHandlersFactory) GraalDebugHandlersFactory(org.graalvm.compiler.printer.GraalDebugHandlersFactory) DebugDumpScope(org.graalvm.compiler.debug.DebugDumpScope) StackValueNode(com.oracle.svm.core.graal.stackvalue.StackValueNode) Node(org.graalvm.compiler.graph.Node) SubstrateForeignCallsProvider(com.oracle.svm.core.graal.meta.SubstrateForeignCallsProvider) SubstrateForeignCallLinkage(com.oracle.svm.core.graal.meta.SubstrateForeignCallLinkage) DebugContext(org.graalvm.compiler.debug.DebugContext) Providers(org.graalvm.compiler.phases.util.Providers) HostedProviders(com.oracle.graal.pointsto.meta.HostedProviders) GraalDebugHandlersFactory(org.graalvm.compiler.printer.GraalDebugHandlersFactory) SubstrateReplacements(com.oracle.svm.core.graal.meta.SubstrateReplacements) NodeLoweringProvider(com.oracle.svm.core.graal.snippets.NodeLoweringProvider)

Aggregations

HostedProviders (com.oracle.graal.pointsto.meta.HostedProviders)1 SubstrateForeignCallLinkage (com.oracle.svm.core.graal.meta.SubstrateForeignCallLinkage)1 SubstrateForeignCallsProvider (com.oracle.svm.core.graal.meta.SubstrateForeignCallsProvider)1 SubstrateLoweringProvider (com.oracle.svm.core.graal.meta.SubstrateLoweringProvider)1 SubstrateReplacements (com.oracle.svm.core.graal.meta.SubstrateReplacements)1 NodeLoweringProvider (com.oracle.svm.core.graal.snippets.NodeLoweringProvider)1 StackValueNode (com.oracle.svm.core.graal.stackvalue.StackValueNode)1 HostedOptionValues (com.oracle.svm.core.option.HostedOptionValues)1 RuntimeOptionValues (com.oracle.svm.core.option.RuntimeOptionValues)1 SubstrateForeignCallDescriptor (com.oracle.svm.core.snippets.SnippetRuntime.SubstrateForeignCallDescriptor)1 DebugContext (org.graalvm.compiler.debug.DebugContext)1 DebugDumpScope (org.graalvm.compiler.debug.DebugDumpScope)1 DebugHandlersFactory (org.graalvm.compiler.debug.DebugHandlersFactory)1 Node (org.graalvm.compiler.graph.Node)1 OptionValues (org.graalvm.compiler.options.OptionValues)1 Providers (org.graalvm.compiler.phases.util.Providers)1 GraalDebugHandlersFactory (org.graalvm.compiler.printer.GraalDebugHandlersFactory)1