Search in sources :

Example 1 with CodeCacheProvider

use of jdk.vm.ci.code.CodeCacheProvider in project graal by oracle.

the class Stub method getCode.

/**
 * Gets the code for this stub, compiling it first if necessary.
 */
@SuppressWarnings("try")
public synchronized InstalledCode getCode(final Backend backend) {
    if (code == null) {
        try (DebugContext debug = openDebugContext(DebugContext.forCurrentThread())) {
            try (DebugContext.Scope d = debug.scope("CompilingStub", providers.getCodeCache(), debugScopeContext())) {
                CodeCacheProvider codeCache = providers.getCodeCache();
                CompilationResult compResult = buildCompilationResult(debug, backend);
                try (DebugContext.Scope s = debug.scope("CodeInstall", compResult);
                    DebugContext.Activation a = debug.activate()) {
                    assert destroyedCallerRegisters != null;
                    // Add a GeneratePIC check here later, we don't want to install
                    // code if we don't have a corresponding VM global symbol.
                    HotSpotCompiledCode compiledCode = HotSpotCompiledCodeBuilder.createCompiledCode(codeCache, null, null, compResult);
                    code = codeCache.installCode(null, compiledCode, null, null, false);
                } catch (Throwable e) {
                    throw debug.handle(e);
                }
            } catch (Throwable e) {
                throw debug.handle(e);
            }
            assert code != null : "error installing stub " + this;
        }
    }
    return code;
}
Also used : HotSpotCompiledCode(jdk.vm.ci.hotspot.HotSpotCompiledCode) DebugContext(org.graalvm.compiler.debug.DebugContext) CompilationResult(org.graalvm.compiler.code.CompilationResult) CodeCacheProvider(jdk.vm.ci.code.CodeCacheProvider)

Example 2 with CodeCacheProvider

use of jdk.vm.ci.code.CodeCacheProvider in project graal by oracle.

the class HotSpotTruffleCompilerImpl method installTruffleCallBoundaryMethods.

/**
 * @see #compileTruffleCallBoundaryMethod
 */
@Override
@SuppressWarnings("try")
public void installTruffleCallBoundaryMethods() {
    HotSpotTruffleCompilerRuntime runtime = (HotSpotTruffleCompilerRuntime) TruffleCompilerRuntime.getRuntime();
    for (ResolvedJavaMethod method : runtime.getTruffleCallBoundaryMethods()) {
        HotSpotCompilationIdentifier compilationId = (HotSpotCompilationIdentifier) backend.getCompilationIdentifier(method);
        OptionValues options = getOptions();
        try (DebugContext debug = DebugStubsAndSnippets.getValue(options) ? hotspotGraalRuntime.openDebugContext(options, compilationId, method, getDebugHandlerFactories()) : DebugContext.DISABLED;
            Activation a = debug.activate();
            DebugContext.Scope d = debug.scope("InstallingTruffleStub")) {
            CompilationResult compResult = compileTruffleCallBoundaryMethod(method, compilationId, debug);
            CodeCacheProvider codeCache = providers.getCodeCache();
            try (DebugContext.Scope s = debug.scope("CodeInstall", codeCache, method, compResult)) {
                CompiledCode compiledCode = HotSpotCompiledCodeBuilder.createCompiledCode(codeCache, method, compilationId.getRequest(), compResult);
                codeCache.setDefaultCode(method, compiledCode);
            } catch (Throwable e) {
                throw debug.handle(e);
            }
        }
    }
}
Also used : OptionValues(org.graalvm.compiler.options.OptionValues) HotSpotCompilationIdentifier(org.graalvm.compiler.hotspot.HotSpotCompilationIdentifier) Activation(org.graalvm.compiler.debug.DebugContext.Activation) CompiledCode(jdk.vm.ci.code.CompiledCode) DebugContext(org.graalvm.compiler.debug.DebugContext) CompilationResult(org.graalvm.compiler.code.CompilationResult) HotSpotCodeCacheProvider(jdk.vm.ci.hotspot.HotSpotCodeCacheProvider) CodeCacheProvider(jdk.vm.ci.code.CodeCacheProvider) HotSpotTruffleCompilerRuntime(org.graalvm.compiler.truffle.common.hotspot.HotSpotTruffleCompilerRuntime) HotSpotResolvedJavaMethod(jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Example 3 with CodeCacheProvider

use of jdk.vm.ci.code.CodeCacheProvider in project graal by oracle.

the class SharedRuntimeConfigurationBuilder method build.

public SharedRuntimeConfigurationBuilder build() {
    wordTypes = new WordTypes(metaAccess, FrameAccess.getWordKind());
    Providers p = createProviders(null, null, null, null, null, null, null, null);
    StampProvider stampProvider = createStampProvider(p);
    p = createProviders(null, null, null, null, null, null, stampProvider, null);
    ConstantReflectionProvider constantReflection = createConstantReflectionProvider(p);
    ConstantFieldProvider constantFieldProvider = createConstantFieldProvider(p);
    createProviders(null, constantReflection, constantFieldProvider, null, null, null, stampProvider, null);
    SnippetReflectionProvider snippetReflection = createSnippetReflectionProvider();
    createProviders(null, constantReflection, constantFieldProvider, null, null, null, stampProvider, snippetReflection);
    ForeignCallsProvider foreignCalls = createForeignCallsProvider();
    p = createProviders(null, constantReflection, constantFieldProvider, foreignCalls, null, null, stampProvider, snippetReflection);
    LoweringProvider lowerer = createLoweringProvider(p);
    p = createProviders(null, constantReflection, constantFieldProvider, foreignCalls, lowerer, null, stampProvider, snippetReflection);
    Replacements replacements = createReplacements(p, snippetReflection);
    p = createProviders(null, constantReflection, constantFieldProvider, foreignCalls, lowerer, replacements, stampProvider, snippetReflection);
    EnumMap<ConfigKind, Backend> backends = new EnumMap<>(ConfigKind.class);
    for (ConfigKind config : ConfigKind.values()) {
        RegisterConfig registerConfig = new SubstrateAMD64RegisterConfig(config, metaAccess, ConfigurationValues.getTarget());
        CodeCacheProvider codeCacheProvider = createCodeCacheProvider(registerConfig);
        Providers newProviders = createProviders(codeCacheProvider, constantReflection, constantFieldProvider, foreignCalls, lowerer, replacements, stampProvider, snippetReflection);
        backends.put(config, GraalConfiguration.instance().createBackend(newProviders));
    }
    runtimeConfig = new RuntimeConfiguration(p, snippetReflection, backends, wordTypes);
    return this;
}
Also used : ForeignCallsProvider(org.graalvm.compiler.core.common.spi.ForeignCallsProvider) SubstrateForeignCallsProvider(com.oracle.svm.core.graal.meta.SubstrateForeignCallsProvider) SubstrateStampProvider(com.oracle.svm.core.graal.meta.SubstrateStampProvider) StampProvider(org.graalvm.compiler.nodes.spi.StampProvider) RegisterConfig(jdk.vm.ci.code.RegisterConfig) SubstrateAMD64RegisterConfig(com.oracle.svm.core.graal.code.amd64.SubstrateAMD64RegisterConfig) Replacements(org.graalvm.compiler.nodes.spi.Replacements) WordTypes(org.graalvm.compiler.word.WordTypes) SubstrateAMD64RegisterConfig(com.oracle.svm.core.graal.code.amd64.SubstrateAMD64RegisterConfig) LoweringProvider(org.graalvm.compiler.nodes.spi.LoweringProvider) SubstrateLoweringProvider(com.oracle.svm.core.graal.meta.SubstrateLoweringProvider) ConfigKind(com.oracle.svm.core.graal.code.amd64.SubstrateAMD64RegisterConfig.ConfigKind) Providers(org.graalvm.compiler.phases.util.Providers) SubstrateCodeCacheProvider(com.oracle.svm.core.graal.meta.SubstrateCodeCacheProvider) CodeCacheProvider(jdk.vm.ci.code.CodeCacheProvider) RuntimeConfiguration(com.oracle.svm.core.graal.meta.RuntimeConfiguration) SubstrateSnippetReflectionProvider(com.oracle.svm.core.graal.meta.SubstrateSnippetReflectionProvider) SnippetReflectionProvider(org.graalvm.compiler.api.replacements.SnippetReflectionProvider) Backend(org.graalvm.compiler.core.target.Backend) ConstantReflectionProvider(jdk.vm.ci.meta.ConstantReflectionProvider) EnumMap(java.util.EnumMap) ConstantFieldProvider(org.graalvm.compiler.core.common.spi.ConstantFieldProvider)

Example 4 with CodeCacheProvider

use of jdk.vm.ci.code.CodeCacheProvider in project graal by oracle.

the class JVMCIInfopointErrorTest method test.

private void test(DebugContext debug, TestSpec spec) {
    ResolvedJavaMethod method = getResolvedJavaMethod("testMethod");
    StructuredGraph graph = parseForCompile(method, debug);
    TestNode test = graph.add(new TestNode(spec));
    graph.addAfterFixed(graph.start(), test);
    CompilationResult compResult = compile(method, graph);
    CodeCacheProvider codeCache = getCodeCache();
    HotSpotCompiledCode compiledCode = HotSpotCompiledCodeBuilder.createCompiledCode(codeCache, method, null, compResult);
    codeCache.addCode(method, compiledCode, null, null);
}
Also used : HotSpotCompiledCode(jdk.vm.ci.hotspot.HotSpotCompiledCode) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) CompilationResult(org.graalvm.compiler.code.CompilationResult) CodeCacheProvider(jdk.vm.ci.code.CodeCacheProvider) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Example 5 with CodeCacheProvider

use of jdk.vm.ci.code.CodeCacheProvider in project graal by oracle.

the class CompilationTask method installMethod.

@SuppressWarnings("try")
private void installMethod(DebugContext debug, final CompilationResult compResult) {
    final CodeCacheProvider codeCache = jvmciRuntime.getHostJVMCIBackend().getCodeCache();
    HotSpotBackend backend = compiler.getGraalRuntime().getHostBackend();
    installedCode = null;
    Object[] context = { new DebugDumpScope(getIdString(), true), codeCache, getMethod(), compResult };
    try (DebugContext.Scope s = debug.scope("CodeInstall", context)) {
        installedCode = (HotSpotInstalledCode) backend.createInstalledCode(debug, getRequest().getMethod(), getRequest(), compResult, getRequest().getMethod().getSpeculationLog(), null, installAsDefault, context);
    } catch (Throwable e) {
        throw debug.handle(e);
    }
}
Also used : DebugDumpScope(org.graalvm.compiler.debug.DebugDumpScope) DebugContext(org.graalvm.compiler.debug.DebugContext) CodeCacheProvider(jdk.vm.ci.code.CodeCacheProvider)

Aggregations

CodeCacheProvider (jdk.vm.ci.code.CodeCacheProvider)6 CompilationResult (org.graalvm.compiler.code.CompilationResult)4 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)3 DebugContext (org.graalvm.compiler.debug.DebugContext)3 HotSpotCompiledCode (jdk.vm.ci.hotspot.HotSpotCompiledCode)2 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)2 OptionValues (org.graalvm.compiler.options.OptionValues)2 SubstrateAMD64RegisterConfig (com.oracle.svm.core.graal.code.amd64.SubstrateAMD64RegisterConfig)1 ConfigKind (com.oracle.svm.core.graal.code.amd64.SubstrateAMD64RegisterConfig.ConfigKind)1 RuntimeConfiguration (com.oracle.svm.core.graal.meta.RuntimeConfiguration)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 SubstrateSnippetReflectionProvider (com.oracle.svm.core.graal.meta.SubstrateSnippetReflectionProvider)1 SubstrateStampProvider (com.oracle.svm.core.graal.meta.SubstrateStampProvider)1 BufferedOutputStream (java.io.BufferedOutputStream)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 OutputStream (java.io.OutputStream)1 Path (java.nio.file.Path)1