Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8026297

Generate AdapterHandlerEntry during CDS dump



    • Enhancement
    • Resolution: Unresolved
    • P3
    • tbd
    • 15
    • hotspot


      We should generate the AdapterHandlerEntry's during CDS dump time (e.g., Method::make_adapters()). The goal is to avoid changing the contents of Method as much as possible. Currently in CDS, Method::_adapter is updated as soon as the class is loaded. This causes a lot of Methods to become dirty and reduces sharing.

      I looked at the i2c and c2i code on x64, and it seems doable because:

      [1] They are mostly position independent. There are a few calls to VM functions.
          These functions are in libjvm.so, so their locations may change. But I can fix this
          by jumping through a trampoline, since these calls are not on hot paths anyway.

      [2] The i2c and c2i functions are NOT patched during run time.

      [3] The code is independent of
          [a] choice of GC
          [b] Client vs Server compiler
          [c] mixed mode vs -Xcomp

      /* example of i2c/c2i code on x64 */

         0x7fffe10d72e0: mov (%rsp),%rax
         ...[debug code skipped]...
         0x7fffe10d73a7: mov %rsp,%r11
         0x7fffe10d73aa: and $0xfffffffffffffff0,%rsp
         0x7fffe10d73ae: push %rax
         0x7fffe10d73af: mov %r11,%rax
         0x7fffe10d73b2: mov 0x48(%rbx),%r11
         0x7fffe10d73b6: mov 0x8(%rax),%rsi
         0x7fffe10d73ba: mov %rbx,0x258(%r15)
         0x7fffe10d73c1: mov %rbx,%rax
         0x7fffe10d73c4: jmpq *%r11

         0x7fffe10d73c7: mov 0x8(%rsi),%ebx
         0x7fffe10d73ca: movabs $0x800000000,%r12 // compressed klass pointer(OK)
         0x7fffe10d73d4: add %r12,%rbx
         0x7fffe10d73d7: xor %r12,%r12
         0x7fffe10d73da: cmp 0x10(%rax),%rbx
         0x7fffe10d73de: mov 0x8(%rax),%rbx
         0x7fffe10d73e2: je 0x7fffe10d73ed
         0x7fffe10d73e8: jmpq 0x7fffe10d59e0 // FIX with trampoline: jump(RuntimeAddress(SharedRuntime::get_ic_miss_stub()));
         0x7fffe10d73ed: cmpq $0x0,0x50(%rbx)
         0x7fffe10d73f5: je 0x7fffe10d74f0
         0x7fffe10d73fb: jmpq 0x7fffe10d59e0 // FIX with trampoline: jump(RuntimeAddress(SharedRuntime::get_ic_miss_stub()));

         0x7fffe10d7400: cmpq $0x0,0x50(%rbx)
         0x7fffe10d7408: je 0x7fffe10d74f0
         0x7fffe10d740e: mov %rsp,%r13
         0x7fffe10d7411: mov (%rsp),%rax
         0x7fffe10d7415: and $0xfffffffffffffff0,%rsp
         0x7fffe10d7419: pushfq
         0x7fffe10d741a: sub $0x8,%rsp
         0x7fffe10d741e: mov %rsp,-0x28(%rsp)
         0x7fffe10d7423: sub $0x80,%rsp
         0x7fffe10d742a: mov %rax,0x78(%rsp)
         0x7fffe10d742f: mov %rcx,0x70(%rsp)
         0x7fffe10d7434: mov %rdx,0x68(%rsp)
         0x7fffe10d7439: mov %rbx,0x60(%rsp)
         0x7fffe10d743e: mov %rbp,0x50(%rsp)
         0x7fffe10d7443: mov %rsi,0x48(%rsp)
         0x7fffe10d7448: mov %rdi,0x40(%rsp)
         0x7fffe10d744d: mov %r8,0x38(%rsp)
         0x7fffe10d7452: mov %r9,0x30(%rsp)
         0x7fffe10d7457: mov %r10,0x28(%rsp)
         0x7fffe10d745c: mov %r11,0x20(%rsp)
         0x7fffe10d7461: mov %r12,0x18(%rsp)
         0x7fffe10d7466: mov %r13,0x10(%rsp)
         0x7fffe10d746b: mov %r14,0x8(%rsp)
         0x7fffe10d7470: mov %r15,(%rsp)
         0x7fffe10d7474: sub $0x200,%rsp
         0x7fffe10d747b: fxsave64 (%rsp)
         0x7fffe10d7480: mov %rbx,%rdi
         0x7fffe10d7483: mov %rax,%rsi
         0x7fffe10d7486: callq 0x7ffff72dd2c6 <SharedRuntime::fixup_callers_callsite(Method*, address)>// Fix with trampoline
         0x7fffe10d748b: fxrstor64 (%rsp)
         0x7fffe10d7490: add $0x200,%rsp
         0x7fffe10d7497: mov (%rsp),%r15
         0x7fffe10d749b: mov 0x8(%rsp),%r14
         0x7fffe10d74a0: mov 0x10(%rsp),%r13
         0x7fffe10d74a5: mov 0x18(%rsp),%r12
         0x7fffe10d74aa: mov 0x20(%rsp),%r11
         0x7fffe10d74af: mov 0x28(%rsp),%r10
         0x7fffe10d74b4: mov 0x30(%rsp),%r9
         0x7fffe10d74b9: mov 0x38(%rsp),%r8
         0x7fffe10d74be: mov 0x40(%rsp),%rdi
         0x7fffe10d74c3: mov 0x48(%rsp),%rsi
         0x7fffe10d74c8: mov 0x50(%rsp),%rbp
         0x7fffe10d74cd: mov 0x60(%rsp),%rbx
         0x7fffe10d74d2: mov 0x68(%rsp),%rdx
         0x7fffe10d74d7: mov 0x70(%rsp),%rcx
         0x7fffe10d74dc: mov 0x78(%rsp),%rax
         0x7fffe10d74e1: add $0x80,%rsp
         0x7fffe10d74e8: add $0x8,%rsp
         0x7fffe10d74ec: popfq
         0x7fffe10d74ed: mov %r13,%rsp
         0x7fffe10d74f0: pop %rax
         0x7fffe10d74f1: mov %rsp,%r13
         0x7fffe10d74f4: sub $0x10,%rsp
         0x7fffe10d74f8: mov %rax,(%rsp)
         0x7fffe10d74fc: mov %rsi,0x8(%rsp)
         0x7fffe10d7501: mov 0x38(%rbx),%rcx
         0x7fffe10d7505: jmpq *%rcx
         0x7fffe10d7507: int3


        Issue Links



              iklam Ioi Lam
              iklam Ioi Lam
              0 Vote for this issue
              4 Start watching this issue