Assembler questions

Krystal Mok rednaxelafx at gmail.com
Mon Apr 16 05:22:07 PDT 2012


Hi Remi,

It sure is.

Could you put up the sample code that you were running? I'm getting a
little bit curious :-)

- Kris

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

> Thinking a little more about that, I think it's a type propagation issue.
>
> Neither obj.getClass() == A.class nor A.class.isInstance(obj) works.
> I think it's because they are instrinsic and doesn't propagate the fact
> that after them obj is an A.
>
> Note that this is really really bad in loop, because you can see 3 or 4
> of these tests consecutively after the loop unrolling/code motion opt.
>
> Rémi
>
>
> On 04/16/2012 01:53 PM, Rémi Forax wrote:
>
>> On 04/16/2012 12:31 PM, Krystal Mok wrote:
>>
>>> Hi Remi,
>>>
>>> Apparently the original code was trying to do something like:
>>>
>>> if (obj.getClass() == A.class) {
>>>  A a = (A) obj;
>>>  // ...
>>> }
>>>
>>> Right?
>>>
>>
>> yes.
>> In fact, it's the equivalent code done using method handles.
>>
>>
>>> If the condition was
>>>
>>> if (obj instanceof A)
>>>
>>> then the checkcast would have been elided.
>>>
>>
>> yes, you're right. I've just tested :)
>>
>>
>>> Maybe this kind of code pattern should be recognized by C2 in a future
>>> enhancement?
>>>
>>
>> Yes, I think it should.
>>
>>>
>>> Regards,
>>> Kris
>>>
>>
>> regards,
>> Rémi
>>
>>
>>> On Mon, Apr 16, 2012 at 5:59 PM, Rémi Forax <forax at univ-mlv.fr <mailto:
>>> 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/af1ea5bb/attachment-0001.html 


More information about the hotspot-compiler-dev mailing list