From cd25d1a2bf4530d8fd4d0515b69e2199df9c102f Mon Sep 17 00:00:00 2001 From: Albert Mingkun Yang Date: Fri, 20 Oct 2023 08:40:51 +0000 Subject: [PATCH] 8318296: Move Space::initialize to ContiguousSpace Reviewed-by: tschatzl, iwalulya --- src/hotspot/share/gc/shared/space.cpp | 34 ++++++++++----------------- src/hotspot/share/gc/shared/space.hpp | 22 +++++++---------- 2 files changed, 22 insertions(+), 34 deletions(-) diff --git a/src/hotspot/share/gc/shared/space.cpp b/src/hotspot/share/gc/shared/space.cpp index 2e076b6ef22..763ff8c616d 100644 --- a/src/hotspot/share/gc/shared/space.cpp +++ b/src/hotspot/share/gc/shared/space.cpp @@ -46,24 +46,6 @@ #include "gc/serial/defNewGeneration.hpp" #endif -void Space::initialize(MemRegion mr, - bool clear_space, - bool mangle_space) { - HeapWord* bottom = mr.start(); - HeapWord* end = mr.end(); - assert(Universe::on_page_boundary(bottom) && Universe::on_page_boundary(end), - "invalid space boundaries"); - set_bottom(bottom); - set_end(end); - if (clear_space) clear(mangle_space); -} - -void Space::clear(bool mangle_space) { - if (ZapUnusedHeapArea && mangle_space) { - mangle_unused_area(); - } -} - ContiguousSpace::ContiguousSpace(): Space(), _compaction_top(nullptr), _next_compaction_space(nullptr), @@ -79,15 +61,25 @@ void ContiguousSpace::initialize(MemRegion mr, bool clear_space, bool mangle_space) { - Space::initialize(mr, clear_space, mangle_space); - set_compaction_top(bottom()); + HeapWord* bottom = mr.start(); + HeapWord* end = mr.end(); + assert(Universe::on_page_boundary(bottom) && Universe::on_page_boundary(end), + "invalid space boundaries"); + set_bottom(bottom); + set_end(end); + if (clear_space) { + clear(mangle_space); + } + set_compaction_top(bottom); _next_compaction_space = nullptr; } void ContiguousSpace::clear(bool mangle_space) { set_top(bottom()); set_saved_mark(); - Space::clear(mangle_space); + if (ZapUnusedHeapArea && mangle_space) { + mangle_unused_area(); + } _compaction_top = bottom(); } diff --git a/src/hotspot/share/gc/shared/space.hpp b/src/hotspot/share/gc/shared/space.hpp index 3729df804fb..d978aabc186 100644 --- a/src/hotspot/share/gc/shared/space.hpp +++ b/src/hotspot/share/gc/shared/space.hpp @@ -112,17 +112,6 @@ class Space: public CHeapObj { return MemRegion(bottom(), saved_mark_word()); } - // Initialization. - // "initialize" should be called once on a space, before it is used for - // any purpose. The "mr" arguments gives the bounds of the space, and - // the "clear_space" argument should be true unless the memory in "mr" is - // known to be zeroed. - virtual void initialize(MemRegion mr, bool clear_space, bool mangle_space); - - // The "clear" method must be called on a region that may have - // had allocation performed in it, but is now to be considered empty. - virtual void clear(bool mangle_space); - // For detecting GC bugs. Should only be called at GC boundaries, since // some unused space may be used as scratch space during GC's. // We also call this when expanding a space to satisfy an allocation @@ -264,9 +253,16 @@ private: ContiguousSpace(); ~ContiguousSpace(); - void initialize(MemRegion mr, bool clear_space, bool mangle_space) override; + // Initialization. + // "initialize" should be called once on a space, before it is used for + // any purpose. The "mr" arguments gives the bounds of the space, and + // the "clear_space" argument should be true unless the memory in "mr" is + // known to be zeroed. + void initialize(MemRegion mr, bool clear_space, bool mangle_space); - void clear(bool mangle_space) override; + // The "clear" method must be called on a region that may have + // had allocation performed in it, but is now to be considered empty. + virtual void clear(bool mangle_space); // Used temporarily during a compaction phase to hold the value // top should have when compaction is complete.