Atomic::cmpxchg_ptr code duplication

Christian Thalinger Christian.Thalinger at Sun.COM
Wed Apr 1 23:23:22 PDT 2009


On Mon, 2009-03-30 at 15:38 -0700, John Coomes wrote:
> The Atomic class has both
> 
>   intptr_t cmpxchg_ptr(intptr_t, volatile intptr_t*, intptr_t);
>   void*    cmpxchg_ptr(void*, volatile void*, void*);
> 
> The latter could be implemented as a simple inline which calls the
> former:
> 
>   void* cmpxchg_ptr(void* exchange_value, volatile void* dest,
>                     void* compare_value) {
>     return (intptr_t)cmpxchg_ptr((intptr_t)exchange_value,
>                                  (volatile intptr_t*)dest,
>                                  (intptr_t)compare_value
>    }
> 
> However, both the intptr_t and void* variants have bodies defined in
> each of the various platform-specific headers (e.g.,
> atomic_windows_x86.inline.hpp, atomic_solaris_x86.inline.hpp, ...).
> So there are 10 places where the cmpxchg_ptr(void*...) variant is
> defined, instead of one.  Is there a reason for the duplication?

I don't see a reason for the duplication.  Maybe it's another historic
artifact?

-- Christian




More information about the hotspot-dev mailing list