Ejemplo n.º 1
0
  protected InstalledCode assembleMethod(Method m, CodeGenTest test) {
    ResolvedJavaMethod method = codeCache.lookupJavaMethod(m);
    RegisterConfig registerConfig = codeCache.lookupRegisterConfig();
    CallingConvention cc =
        CodeUtil.getCallingConvention(codeCache, CallingConvention.Type.JavaCallee, method, false);

    CompilationResult compResult = new CompilationResult();
    Buffer codeBuffer = test.generateCode(compResult, codeCache.getTarget(), registerConfig, cc);
    compResult.setTargetCode(codeBuffer.close(true), codeBuffer.position());

    InstalledCode code = codeCache.addMethod(method, compResult);

    DisassemblerProvider dis = Graal.getRuntime().getCapability(DisassemblerProvider.class);
    if (dis != null) {
      String disasm = dis.disassemble(code);
      Assert.assertTrue(code.toString(), disasm == null || disasm.length() > 0);
    }
    return code;
  }
Ejemplo n.º 2
0
 protected void assertReturn(
     String methodName, CodeGenTest test, Object expected, Object... args) {
   Object actual = runTest(methodName, test, args);
   Assert.assertEquals("unexpected return value", expected, actual);
 }