Search in sources :

Example 1 with DisassemblerProvider

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);
    }
}
Also used : CallingConvention(jdk.vm.ci.code.CallingConvention) RegisterConfig(jdk.vm.ci.code.RegisterConfig) CompilationIdentifier(org.graalvm.compiler.core.common.CompilationIdentifier) OptionValues(org.graalvm.compiler.options.OptionValues) DebugContext(org.graalvm.compiler.debug.DebugContext) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) DisassemblerProvider(org.graalvm.compiler.code.DisassemblerProvider) InstalledCode(jdk.vm.ci.code.InstalledCode) CompilationResult(org.graalvm.compiler.code.CompilationResult) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Aggregations

CallingConvention (jdk.vm.ci.code.CallingConvention)1 InstalledCode (jdk.vm.ci.code.InstalledCode)1 RegisterConfig (jdk.vm.ci.code.RegisterConfig)1 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)1 CompilationResult (org.graalvm.compiler.code.CompilationResult)1 DisassemblerProvider (org.graalvm.compiler.code.DisassemblerProvider)1 CompilationIdentifier (org.graalvm.compiler.core.common.CompilationIdentifier)1 DebugContext (org.graalvm.compiler.debug.DebugContext)1 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)1 OptionValues (org.graalvm.compiler.options.OptionValues)1