RFR: 8352299: GenShen: Young cycles that interrupt old cycles cannot be cancelled [v2]

Kelvin Nilsen kdnilsen at openjdk.org
Mon Mar 24 18:19:09 UTC 2025


On Tue, 18 Mar 2025 22:58:12 GMT, William Kemper <wkemper at openjdk.org> wrote:

>> src/hotspot/share/gc/shenandoah/shenandoahSharedVariables.hpp line 243:
>> 
>>> 241:     assert (new_value < (sizeof(ShenandoahSharedValue) * CHAR_MAX), "sanity");
>>> 242:     // Hmm, no platform template specialization defined for exchanging one byte... (up cast to intptr is workaround).
>>> 243:     return (T)Atomic::xchg((intptr_t*)&value, (intptr_t)new_value);
>> 
>> That... likely gets awkward on different endianness. See the complicated dance `Atomic::CmpxchgByteUsingInt` has to do to handle it. 
>> 
>> Not to mention we are likely writing to adjacent memory location. Which is _currently_ innocuous, since we hit padding, but it is not very reliable.
>
> `PlatformCmpxchg` has specializations on aarch64 and x86 for `sizeof(T) == 1`. Should we also add platform specializations for `PlatformXchg` for `sizeof(T) == 1`? (It has them for `4` and `8`). Could also do what `XchgUsingCmpxchg` does...

Maybe it is easiest/safest to change declaration of value to intptr_t.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/24105#discussion_r2010707057


More information about the shenandoah-dev mailing list