On 02/04/2018 12:31 AM, John Hening wrote:
> |
> publicstaticintdontOptimize;
> publicstaticintsimple(){
>  returndontOptimize;
> }
> |
> And JITed version of that:

>   0x00007fdc75112aa0:mov    %eax,-0x14000(%rsp)
>   0x00007fdc75112aa7:push   %rbp
>   0x00007fdc75112aa8:sub   $0x30,%rsp
>   *_0x00007fdc75112aac_*:mov    $0x7fdc7443be90,%rax  ;  {metadata(method data
> for{method}{0x00007fdc7443bb30}'simple''()I'in'Main')}
>   0x00007fdc75112ab6:mov    0xdc(%rax),%esi

> Though I know understand I cannot understand a such simple code. Especially, 
> what does lines between
> |0x00007fdc75112aac-|||_*0x00007fdc75112ad8*_| means? I highlighted it.

This is most likely the method compiled at level 2/3 (C1 with profiling), and 
the updates you see at
...aac are updates of profiling data. It is unlikely to be on hotpath -- if it 
is, this is the
performnace bug in tiered compilation machinery.

Zen question: How do you know you got the the version you have executed on hot 
path? With tiered
compilation, on-stack replacement, deoptimization, etc. there are much more 
than 1 version of the
method,  JMH's -prof perfasm can be used to highlight what version is actually 
executing. For example:

    public static int dontOptimize;

    public int test() {
        return dontOptimize;


C1, level 1, org.openjdk.StaticBench::test, version 443 (36 bytes)

        [Verified Entry Point]
  3.16%  0x00007f63c91b0e80: mov    %eax,-0x14000(%rsp)
  3.35%  0x00007f63c91b0e87: push   %rbp
  1.65%  0x00007f63c91b0e88: sub    $0x30,%rsp
  2.39%  0x00007f63c91b0e8c: movabs $0x782737b50,%rax  ; {oop(a 
  2.86%  0x00007f63c91b0e96: mov    0x68(%rax),%eax    ;*getstatic dontOptimize
                                                       ; - 
org.openjdk.StaticBench::test@0 (line 44)
  1.75%  0x00007f63c91b0e99: add    $0x30,%rsp
  1.26%  0x00007f63c91b0e9d: pop    %rbp
  0.82%  0x00007f63c91b0e9e: test   %eax,0x1774025c(%rip)        # 
                                                       ;   {poll_return}
  3.14%  0x00007f63c91b0ea4: retq

The method is trivial, and so compilation stops at level 1.

-XX:-TieredComplation yields:

C2, org.openjdk.StaticBench::test, version 82 (37 bytes)

         [Verified Entry Point]
  7.11%  0x00007fbdb109c6c0: sub    $0x18,%rsp
  0.18%  0x00007fbdb109c6c7: mov    %rbp,0x10(%rsp)    ;*synchronization entry
org.openjdk.StaticBench::test@-1 (line 44)
  0.04%  0x00007fbdb109c6cc: movabs $0x782647980,%r10  ;  {oop(a 
'java/lang/Class' =
  6.25%  0x00007fbdb109c6d6: mov    0x68(%r10),%eax    ;*getstatic dontOptimize
                                                       ; - 
org.openjdk.StaticBench::test@0 (line 44)
         0x00007fbdb109c6da: add    $0x10,%rsp
  0.08%  0x00007fbdb109c6de: pop    %rbp
 27.58%  0x00007fbdb109c6df: test   %eax,0xccef91b(%rip)   # 0x00007fbdbdd8c000
                                                       ;   {poll_return}
  0.02%  0x00007fbdb109c6e5: retq

...which is almost the same code, and this is why tiered compilation policy is 
happy with Level 1


You received this message because you are subscribed to the Google Groups 
"mechanical-sympathy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mechanical-sympathy+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to