RFR: 8376350: Convert ReferenceProcessorPhaseTimes to use Atomic<T>

Thomas Schatzl tschatzl at openjdk.org
Tue Jan 27 12:55:33 UTC 2026


On Tue, 27 Jan 2026 12:26:59 GMT, Stefan Karlsson <stefank at openjdk.org> wrote:

>> Hi all,
>> 
>>   please review this change to convert `ReferenceProcessorPhaseTimes` to use `Atomic<T>`.
>> 
>> Testing: gha
>> 
>> Thanks,
>>   Thomas
>
> src/hotspot/share/gc/shared/referenceProcessorPhaseTimes.cpp line 199:
> 
>> 197: 
>> 198:   for (int i = 0; i < number_of_subclasses_of_ref; i++) {
>> 199:     ::new (&_ref_dropped[i]) Atomic<size_t>{};
> 
> I had some offline discussions with @jdksjolen and @walulyai about if we really should be using placement new to reset `Atomic`s, and if this is the correct way, should we also call the destructor on the old object?
> 
> That discussion ended up with suggesting the following instead:
> Suggestion:
> 
>     _ref_dropped[i].store_relaxed(0);

Last time Kim noted that since this (and that other) store would be initialization, and the first time this occurs this would be (technically) undefined behavior. I am good either way.

It may be that last time it had been a more complex data structure than a size_t.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/29423#discussion_r2731871581


More information about the hotspot-gc-dev mailing list