RFR: 8375438: G1: Convert G1HeapRegion related classes to use Atomic<T>
Aleksey Shipilev
shade at openjdk.org
Tue Jan 20 10:10:24 UTC 2026
On Mon, 19 Jan 2026 13:32:46 GMT, Thomas Schatzl <tschatzl 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
Can go a bit further:
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.
src/hotspot/share/gc/g1/g1HeapRegionManager.cpp line 740:
> 738: bool G1HeapRegionClaimer::claim_region(uint region_index) {
> 739: assert(region_index < _n_regions, "Invalid index.");
> 740: uint old_val = _claims[region_index].compare_exchange(Unclaimed, Claimed);
Same thing here, it could be just `return _claims[region_index].compare_set(Unclaimed, Claimed)`.
-------------
PR Review: https://git.openjdk.org/jdk/pull/29301#pullrequestreview-3681362712
PR Review Comment: https://git.openjdk.org/jdk/pull/29301#discussion_r2707640538
PR Review Comment: https://git.openjdk.org/jdk/pull/29301#discussion_r2707646539
More information about the hotspot-dev
mailing list