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;
}
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);
}
}
}
}
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;
}
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);
}
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);
}
}
Aggregations