8318296: Move Space::initialize to ContiguousSpace

Reviewed-by: tschatzl, iwalulya
This commit is contained in:
Albert Mingkun Yang 2023-10-20 08:40:51 +00:00
parent 744f206fef
commit cd25d1a2bf
2 changed files with 22 additions and 34 deletions

View File

@ -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();
}

View File

@ -112,17 +112,6 @@ class Space: public CHeapObj<mtGC> {
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.