[RFR]: 8186578: Zero fails to build on linux-sparc due to sparc-specific code

Andrew Haley aph at redhat.com
Mon Aug 28 09:54:04 UTC 2017


On 23/08/17 13:23, John Paul Adrian Glaubitz wrote:
> The second instance is in src/share/vm/gc/shared/memset_with_concurrent_readers.hpp:
> 
> #ifdef SPARC
> 
> // SPARC requires special handling.  See SPARC-specific definition.
> 
> #else
> // All others just use memset.
> 
> inline void memset_with_concurrent_readers(void* to, int value, size_t size) {
>    ::memset(to, value, size);
> }
> 
> #endif // End of target dispatch.

It certainly looks like this is wrong.  The execution of memset with concurrent
readers while the memory is being zeroed is UB, so we need some kind of special
handling in the general case.  I'm pretty sure this would work:

inline void memset_with_concurrent_readers(void* to, int value, size_t size) {
  volatile char *dest = to;
  for (int i = 0; i < count; i++)
    *dest++ = value;
}

but its performance would be awful.  It'd be interesting to try to figure out
a portable C++ version which would work everywhere, but I guess that wouldn't
be possible without C++11 atomics.

-- 
Andrew Haley
Java Platform Lead Engineer
Red Hat UK Ltd. <https://www.redhat.com>
EAC8 43EB D3EF DB98 CC77 2FAD A5CD 6035 332F A671


More information about the hotspot-dev mailing list