RFR: 8245594: Remove volatile-qualified member functions and parameters from oop class
Kim Barrett
kim.barrett at oracle.com
Fri May 22 18:42:40 UTC 2020
> On May 22, 2020, at 12:10 PM, coleen.phillimore at oracle.com wrote:
>
>
>
> On 5/21/20 6:31 PM, Kim Barrett wrote:
>> Please review this change to eliminate volatile qualification in the
>> member functions and parameters of the oop class and its subclasses.
>
> This is nice. I thought more code would fail to compile if the volatile versions were removed, which is why they were added in the first place. It does not look like this is the case since this changeset is small.
There were a number of preparatory changes. A couple, but not all, are linked as
related to this one in JBS.
>>
>> Removed volatile qualified member functions and parameters from class
>> oop and its subclasses (instanceOop, arrayOop, objArrayOop, typeArrayOop).
>> Changed the few remaining volatile oop accesses to instead use relaxed
>> atomics.
> "relaxed atomics" means Atomic::load(&_field) ?
And Atomic::store, yes.
> So if the field is declared "volatile", will the compiler give you an error if you just store a value to it without Atomic::store(&_field) ? But it will not give you an error if you fail to load the value without Atomic::load(&_field). But keeping the "volatile" keyword on declarations is a good way to visually signal that this variable needs special access?
It depends, but that is likely to produce a compiler error too. There
are no operations in oop with a parameter that is a pointer/reference
to volatile oop, so those aren't applicable. Another class could have
operations that take a pointer/reference to volatile oop, but there
don't appear to be any of those.
So having the variable be volatile qualified provides some checking
that we're using Atomic operations where we should be, at least for
this class (and any other similar classes that don't have volatile
qualifiers in their operations). It doesn't help for fundamental
types though. Leo is working on something for that.
> Thanks for cleaning the oop class up.
Thanks for reviewing.
More information about the hotspot-dev
mailing list