RFR: Disable barrier optimization on constant when +ShenandoahBarriersForConst

Roland Westrelin rwestrel at redhat.com
Tue Jun 20 16:07:01 UTC 2017


>> a = o1.getClass();
>> b = o2.getClass();
>> if (a != b) {
>>   a' = read_barrier(a);
>>   b' = read_barrier(b);
>>   if (a' == b') {
>>     ..
>>   } else {
>>     ..
>>  }
>> } else  {
>>
>> to:
>>
>> a = o1.getClass();
>> b = o2.getClass();
>> if (a != b) {
>>   if (a == b) {
>>     ..
>>   } else {
>>     ..
>>  }
>> } else  {
>
> But this is not valid when we can get false negatives on a != b !
> Suppose you get a and b both pointing to the same Class object, but
> different copies of it, then the cmp would fail even though it should not.

It's no valid but it's only a temporary state because then the getClass
are removed right away and replaced by o1.klass and o2.klass.

>> then to:
>>
>> if (o1.klass != o2.klass) {
>>   if (o1.klass == o2.klass) {
> Is this always equivalent? E.g. primitive classes or array classes?

It's an optimization from upstream so hopefully, yes.

Roland.


More information about the shenandoah-dev mailing list