RFR: 8301599: Serial: Refactor nested closures in DefNewGeneration
Thomas Schatzl
tschatzl at openjdk.org
Wed Feb 1 10:43:57 UTC 2023
On Wed, 1 Feb 2023 10:13:25 GMT, Albert Mingkun Yang <ayang at openjdk.org> wrote:
> Simple refactoring broken into two commits:
>
> 1. Rename `KeepAliveClosure`.
> 2. Extract and move closures to cpp file.
>
> Test: hotspot_gc
Lgtm.
src/hotspot/share/gc/serial/defNewGeneration.cpp line 75:
> 73:
> 74: bool do_object_b(oop p) {
> 75: return cast_from_oop<HeapWord*>(p) >= _young_gen->reserved().end() || p->is_forwarded();
Another micro-optimization for another day, `_young_gen->reserved().end()` is constant across the use (i.e. avoid the dereference for `_young_gen->reserved()` all the time).
src/hotspot/share/gc/serial/defNewGeneration.cpp line 101:
> 99: // generation pointer.
> 100: oop obj = RawAccess<IS_NOT_NULL>::oop_load(p);
> 101: if ((cast_from_oop<HeapWord*>(obj) < _boundary) && GenCollectedHeap::heap()->is_in_reserved(p)) {
I'm wondering whether the second part of the condition can ever be false. From what I can see, the `KeepAliveClosure` is only ever used during reference processing (afaict, may be wrong), and I can't think of a reason why the `Reference` would ever be outside the heap.
Feel free to ignore for this change, I can clean this up.
-------------
Marked as reviewed by tschatzl (Reviewer).
PR: https://git.openjdk.org/jdk/pull/12359
More information about the hotspot-gc-dev
mailing list