RFR: 8375438: G1: Convert G1HeapRegion related classes to use Atomic<T>
Thomas Schatzl
tschatzl at openjdk.org
Tue Jan 20 10:48:16 UTC 2026
On Tue, 20 Jan 2026 10:04:46 GMT, Aleksey Shipilev <shade at openjdk.org> wrote:
>> Hi all,
>>
>> please review conversion of G1HeapRegion related classes to use Atomic<T>.
>>
>> Testing: tier1, tier4, tier5
>>
>> (The PipelineLeaksFD failure in gha is a known issue)
>>
>> Thanks,
>> Thomas
>
> src/hotspot/share/gc/g1/g1HeapRegion.inline.hpp line 196:
>
>> 194: if (want_to_allocate >= min_word_size) {
>> 195: HeapWord* new_top = obj + want_to_allocate;
>> 196: HeapWord* result = _top.compare_exchange(obj, new_top);
>
> Since you are not using `result` beyond checking for CAS completion, you can probably do `if (_top.compare_set(obj_top)) { ... ` directly. This would also obviate the need for the comment on what CAE return value is supposed to signify.
I rewrote the loop to avoid the reload of `top()`, using the result of the `compare_exchange`.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/29301#discussion_r2707795071
More information about the hotspot-dev
mailing list