RFR: Disable barrier optimization on constant when +ShenandoahBarriersForConst
Roman Kennke
rkennke at redhat.com
Tue Jun 20 16:03:22 UTC 2017
Am 20.06.2017 um 17:52 schrieb Roland Westrelin:
>> There is an optimization in
>> CmpPNode::shenandoah_optimize_java_mirror_cmp() that eliminates barriers
>> when comparing two java mirror objects. We need those barriers when
>> running with +ShenandoahBarriersForConst. This patch disables that
>> optimization:
>>
>> http://cr.openjdk.java.net/~rkennke/fixbarriersforconst/webrev.00/
>> <http://cr.openjdk.java.net/%7Erkennke/fixbarriersforconst/webrev.00/>
> Unless I misread the code, this optimization transforms:
>
> 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.
> then to:
>
> if (o1.klass != o2.klass) {
> if (o1.klass == o2.klass) {
Is this always equivalent? E.g. primitive classes or array classes?
Roman
More information about the shenandoah-dev
mailing list