From cd11059f105cf17aa4e99a195f0eb410e78abf5c Mon Sep 17 00:00:00 2001 From: Albert Mingkun Yang Date: Thu, 1 Feb 2024 11:00:09 +0000 Subject: [PATCH] 8325053: Serial: Move Generation::save_used_region to TenuredGeneration Reviewed-by: stefank, ehelin --- src/hotspot/share/gc/serial/genMarkSweep.cpp | 7 +++---- src/hotspot/share/gc/serial/generation.hpp | 6 ------ src/hotspot/share/gc/serial/serialHeap.cpp | 5 ----- src/hotspot/share/gc/serial/serialHeap.hpp | 3 --- src/hotspot/share/gc/serial/tenuredGeneration.hpp | 6 ++++-- 5 files changed, 7 insertions(+), 20 deletions(-) diff --git a/src/hotspot/share/gc/serial/genMarkSweep.cpp b/src/hotspot/share/gc/serial/genMarkSweep.cpp index 28ba4615f73..41bd49edaf6 100644 --- a/src/hotspot/share/gc/serial/genMarkSweep.cpp +++ b/src/hotspot/share/gc/serial/genMarkSweep.cpp @@ -441,10 +441,9 @@ void GenMarkSweep::invoke_at_safepoint(bool clear_all_softrefs) { // Increment the invocation count _total_invocations++; - // Capture used regions for each generation that will be - // subject to collection, so that card table adjustments can - // be made intelligently (see clear / invalidate further below). - gch->save_used_regions(); + // Capture used regions for old-gen to reestablish old-to-young invariant + // after full-gc. + gch->old_gen()->save_used_region(); allocate_stacks(); diff --git a/src/hotspot/share/gc/serial/generation.hpp b/src/hotspot/share/gc/serial/generation.hpp index 265b1e1ea40..5af6e5dea89 100644 --- a/src/hotspot/share/gc/serial/generation.hpp +++ b/src/hotspot/share/gc/serial/generation.hpp @@ -58,9 +58,6 @@ class GCStats; class Generation: public CHeapObj { friend class VMStructs; private: - MemRegion _prev_used_region; // for collectors that want to "remember" a value for - // used region at some specific point during collection. - GCMemoryManager* _gc_manager; protected: @@ -120,9 +117,6 @@ class Generation: public CHeapObj { // generation. virtual MemRegion used_region() const { return _reserved; } - MemRegion prev_used_region() const { return _prev_used_region; } - virtual void save_used_region() { _prev_used_region = used_region(); } - /* Returns "TRUE" iff "p" points into the reserved area of the generation. */ bool is_in_reserved(const void* p) const { return _reserved.contains(p); diff --git a/src/hotspot/share/gc/serial/serialHeap.cpp b/src/hotspot/share/gc/serial/serialHeap.cpp index a781c950aa9..4d1ad497b85 100644 --- a/src/hotspot/share/gc/serial/serialHeap.cpp +++ b/src/hotspot/share/gc/serial/serialHeap.cpp @@ -294,11 +294,6 @@ size_t SerialHeap::used() const { return _young_gen->used() + _old_gen->used(); } -void SerialHeap::save_used_regions() { - _old_gen->save_used_region(); - _young_gen->save_used_region(); -} - size_t SerialHeap::max_capacity() const { return _young_gen->max_capacity() + _old_gen->max_capacity(); } diff --git a/src/hotspot/share/gc/serial/serialHeap.hpp b/src/hotspot/share/gc/serial/serialHeap.hpp index d809ca1454b..c9a2d5ca81a 100644 --- a/src/hotspot/share/gc/serial/serialHeap.hpp +++ b/src/hotspot/share/gc/serial/serialHeap.hpp @@ -162,9 +162,6 @@ public: size_t capacity() const override; size_t used() const override; - // Save the "used_region" for both generations. - void save_used_regions(); - size_t max_capacity() const override; HeapWord* mem_allocate(size_t size, bool* gc_overhead_limit_was_exceeded) override; diff --git a/src/hotspot/share/gc/serial/tenuredGeneration.hpp b/src/hotspot/share/gc/serial/tenuredGeneration.hpp index 329e531c1f3..6ae34a4e674 100644 --- a/src/hotspot/share/gc/serial/tenuredGeneration.hpp +++ b/src/hotspot/share/gc/serial/tenuredGeneration.hpp @@ -45,7 +45,7 @@ class TenuredGeneration: public Generation { // Abstractly, this is a subtype that gets access to protected fields. friend class VM_PopulateDumpSharedSpace; - protected: + MemRegion _prev_used_region; // This is shared with other generations. CardTableRS* _rs; @@ -70,7 +70,6 @@ class TenuredGeneration: public Generation { GenerationCounters* _gen_counters; CSpaceCounters* _space_counters; - // Attempt to expand the generation by "bytes". Expand by at a // minimum "expand_bytes". Return true if some amount (not // necessarily the full "bytes") was done. @@ -95,6 +94,9 @@ class TenuredGeneration: public Generation { size_t free() const; MemRegion used_region() const; + MemRegion prev_used_region() const { return _prev_used_region; } + void save_used_region() { _prev_used_region = used_region(); } + void space_iterate(SpaceClosure* blk, bool usedOnly = false); void younger_refs_iterate(OopIterateClosure* blk);