use of jdk.vm.ci.code.CompiledCode in project graal by oracle.
the class Backend method createInstalledCode.
/**
* Installs code based on a given compilation result.
*
* @param method the method compiled to produce {@code compiledCode} or {@code null} if the
* input to {@code compResult} was not a {@link ResolvedJavaMethod}
* @param compilationRequest the compilation request or {@code null}
* @param compilationResult the code to be installed
* @param predefinedInstalledCode a pre-allocated {@link InstalledCode} object to use as a
* reference to the installed code. If {@code null}, a new {@link InstalledCode}
* object will be created.
* @param speculationLog the speculation log to be used
* @param isDefault specifies if the installed code should be made the default implementation of
* {@code compRequest.getMethod()}. The default implementation for a method is the
* code executed for standard calls to the method. This argument is ignored if
* {@code compRequest == null}.
* @param context a custom debug context to use for the code installation
* @return a reference to the compiled and ready-to-run installed code
* @throws BailoutException if the code installation failed
*/
@SuppressWarnings("try")
public InstalledCode createInstalledCode(DebugContext debug, ResolvedJavaMethod method, CompilationRequest compilationRequest, CompilationResult compilationResult, SpeculationLog speculationLog, InstalledCode predefinedInstalledCode, boolean isDefault, Object[] context) {
Object[] debugContext = context != null ? context : new Object[] { getProviders().getCodeCache(), method, compilationResult };
CodeInstallationTask[] tasks;
synchronized (this) {
tasks = new CodeInstallationTask[codeInstallationTaskFactories.size()];
for (int i = 0; i < codeInstallationTaskFactories.size(); i++) {
tasks[i] = codeInstallationTaskFactories.get(i).create();
}
}
try (DebugContext.Scope s2 = debug.scope("CodeInstall", debugContext);
DebugContext.Activation a = debug.activate()) {
InstalledCode installedCode;
try {
preCodeInstallationTasks(tasks, compilationResult, predefinedInstalledCode);
CompiledCode compiledCode = createCompiledCode(method, compilationRequest, compilationResult);
installedCode = getProviders().getCodeCache().installCode(method, compiledCode, predefinedInstalledCode, speculationLog, isDefault);
assert predefinedInstalledCode == null || installedCode == predefinedInstalledCode;
} catch (Throwable t) {
failCodeInstallationTasks(tasks, t);
throw t;
}
postCodeInstallationTasks(tasks, installedCode);
return installedCode;
} catch (Throwable e) {
throw debug.handle(e);
}
}
use of jdk.vm.ci.code.CompiledCode 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);
}
}
}
}
Aggregations