use of org.graalvm.compiler.code.DisassemblerProvider in project graal by oracle.
the class AssemblerTest method assembleMethod.
@SuppressWarnings("try")
protected InstalledCode assembleMethod(Method m, CodeGenTest test) {
ResolvedJavaMethod method = getMetaAccess().lookupJavaMethod(m);
OptionValues options = getInitialOptions();
DebugContext debug = getDebugContext(options);
try (DebugContext.Scope s = debug.scope("assembleMethod", method, codeCache)) {
RegisterConfig registerConfig = codeCache.getRegisterConfig();
CompilationIdentifier compilationId = backend.getCompilationIdentifier(method);
StructuredGraph graph = new StructuredGraph.Builder(options, debug).method(method).compilationId(compilationId).build();
CallingConvention cc = backend.newLIRGenerationResult(compilationId, null, null, graph, null).getCallingConvention();
CompilationResult compResult = new CompilationResult(graph.compilationId());
byte[] targetCode = test.generateCode(compResult, codeCache.getTarget(), registerConfig, cc);
compResult.setTargetCode(targetCode, targetCode.length);
compResult.setTotalFrameSize(0);
compResult.close();
InstalledCode code = backend.addInstalledCode(debug, method, asCompilationRequest(compilationId), compResult);
for (DisassemblerProvider dis : GraalServices.load(DisassemblerProvider.class)) {
String disasm1 = dis.disassembleCompiledCode(codeCache, compResult);
Assert.assertTrue(compResult.toString(), disasm1 == null || disasm1.length() > 0);
String disasm2 = dis.disassembleInstalledCode(codeCache, compResult, code);
Assert.assertTrue(code.toString(), disasm2 == null || disasm2.length() > 0);
}
return code;
} catch (Throwable e) {
throw debug.handle(e);
}
}
Aggregations