Beispiel #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;
  }
 void _reset(Buffer b) {
   b.position(0);
   b.limit(b.capacity());
 }