RFR(XS): make shared variables volatile

Zhengyu Gu zgu at redhat.com
Thu Sep 22 15:20:44 UTC 2016


On 09/22/2016 11:04 AM, Andrew Haley wrote:

> On 21/09/16 15:47, Aleksey Shipilev wrote:
>> On 09/21/2016 04:40 PM, Zhengyu Gu wrote:
>>> http://cr.openjdk.java.net/~zgu/volatile/webrev.01/
>> +1
>>
>> I wonder if this means we should update/poll these volatile variables
>> with Atomic::* too, at least for the benefit of weak arches like AArch64.
> Always.  volatile is never sufficient for variables accessed racily by
> multiple threads, and in C++11 it's undefined behaviour.  I remember
> finding and fixing a couple of these when I did the AArch64 Shenandoah
> port.

My intention here is simply preventing compiler from caching the shared variables, ex.

ShenandoahHeapRegion::object_iterate_interruptible()
   ...
   while (p < top() && !(allow_cancel && heap->cancelled_concgc()))
   ...


Setting _cancelled_concgc is followed by a full fence, I have yet checked the others.


Thanks,

-Zhengyu

> Andrew.



More information about the shenandoah-dev mailing list