(S) RFR: 8157904: Atomic::cmpxchg for jbyte is missing a fence on initial failure

Volker Simonis volker.simonis at gmail.com
Tue Aug 23 12:20:02 UTC 2016


On Tue, Aug 23, 2016 at 10:55 AM, David Holmes <david.holmes at oracle.com> wrote:
> Hi Volker, Andrew,
>
> On 23/08/2016 12:27 AM, Volker Simonis wrote:
>>
>> Hi,
>>
>> I don't particularly like the const_casts as well.
>
>
> I would have thought this was exactly the kind of thing const_cast was good
> for - avoiding the need to define multiple overloads to deal with volatile,
> non-volatile, const etc.
>
>> Why not change pointer_delta to accept pointers to volatiles as well:
>>
>> pointer_delta(const volatile void* left, const volatile void* right,
>
>
> I can do that. I also have to make a similar change to align_ptr_down. Now
> should I also change align_ptr_up for consistency (though I note they are
> already inconsistent in that one takes void* and one takes const void*) ?
>
> Alternative webrev at:
>
> http://cr.openjdk.java.net/~dholmes/8157904/webrev.v2/

I like it much better this way, but you don't need the old versions
any more. pointer_delta() taking "const volatile void*" and
align_ptr_down() taking "volatile void*" arguments are enough. The
other versions can be removed. I tried to make that clear in my
previous mail:

Because there are standard conversion from "<type>*" to "volatile
<type>*", the new version will still work for callers which use
non-volatile arguments.

And:

Notice that "const volatile void*" means a pointer to a value which
might change unexpectedly but which can not be changed by the program
itself. As the function doesn't really dereferences the pointers (i.e.
reads the values pointed to by the pointers) but only computes the
delta of the pointers themselves, this shouldn't do any harm regarding
the optimization possibilities.

Thanks,
Volker

>
> Thanks,
> David
> -----
>
>
>
>> Notice that "const volatile void*" means a pointer to a value which
>> might change unexpectedly but which can not be changed by the program
>> itself. As the function doesn't really dereferences the pointers (i.e.
>> reads the values pointed to by the pointers) but only computes the
>> delta of the pointers themselves, this shouldn't do any harm regarding
>> the optimization possibilities.
>>
>> Because there are standard conversion from "<type>*" to "volatile
>> <type>*", the new version will still work for callers which use
>> non-volatile arguments.
>>
>> Regards,
>> Volker
>>
>>
>> On Mon, Aug 22, 2016 at 12:59 PM, David Holmes <david.holmes at oracle.com>
>> wrote:
>>>
>>> On 22/08/2016 6:25 PM, Andrew Haley wrote:
>>>>
>>>>
>>>> On 22/08/16 08:54, David Holmes wrote:
>>>>>
>>>>>
>>>>> Bug: https://bugs.openjdk.java.net/browse/JDK-8157904
>>>>>
>>>>> webrev: http://cr.openjdk.java.net/~dholmes/8157904/webrev/
>>>>
>>>>
>>>>
>>>> The casting away volatile is confusing and ugly.  Is the problem
>>>> that we don't have volatile cmpxchg() ?  Or that we don't have a
>>>> pointer_delta() which accepts a volatile?
>>>
>>>
>>>
>>> The latter - pointer_delta takes const args.
>>>
>>> David
>>>
>>>> Andrew.
>>>>
>>>>
>>>
>


More information about the hotspot-runtime-dev mailing list