acmp/cas retries and null arguments
Aleksey Shipilev
shade at redhat.com
Wed Sep 14 16:39:34 UTC 2016
On 09/13/2016 06:16 PM, Roman Kennke wrote:
>> acmp(%a, %b):
>> test %a, %b
>> je <true>
>>
>> test %a, %a
>> je <false> // %a is null, guaranteed "false"
>> mov %a, (%a - 8);
>>
>> test %b, %b
>> je <false> // %b is null, guaranteed "false"
>> mov %b, (%b - 8);
>>
>> test %a, %b;
>> je <true>
>>
>> false:
>> ret false;
>>
>> true:
>> ret true;
>>
>> This saves read barriers if one of the arguments is not null.
>
> Right.
> C2 should avoid generating the special acmp and cas barriers if one of
> the args is *known* to be null.
Yes, in fact we have seen it:
http://cr.openjdk.java.net/~shade/shenandoah/shenandoah-gc-bench/src/main/java/org/openjdk/shenandoah/acmp/ACmpBarriersKnownNulls.java
Granted, the most frequent (obj == null) test is catered by this.
> It's a little more involved if it determines at runtime that one is
> null. I'd be happy to see it optimized though :-)
Yup, but this is the essence of the trick: we nullcheck before
dereferencing through forwarding pointer anyway. We could instead break
out instantly, without trying to do other read and unnecessary
additional comparison.
I'll take a look after CASes codegen.
Thanks,
-Aleksey
More information about the shenandoah-dev
mailing list