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

Generate comments in -XX:+PrintInterpreter to link to source code

    Details

    • Type: Enhancement
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 11
    • Fix Version/s: 12
    • Component/s: hotspot
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      b03

      Description

      HotSpot's interpreter is dynamically generated (by C++ sources such as src/hotspot/cpu/x86/templateTable_x86.cpp).

      The command "java -XX:+UnlockDiagnosticVMOptions -XX:+PrintInterpreter" can be used to print a disassembly of the HotSpot interpreter. However, the output has very little comment, and it's very hard to associate the assembler instructions with the C++ code that generates them.

      To make it easier to understand the -XX:+PrintInterpreter, we should generate comments to link the instructions back to the C++ source code that generates them. This is doable because much of the interpreter code generation is done via a macro "__". We can redefine this macro to generate comments.

      Proof-of-concept:
      http://cr.openjdk.java.net/~iklam/misc/8204267-print-interpreter-comments.v00/

      Full example output:
      http://cr.openjdk.java.net/~iklam/misc/8204267-print-interpreter-comments.v00/hs_interp.S

      Here's an excerpt from the above output

      f2i 139 f2i [0x00007f830cc93840, 0x00007f830cc938a0] 96 bytes

      0x7f830cc93840: vmovss (%rsp),%xmm0
      0x7f830cc93845: add $0x8,%rsp
      0x7f830cc93849: vcvttss2si %xmm0,%eax ;; 1813: __ cvttss2sil(rax, xmm0);
      0x7f830cc9384d: cmp $0x80000000,%eax ;; 1814: __ cmpl(rax, 0x80000000); // NaN or overflow/underflow?
      0x7f830cc93853: jne 0x00007f830cc9387c ;; 1815: __ jcc(Assembler::notEqual, L);
      0x7f830cc93859: test $0xf,%esp ;; 1816: __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::f2i), 1);
      0x7f830cc9385f: je 0x00007f830cc93877
      0x7f830cc93865: sub $0x8,%rsp
      0x7f830cc93869: callq 0x00007f832ba976d0 = SharedRuntime::f2i(float)
      0x7f830cc9386e: add $0x8,%rsp
      0x7f830cc93872: jmpq 0x00007f830cc9387c
      0x7f830cc93877: callq 0x00007f832ba976d0 = SharedRuntime::f2i(float)
      0x7f830cc9387c: movzbl 0x1(%r13),%ebx ;; 1817: __ bind(L);
      0x7f830cc93881: inc %r13
      0x7f830cc93884: mov $0x7f832c055500,%r10
      0x7f830cc9388e: jmpq *(%r10,%rbx,8)

      ifeq 153 ifeq [0x00007f830cc93da0, 0x00007f830cc941c0] 1056 bytes

      0x7f830cc93da0: mov (%rsp),%eax
      0x7f830cc93da3: add $0x8,%rsp
      0x7f830cc93da7: test %eax,%eax ;; 2353: __ testl(rax, rax);
      0x7f830cc93da9: jne 0x00007f830cc94177 ;; 2354: __ jcc(j_not(cc), not_taken);
      0x7f830cc93daf: mov -0x18(%rbp),%rcx ;; 2120: __ get_method(rcx); // rcx holds method
      0x7f830cc93db3: mov -0x28(%rbp),%rax ;; 2121: __ profile_taken_branch(rax, rbx); // rax holds updated MDP, rbx
      0x7f830cc93db7: test %rax,%rax
      0x7f830cc93dba: je 0x00007f830cc93dd8
      0x7f830cc93dc0: mov 0x8(%rax),%rbx
      0x7f830cc93dc4: add $0x1,%rbx
      0x7f830cc93dc8: sbb $0x0,%rbx
      0x7f830cc93dcc: mov %rbx,0x8(%rax)
      0x7f830cc93dd0: add 0x10(%rax),%rax
      0x7f830cc93dd4: mov %rax,-0x28(%rbp)
      0x7f830cc93dd8: movswl 0x1(%r13),%edx ;; 2133: __ load_signed_short(rdx, at_bcp(1));
      0x7f830cc93ddd: bswap %edx ;; 2135: __ bswapl(rdx);
      0x7f830cc93ddf: sar $0x10,%edx ;; 2138: __ sarl(rdx, 16);
      0x7f830cc93de2: movslq %edx,%rdx ;; 2140: LP64_ONLY(__ movl2ptr(rdx, rdx));
      0x7f830cc93de5: add %rdx,%r13 ;; 2164: __ addptr(rbcp, rdx);
      0x7f830cc93de8: test %edx,%edx ;; 2179: __ testl(rdx, rdx); // check if forward or backward branch
      0x7f830cc93dea: jns 0x00007f830cc93eec ;; 2180: __ jcc(Assembler::positive, dispatch); // count only if backward branch
      0x7f830cc93df0: mov 0x18(%rcx),%rax ;; 2184: __ movptr(rax, Address(rcx, Method::method_counters_offset()));
      0x7f830cc93df4: test %rax,%rax ;; 2185: __ testptr(rax, rax);
      0x7f830cc93df7: jne 0x00007f830cc93ead ;; 2186: __ jcc(Assembler::notZero, has_counters);
      0x7f830cc93dfd: push %rdx ;; 2187: __ push(rdx);
      0x7f830cc93dfe: push %rcx ;; 2188: __ push(rcx);
      0x7f830cc93dff: callq 0x00007f830cc93e09 ;; 2189: __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::build_method_counters),

        Attachments

          Activity

            People

            • Assignee:
              iklam Ioi Lam
              Reporter:
              iklam Ioi Lam
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: