29 import org.graalvm.compiler.api.test.Graal; |
29 import org.graalvm.compiler.api.test.Graal; |
30 import org.graalvm.compiler.code.CompilationResult; |
30 import org.graalvm.compiler.code.CompilationResult; |
31 import org.graalvm.compiler.code.DisassemblerProvider; |
31 import org.graalvm.compiler.code.DisassemblerProvider; |
32 import org.graalvm.compiler.core.common.CompilationIdentifier; |
32 import org.graalvm.compiler.core.common.CompilationIdentifier; |
33 import org.graalvm.compiler.core.target.Backend; |
33 import org.graalvm.compiler.core.target.Backend; |
34 import org.graalvm.compiler.debug.Debug; |
34 import org.graalvm.compiler.debug.DebugContext; |
35 import org.graalvm.compiler.debug.Debug.Scope; |
|
36 import org.graalvm.compiler.nodes.StructuredGraph; |
35 import org.graalvm.compiler.nodes.StructuredGraph; |
37 import org.graalvm.compiler.options.OptionValues; |
36 import org.graalvm.compiler.options.OptionValues; |
38 import org.graalvm.compiler.runtime.RuntimeProvider; |
37 import org.graalvm.compiler.runtime.RuntimeProvider; |
39 import org.graalvm.compiler.serviceprovider.GraalServices; |
38 import org.graalvm.compiler.serviceprovider.GraalServices; |
40 import org.graalvm.compiler.test.GraalTest; |
39 import org.graalvm.compiler.test.GraalTest; |
81 } |
80 } |
82 |
81 |
83 @SuppressWarnings("try") |
82 @SuppressWarnings("try") |
84 protected InstalledCode assembleMethod(Method m, CodeGenTest test) { |
83 protected InstalledCode assembleMethod(Method m, CodeGenTest test) { |
85 ResolvedJavaMethod method = getMetaAccess().lookupJavaMethod(m); |
84 ResolvedJavaMethod method = getMetaAccess().lookupJavaMethod(m); |
86 try (Scope s = Debug.scope("assembleMethod", method, codeCache)) { |
85 OptionValues options = getInitialOptions(); |
|
86 DebugContext debug = getDebugContext(options); |
|
87 try (DebugContext.Scope s = debug.scope("assembleMethod", method, codeCache)) { |
87 RegisterConfig registerConfig = codeCache.getRegisterConfig(); |
88 RegisterConfig registerConfig = codeCache.getRegisterConfig(); |
88 CompilationIdentifier compilationId = backend.getCompilationIdentifier(method); |
89 CompilationIdentifier compilationId = backend.getCompilationIdentifier(method); |
89 StructuredGraph graph = new StructuredGraph.Builder(getInitialOptions()).method(method).compilationId(compilationId).build(); |
90 StructuredGraph graph = new StructuredGraph.Builder(options, debug).method(method).compilationId(compilationId).build(); |
90 CallingConvention cc = backend.newLIRGenerationResult(compilationId, null, null, graph, null).getCallingConvention(); |
91 CallingConvention cc = backend.newLIRGenerationResult(compilationId, null, null, graph, null).getCallingConvention(); |
91 |
92 |
92 CompilationResult compResult = new CompilationResult(); |
93 CompilationResult compResult = new CompilationResult(); |
93 byte[] targetCode = test.generateCode(compResult, codeCache.getTarget(), registerConfig, cc); |
94 byte[] targetCode = test.generateCode(compResult, codeCache.getTarget(), registerConfig, cc); |
94 compResult.setTargetCode(targetCode, targetCode.length); |
95 compResult.setTargetCode(targetCode, targetCode.length); |
95 compResult.setTotalFrameSize(0); |
96 compResult.setTotalFrameSize(0); |
96 compResult.close(); |
97 compResult.close(); |
97 |
98 |
98 InstalledCode code = backend.addInstalledCode(method, asCompilationRequest(compilationId), compResult); |
99 InstalledCode code = backend.addInstalledCode(debug, method, asCompilationRequest(compilationId), compResult); |
99 |
100 |
100 for (DisassemblerProvider dis : GraalServices.load(DisassemblerProvider.class)) { |
101 for (DisassemblerProvider dis : GraalServices.load(DisassemblerProvider.class)) { |
101 String disasm1 = dis.disassembleCompiledCode(codeCache, compResult); |
102 String disasm1 = dis.disassembleCompiledCode(codeCache, compResult); |
102 Assert.assertTrue(compResult.toString(), disasm1 == null || disasm1.length() > 0); |
103 Assert.assertTrue(compResult.toString(), disasm1 == null || disasm1.length() > 0); |
103 String disasm2 = dis.disassembleInstalledCode(codeCache, compResult, code); |
104 String disasm2 = dis.disassembleInstalledCode(codeCache, compResult, code); |
104 Assert.assertTrue(code.toString(), disasm2 == null || disasm2.length() > 0); |
105 Assert.assertTrue(code.toString(), disasm2 == null || disasm2.length() > 0); |
105 } |
106 } |
106 return code; |
107 return code; |
107 } catch (Throwable e) { |
108 } catch (Throwable e) { |
108 throw Debug.handle(e); |
109 throw debug.handle(e); |
109 } |
110 } |
110 } |
111 } |
111 |
112 |
112 protected Object runTest(String methodName, CodeGenTest test, Object... args) { |
113 protected Object runTest(String methodName, CodeGenTest test, Object... args) { |
113 Method method = getMethod(methodName); |
114 Method method = getMethod(methodName); |