RFR (M): 8187977: Generalize Atomic::xchg to use templates

Kim Barrett kim.barrett at oracle.com
Fri Sep 29 16:24:02 UTC 2017


> On Sep 29, 2017, at 6:45 AM, Erik Österlund <erik.osterlund at oracle.com> wrote:
> On 2017-09-28 21:02, Kim Barrett wrote:
>> src/hotspot/share/runtime/atomic.hpp
>> 
>> There are a lot of similarities between the handling of the
>> exchange_value by cmpxchg and xchg, and I expect Atomic::store and
>> OrderAccess::release_store and variants to also be similar. (Actually,
>> xchg and store may look *very* similar.) It would be nice to think
>> about whether there's some refactoring that could be used to reduce
>> the amount of code involved. I don't have a specific suggestion yet
>> though.  For now, this is just something to think about.
> 
> I would not like to mix xchg and load/store implementations in Atomic. The reason for that is that I would rather share the implementation between Atomic::load/store and OrderAccess::*load/store*, because they are even more similar. I have that already in my patch queue.

I’m specifically looking at the canonicalization of the value_to_store and the destination.
I think *all* of those operations ought to handle this the same way.  And the present
approach to that is somewhat verbose and duplicated per operation.  It seems to me
that we should be able to do better.  Something like a canonicalization function and a
type trait for the canonicalized destination type.

I’ll see if I can come up with something more concrete to suggest.



More information about the hotspot-dev mailing list