> On 3 Feb 2018, at 23:31, John Hening <gocio...@gmail.com> wrote:
> 
> public static int dontOptimize;
> 
> 
> public static int simple(){
>  return dontOptimize;
> }
> 
> 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
>   0x00007fdc75112abc: add    $0x8,%esi
>   0x00007fdc75112abf: mov    %esi,0xdc(%rax)
>   0x00007fdc75112ac5: mov    $0x7fdc7443bb30,%rax  ;   {metadata({method} 
> {0x00007fdc7443bb30} 'simple' '()I' in 'Main')}
>   0x00007fdc75112acf: and    $0x1ff8,%esi
>   0x00007fdc75112ad5: cmp    $0x0,%esi
>   0x00007fdc75112ad8: je     0x00007fdc75112af7
>   0x00007fdc75112ade: mov    $0x76d2414f0,%rax  ;   {oop(a 'java/lang/Class' 
> = 'Main')}
>   0x00007fdc75112ae8: mov    0x68(%rax),%eax    ;*getstatic dontOptimize
>                                                 ; - Main::simple@0 (line 11)
> 
>   0x00007fdc75112aeb: add    $0x30,%rsp
>   0x00007fdc75112aef: pop    %rbp
>   0x00007fdc75112af0: test   %eax,0x1861060a(%rip)        # 0x00007fdc8d723100
>                                                 ;   {poll_return}
>   0x00007fdc75112af6: retq   
> 
> 
> 
> 
> 
> Though I know understand I cannot understand a such simple code. Especially, 
> what does lines between 0x00007fdc75112aac-0x00007fdc75112ad8 means? I 
> highlighted it. 

This is profiling information. It is accessing the metadata for the method, and 
adding 8 each time it’s called. The comparison is checking for overflow of that 
counter, and jumping elsewhere if that’s the case. 

It’s effectively equivalent to:

if method.getMetadata().count++ > 0x1ff8 / 8 goto elsewhere

The purpose is to determine whether or not the method has been called a number 
of times (i.e. it is “hot”) and will then get called into the C2 compiler to 
re-optimise the method. 

Alex 

-- 
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.

Reply via email to