Search in sources :

Example 6 with Backend

use of org.graalvm.compiler.core.target.Backend 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

Backend (org.graalvm.compiler.core.target.Backend)6 DebugContext (org.graalvm.compiler.debug.DebugContext)3 LIRSuites (org.graalvm.compiler.lir.phases.LIRSuites)3 Suites (org.graalvm.compiler.phases.tiers.Suites)3 HostedProviders (com.oracle.graal.pointsto.meta.HostedProviders)2 RuntimeConfiguration (com.oracle.svm.core.graal.meta.RuntimeConfiguration)2 SubstrateReplacements (com.oracle.svm.core.graal.meta.SubstrateReplacements)2 SnippetReflectionProvider (org.graalvm.compiler.api.replacements.SnippetReflectionProvider)2 Indent (org.graalvm.compiler.debug.Indent)2 InvocationPlugins (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins)2 Providers (org.graalvm.compiler.phases.util.Providers)2 WordTypes (org.graalvm.compiler.word.WordTypes)2 DeoptEntryInfopoint (com.oracle.svm.core.deopt.DeoptEntryInfopoint)1 SubstrateCompilationResult (com.oracle.svm.core.graal.code.SubstrateCompilationResult)1 SubstrateAMD64Backend (com.oracle.svm.core.graal.code.amd64.SubstrateAMD64Backend)1 SubstrateAMD64RegisterConfig (com.oracle.svm.core.graal.code.amd64.SubstrateAMD64RegisterConfig)1 ConfigKind (com.oracle.svm.core.graal.code.amd64.SubstrateAMD64RegisterConfig.ConfigKind)1 SubstrateCodeCacheProvider (com.oracle.svm.core.graal.meta.SubstrateCodeCacheProvider)1 SubstrateForeignCallsProvider (com.oracle.svm.core.graal.meta.SubstrateForeignCallsProvider)1 SubstrateLoweringProvider (com.oracle.svm.core.graal.meta.SubstrateLoweringProvider)1