Assembler questions

Krystal Mok rednaxelafx at gmail.com
Mon Apr 16 03:31:30 PDT 2012


Hi Remi,

Apparently the original code was trying to do something like:

if (obj.getClass() == A.class) {
  A a = (A) obj;
  // ...
}

Right?

If the condition was

if (obj instanceof A)

then the checkcast would have been elided.

Maybe this kind of code pattern should be recognized by C2 in a future
enhancement?

Regards,
Kris

On Mon, Apr 16, 2012 at 5:59 PM, Rémi Forax <forax at univ-mlv.fr> wrote:

> Hi guys,
> I'm trying to read some assembler dump printed by hsdis.
>
> In the snippet below, I don't understand why there is a %r12 in the middle
> of the mov.
> Is some intermediary result stored in %r12 ?
> Is it equivalent to
>  move 0x8(%r11), %r12
>  move 0x78(%r12), %rbp ?
>
> Another question more related to the layout of the class in hotspot.
> It seems there are two kinds of class pointer, the one with the type
> java/lang/Class
> and another one used by checkcast (oop('A')).
> I suppose it's the same object at two different offsets perhaps the Java
> one and the C++ one
> but  I don't understand why they both exist in the generated code.
>
> And the last question is why the checkcast is not removed because
> the test getClass() == A.class is just above.
> Is the VM also lost with the double representation of a class ?
>
> regards,
> Rémi
>
> 0x00007f67a46e326c: mov    0x8(%rsi),%r11d    ; implicit exception:
> dispatches to 0x00007f67a46e32ea
>  ;; B2: #    B7 B3 <- B1  Freq: 0.999999
>
>  0x00007f67a46e3270: mov    0x78(%r12,%r11,8),%rbp  ;*invokevirtual
> getClass
>                                                ; - RT::classCheck at 1 (line
> 102)
>                                                ; -
> java.lang.invoke.MethodHandle:**:invokeExact at 3
>                                                ; -
> java.lang.invoke.MethodHandle:**:invokeExact at 3
>                                                ; - IndyTest::test at 1
>  0x00007f67a46e3275: mov    $0x7d6bb4228,%r10  ;   {oop(a
> 'java/lang/Class' = 'A')}
>  0x00007f67a46e327f: cmp    %r10,%rbp
>  0x00007f67a46e3282: jne    0x00007f67a46e32c9  ;*if_acmpne
>                                                ; - RT::classCheck at 5 (line
> 102)
>                                                ; -
> java.lang.invoke.MethodHandle:**:invokeExact at 3
>                                                ; -
> java.lang.invoke.MethodHandle:**:invokeExact at 3
>                                                ; - IndyTest::test at 1
>  ;; B3: #    B6 B4 <- B2  Freq: 0.999999
>
>  0x00007f67a46e3284: mov    0x40(%r12,%r11,8),%r10
>  0x00007f67a46e3289: mov    $0x77f280d58,%r11  ;   {oop('A')}
>  0x00007f67a46e3293: cmp    %r11,%r10
>  0x00007f67a46e3296: jne    0x00007f67a46e32b4  ;*checkcast
>                                                ; -
> java.lang.invoke.MethodHandle:**:invokeExact at 1
>                                                ; -
> java.lang.invoke.MethodHandle:**:invokeExact at 21
>                                                ; - IndyTest::test at 1
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/hotspot-compiler-dev/attachments/20120416/684d1365/attachment-0001.html 


More information about the hotspot-compiler-dev mailing list