> On 19 Nov 2017, at 16:32, John Hening <gocio...@gmail.com> wrote: > > I am analyzing the following Java code: > > class Main { > > private static class C{ > private C ref; > } > > > private static void foo(C c, C c2){ > c.ref = c2; > } > } > > > > > > > And JITed version of it: > > > [Entry Point] > [Verified Entry Point] > [Constants] > # {method} {0x00007ff5b3c02af8} 'foo' '(LMain$C;LMain$C;)V' in 'Main' > # parm0: rsi:rsi = 'Main$C' > # parm1: rdx:rdx = 'Main$C' > # [sp+0x50] (sp of caller) > 0x00007ff5c110cc60: mov %eax,-0x14000(%rsp) > 0x00007ff5c110cc67: push %rbp > 0x00007ff5c110cc68: sub $0x40,%rsp > 0x00007ff5c110cc6c: mov $0x7ff5b3c03200,%rdi ; What is value the > $0x7ff5b3c03200? (1) > 0x00007ff5c110cc76: mov 0x8(%rdi),%ebx > 0x00007ff5c110cc79: add $0x8,%ebx > 0x00007ff5c110cc7c: mov %ebx,0x8(%rdi) > 0x00007ff5c110cc7f: mov $0x7ff5b3c02af8,%rdi ; {metadata({method} > {0x00007ff5b3c02af8} 'foo' '(LMain$C;LMain$C;)V' in 'Main')} > 0x00007ff5c110cc89: and $0x3ff8,%ebx ; What is the value > $0x3ff8 (2) > 0x00007ff5c110cc8f: cmp $0x0,%ebx > 0x00007ff5c110cc92: je 0x00007ff5c110ccc1 ;*aload_0 > ; - Main::foo@0 (line 11) > > 0x00007ff5c110cc98: mov %rdx,%r10 > 0x00007ff5c110cc9b: shr $0x3,%r10 ; Why a param1(reference > to c2) is shifted right by 3? (3) > 0x00007ff5c110cc9f: mov %r10d,0xc(%rsi) ; implicit exception: > dispatches to 0x00007ff5c110ccd5 > 0x00007ff5c110cca3: shr $0x9,%rsi > 0x00007ff5c110cca7: mov $0x7ff5d13bd000,%rdi > 0x00007ff5c110ccb1: movb $0x0,(%rsi,%rdi,1) ;*putfield ref > ; - Main$C::access$002@3 > (line 6) > ; - Main::foo@2 (line 11) > > 0x00007ff5c110ccb5: add $0x40,%rsp > 0x00007ff5c110ccb9: pop %rbp > 0x00007ff5c110ccba: test %eax,0x17d2c440(%rip) # > 0x00007ff5d8e39100 What is a constant 0x17d2c440? > ; {poll_return} > 0x00007ff5c110ccc0: retq > 0x00007ff5c110ccc1: mov %rdi,0x8(%rsp) > 0x00007ff5c110ccc6: movq $0xffffffffffffffff,(%rsp) > 0x00007ff5c110ccce: callq 0x00007ff5c1101560 ; OopMap{rsi=Oop rdx=Oop > off=115} > ;*synchronization entry > ; - Main::foo@-1 (line 11) > ; {runtime_call} > 0x00007ff5c110ccd3: jmp 0x00007ff5c110cc98 > 0x00007ff5c110ccd5: callq 0x00007ff5c106f7c0 ; OopMap{rsi=Oop off=122} > ;*putfield ref > ; - Main$C::access$002@3 > (line 6) > ; - Main::foo@2 (line 11) > ; {runtime_call} > 0x00007ff5c110ccda: nop > 0x00007ff5c110ccdb: nop > 0x00007ff5c110ccdc: mov 0x290(%r15),%rax > 0x00007ff5c110cce3: mov $0x0,%r10 > 0x00007ff5c110cced: mov %r10,0x290(%r15) > 0x00007ff5c110ccf4: mov $0x0,%r10 > 0x00007ff5c110ccfe: mov %r10,0x298(%r15) > 0x00007ff5c110cd05: add $0x40,%rsp > 0x00007ff5c110cd09: pop %rbp > 0x00007ff5c110cd0a: jmpq 0x00007ff5c106e3e0 ; {runtime_call} > > > > > I don't understand some issues, and I would like to someone ask for it: > > I've annotated line in the assembly code with numbers. For example, > The first question (1.) refers to the line annotated with (1). And so on. > > 1. What is value the $0x7ff5b3c03200? > 2. What is the value $0x3ff8? > 3. Why a param1(reference to c2) is shifted right by 3? >
I have a presentation on Hotspot under the Hood at JavaOne in 2016 which talks a little bit about how some of this works (including right shifting references). You might find it instructive to look through that deck. I also recorded a voice-over of the presentation at Vimeo, in case you want to watch it as a video. Unfortunately it wasn’t recorded live at JavaOne itself. http://alblue.bandlem.com/2016/09/javaone-hotspot.html -- 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.