use of org.graalvm.compiler.code.CompilationResult in project graal by oracle.
the class DeoptEntryOp method emitCode.
@Override
public void emitCode(CompilationResultBuilder crb) {
CompilationResult compilation = crb.compilationResult;
/* Search for the previous added info point. */
List<Infopoint> infoPoints = compilation.getInfopoints();
int size = infoPoints.size();
for (int idx = size - 1; idx >= 0; idx--) {
Infopoint infopoint = infoPoints.get(idx);
int entryOffset = CodeInfoEncoder.getEntryOffset(infopoint);
if (entryOffset >= 0) {
if (entryOffset == crb.asm.position()) {
crb.asm.ensureUniquePC();
break;
}
}
}
/* Register this location as a deopt infopoint. */
compilation.addInfopoint(new DeoptEntryInfopoint(crb.asm.position(), state.debugInfo()));
/* Add NOP so that the next infopoint (e.g., an invoke) gets a unique PC. */
crb.asm.ensureUniquePC();
}
use of org.graalvm.compiler.code.CompilationResult in project graal by oracle.
the class SubstrateGraalUtils method doCompile.
/**
* Actual method compilation.
*
* For zone allocation this is where the zone boundary can be placed when the code is only
* compiled. However using the returned compilation result would result into a zone allocation
* invariant violation.
*/
private static CompilationResult doCompile(DebugContext initialDebug, RuntimeConfiguration runtimeConfig, Suites suites, LIRSuites lirSuites, final SubstrateMethod method) {
String methodString = method.format("%H.%n(%p)");
SubstrateCompilationIdentifier compilationId = new SubstrateCompilationIdentifier();
return new CompilationWrapper<CompilationResult>(GraalSupport.get().getDebugOutputDirectory(), compilationProblemsPerAction) {
@SuppressWarnings({ "unchecked", "unused" })
<E extends Throwable> RuntimeException silenceThrowable(Class<E> type, Throwable ex) throws E {
throw (E) ex;
}
@Override
protected CompilationResult handleException(Throwable t) {
throw silenceThrowable(RuntimeException.class, t);
}
@Override
protected CompilationResult performCompilation(DebugContext debug) {
StructuredGraph graph = GraalSupport.decodeGraph(debug, null, compilationId, method);
return compileGraph(runtimeConfig, suites, lirSuites, method, graph);
}
@Override
public String toString() {
return methodString;
}
@Override
protected DebugContext createRetryDebugContext(OptionValues options) {
return GraalSupport.get().openDebugContext(options, compilationId, method);
}
}.run(initialDebug);
}
use of org.graalvm.compiler.code.CompilationResult in project graal by oracle.
the class SubstrateGraalUtils method doCompileAndInstall.
/**
* This method does the actual compilation and installation of the method. Nothing is returned
* by this call. The code is installed via pinned objects and the address is updated in the
* {@link InstalledCode} argument.
*
* For zone allocation this is where the zone boundary can be placed when the code needs to be
* compiled and installed.
*/
private static void doCompileAndInstall(DebugContext debug, RuntimeConfiguration runtimeConfig, Suites suites, LIRSuites lirSuites, SubstrateMethod method, SubstrateInstalledCodeImpl installedCode, boolean testTrampolineJumps) {
CompilationResult compilationResult = doCompile(debug, runtimeConfig, suites, lirSuites, method);
installMethod(method, compilationResult, installedCode, testTrampolineJumps);
}
use of org.graalvm.compiler.code.CompilationResult 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 org.graalvm.compiler.code.CompilationResult in project graal by oracle.
the class GraalCompilerAssumptionsTest method testAssumption.
/**
* Checks the behavior of class loading on {@link Assumption invalidation}. {@code methodName}
* is compiled and the resulting graph is checked for {@code expectedAssumption}. The code is
* installed and optionally {@code classToLoad} is loaded. The class is assumed to be an inner
* class of the test class and the name of the class to load is constructed relative to that.
*
* @param methodName the method to compile
* @param expectedAssumption expected {@link Assumption} instance to find in graph
* @param classToLoad an optional class to load to trigger an invalidation check
* @param willInvalidate true if loading {@code classToLoad} should invalidate the method
*/
protected void testAssumption(String methodName, Assumption expectedAssumption, String classToLoad, boolean willInvalidate) {
ResolvedJavaMethod javaMethod = getResolvedJavaMethod(methodName);
StructuredGraph graph = parseEager(javaMethod, AllowAssumptions.YES);
assertTrue(!graph.getAssumptions().isEmpty());
checkGraph(expectedAssumption, graph);
CompilationResult compilationResult = compile(javaMethod, graph);
final InstalledCode installedCode = getBackend().createDefaultInstalledCode(graph.getDebug(), javaMethod, compilationResult);
assertTrue(installedCode.isValid());
if (classToLoad != null) {
String fullName = getClass().getName() + "$" + classToLoad;
try {
Class.forName(fullName);
} catch (ClassNotFoundException e) {
fail("Can't find class %s", fullName);
}
assertTrue(!willInvalidate == installedCode.isValid(), "method should be %s", willInvalidate ? "invalid" : "valid");
}
}
Aggregations