RFR: 8048180: G1: Eager reclaim of humongous objects with references [v4]

Thomas Schatzl tschatzl at openjdk.org
Thu Oct 9 13:11:48 UTC 2025


On Thu, 9 Oct 2025 12:58:00 GMT, Thomas Schatzl <tschatzl at openjdk.org> wrote:

>> src/hotspot/share/gc/g1/g1YoungCollector.cpp line 401:
>> 
>>> 399:       bool mark_in_progress = _g1h->collector_state()->mark_in_progress();
>>> 400:       return (obj->is_typeArray() || (G1EagerReclaimWithRefs && (allocated_after_mark_start || !mark_in_progress))) &&
>>> 401:              _g1h->is_potential_eager_reclaim_candidate(region);
>> 
>> I'd suggest rewriting this a bit (e.g. using early-return or sth) -- the current form is not super clear.
>
> Are you okay with removing the `G1EagerReclaimWithRefs` flag? Then it becomes a bit easier by itself.
> 
> The logical or does not lend itself very well to early returns.

Suggestion:

      if (!obj->is_typeArray()) {
        if (!G1EagerReclaimWithRefs) {
          return false;
        }
        // All regions that were allocated before marking have a TAMS != bottom.
        bool allocated_before_mark_start = region->bottom() != _g1h->concurrent_mark()->top_at_mark_start(region);
        bool mark_in_progress = _g1h->collector_state()->mark_in_progress();

        if (allocated_before_mark_start && mark_in_progress) {
          return false;
        }
      }
      return _g1h->is_potential_eager_reclaim_candidate(region);

Maybe something like this?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/27525#discussion_r2416743143


More information about the hotspot-gc-dev mailing list