use of jdk.vm.ci.code.InstalledCode in project graal by oracle.
the class AMD64HotSpotFrameOmissionTest method testHelper.
private void testHelper(String name, CodeGenerator gen) {
ResolvedJavaMethod javaMethod = getResolvedJavaMethod(name);
InstalledCode installedCode = getCode(javaMethod);
TargetDescription target = getCodeCache().getTarget();
AMD64Assembler asm = new AMD64Assembler(target);
gen.generateCode(asm);
byte[] expectedCode = asm.close(true);
// Only compare up to expectedCode.length bytes to ignore
// padding instructions adding during code installation
byte[] actualCode = Arrays.copyOf(installedCode.getCode(), expectedCode.length);
Assert.assertArrayEquals(expectedCode, actualCode);
}
use of jdk.vm.ci.code.InstalledCode 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);
}
}
use of jdk.vm.ci.code.InstalledCode in project graal by oracle.
the class TruffleCallBoundaryInstrumentation method recordMark.
@Override
public Mark recordMark(Object id) {
Mark mark = super.recordMark(id);
if ((int) id == config.MARKID_VERIFIED_ENTRY) {
ResolvedJavaType optimizedCallTargetType = getRuntime().resolveType(metaAccess, "org.graalvm.compiler.truffle.runtime.hotspot.HotSpotOptimizedCallTarget");
int installedCodeOffset = getFieldOffset("installedCode", optimizedCallTargetType);
int entryPointOffset = getFieldOffset("entryPoint", metaAccess.lookupJavaType(InstalledCode.class));
injectTailCallCode(installedCodeOffset, entryPointOffset);
}
return mark;
}
use of jdk.vm.ci.code.InstalledCode in project graal by oracle.
the class DeoptimizeDirectiveTest method testZeroBranchProbability.
@Test
public void testZeroBranchProbability() {
ResolvedJavaMethod method = getResolvedJavaMethod("zeroBranchProbabilitySnippet");
Result expected = executeExpected(method, null, true);
InstalledCode code = getCode(method);
Result actual;
try {
actual = new Result(code.executeVarargs(true), null);
} catch (Exception e) {
actual = new Result(null, e);
}
assertEquals(expected, actual);
assertFalse("code should be invalidated", code.isValid());
}
use of jdk.vm.ci.code.InstalledCode in project graal by oracle.
the class DeoptimizeDirectiveTest method testDeoptimizeCheckValid.
private boolean testDeoptimizeCheckValid(ResolvedJavaMethod method) {
Result expected = executeExpected(method, null);
InstalledCode code = getCode(method);
Result actual;
try {
actual = new Result(code.executeVarargs(), null);
} catch (Exception e) {
actual = new Result(null, e);
}
assertEquals(expected, actual);
return code.isValid();
}
Aggregations