Search in sources :

Example 1 with SubstrateGraalRuntime

use of com.oracle.svm.graal.SubstrateGraalRuntime in project graal by oracle.

the class RuntimeStrengthenStampsPhase method beforeAnalysis.

@Override
public void beforeAnalysis(BeforeAnalysisAccess c) {
    BeforeAnalysisAccessImpl config = (BeforeAnalysisAccessImpl) c;
    GraalSupport.allocatePhaseStatisticsCache();
    populateMatchRuleRegistry();
    Function<Providers, Backend> backendProvider = GraalSupport.getRuntimeBackendProvider();
    Providers originalProviders = GraalAccess.getOriginalProviders();
    runtimeConfigBuilder = new SubstrateRuntimeConfigurationBuilder(RuntimeOptionValues.singleton(), config.getHostVM(), config.getUniverse(), config.getMetaAccess(), originalProviders.getConstantReflection(), backendProvider).build();
    RuntimeConfiguration runtimeConfig = runtimeConfigBuilder.getRuntimeConfig();
    Providers runtimeProviders = runtimeConfig.getProviders();
    WordTypes wordTypes = runtimeConfigBuilder.getWordTypes();
    hostedProviders = new HostedProviders(runtimeProviders.getMetaAccess(), runtimeProviders.getCodeCache(), runtimeProviders.getConstantReflection(), runtimeProviders.getConstantFieldProvider(), runtimeProviders.getForeignCalls(), runtimeProviders.getLowerer(), runtimeProviders.getReplacements(), runtimeProviders.getStampProvider(), runtimeConfig.getSnippetReflection(), wordTypes);
    SubstrateGraalRuntime graalRuntime = new SubstrateGraalRuntime();
    objectReplacer.setGraalRuntime(graalRuntime);
    ImageSingletons.add(GraalRuntime.class, graalRuntime);
    RuntimeSupport.getRuntimeSupport().addShutdownHook(new GraalSupport.GraalShutdownHook());
    FeatureHandler featureHandler = config.getFeatureHandler();
    NativeImageGenerator.registerGraphBuilderPlugins(featureHandler, runtimeConfig, hostedProviders, config.getMetaAccess(), config.getUniverse(), null, null, config.getNativeLibraries(), config.getImageClassLoader(), false, false);
    DebugContext debug = DebugContext.forCurrentThread();
    NativeImageGenerator.registerReplacements(debug, featureHandler, runtimeConfig, runtimeConfig.getProviders(), runtimeConfig.getSnippetReflection(), false);
    featureHandler.forEachGraalFeature(feature -> feature.registerCodeObserver(runtimeConfig));
    Suites suites = NativeImageGenerator.createSuites(featureHandler, runtimeConfig, runtimeConfig.getSnippetReflection(), false);
    LIRSuites lirSuites = NativeImageGenerator.createLIRSuites(featureHandler, runtimeConfig.getProviders(), false);
    GraalSupport.setRuntimeConfig(runtimeConfig, suites, lirSuites);
    NodeClass<?>[] snippetNodeClasses = ((SubstrateReplacements) runtimeProviders.getReplacements()).getSnippetNodeClasses();
    for (NodeClass<?> nodeClass : snippetNodeClasses) {
        config.getMetaAccess().lookupJavaType(nodeClass.getClazz()).registerAsAllocated(null);
    }
    /* Initialize configuration with reasonable default values. */
    graphBuilderConfig = GraphBuilderConfiguration.getDefault(hostedProviders.getGraphBuilderPlugins()).withBytecodeExceptionMode(BytecodeExceptionMode.ExplicitOnly);
    includeCalleePredicate = GraalFeature::defaultIncludeCallee;
    optimisticOpts = OptimisticOptimizations.ALL.remove(OptimisticOptimizations.Optimization.UseLoopLimitChecks);
    methods = new LinkedHashMap<>();
    graphEncoder = new GraphEncoder(ConfigurationValues.getTarget().arch);
    /*
         * Ensure that all snippet methods have their SubstrateMethod object created by the object
         * replacer, to avoid corner cases later when writing the native image.
         */
    for (ResolvedJavaMethod method : ((SubstrateReplacements) runtimeProviders.getReplacements()).getSnippetMethods()) {
        objectReplacer.apply(method);
    }
}
Also used : BeforeAnalysisAccessImpl(com.oracle.svm.hosted.FeatureImpl.BeforeAnalysisAccessImpl) SubstrateGraalRuntime(com.oracle.svm.graal.SubstrateGraalRuntime) GraalSupport(com.oracle.svm.graal.GraalSupport) WordTypes(org.graalvm.compiler.word.WordTypes) DebugContext(org.graalvm.compiler.debug.DebugContext) GraphEncoder(org.graalvm.compiler.nodes.GraphEncoder) HostedProviders(com.oracle.graal.pointsto.meta.HostedProviders) Providers(org.graalvm.compiler.phases.util.Providers) RuntimeConfiguration(com.oracle.svm.core.graal.meta.RuntimeConfiguration) HostedProviders(com.oracle.graal.pointsto.meta.HostedProviders) NodeClass(org.graalvm.compiler.graph.NodeClass) Backend(org.graalvm.compiler.core.target.Backend) SubstrateReplacements(com.oracle.svm.core.graal.meta.SubstrateReplacements) FeatureHandler(com.oracle.svm.hosted.FeatureHandler) SubstrateRuntimeConfigurationBuilder(com.oracle.svm.graal.meta.SubstrateRuntimeConfigurationBuilder) LIRSuites(org.graalvm.compiler.lir.phases.LIRSuites) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod) LIRSuites(org.graalvm.compiler.lir.phases.LIRSuites) Suites(org.graalvm.compiler.phases.tiers.Suites)

Aggregations

HostedProviders (com.oracle.graal.pointsto.meta.HostedProviders)1 RuntimeConfiguration (com.oracle.svm.core.graal.meta.RuntimeConfiguration)1 SubstrateReplacements (com.oracle.svm.core.graal.meta.SubstrateReplacements)1 GraalSupport (com.oracle.svm.graal.GraalSupport)1 SubstrateGraalRuntime (com.oracle.svm.graal.SubstrateGraalRuntime)1 SubstrateRuntimeConfigurationBuilder (com.oracle.svm.graal.meta.SubstrateRuntimeConfigurationBuilder)1 FeatureHandler (com.oracle.svm.hosted.FeatureHandler)1 BeforeAnalysisAccessImpl (com.oracle.svm.hosted.FeatureImpl.BeforeAnalysisAccessImpl)1 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)1 Backend (org.graalvm.compiler.core.target.Backend)1 DebugContext (org.graalvm.compiler.debug.DebugContext)1 NodeClass (org.graalvm.compiler.graph.NodeClass)1 LIRSuites (org.graalvm.compiler.lir.phases.LIRSuites)1 GraphEncoder (org.graalvm.compiler.nodes.GraphEncoder)1 Suites (org.graalvm.compiler.phases.tiers.Suites)1 Providers (org.graalvm.compiler.phases.util.Providers)1 WordTypes (org.graalvm.compiler.word.WordTypes)1