Skip to content

Commit cd25d1a

Browse files
committedOct 20, 2023
8318296: Move Space::initialize to ContiguousSpace
Reviewed-by: tschatzl, iwalulya
1 parent 744f206 commit cd25d1a

File tree

2 files changed

+22
-34
lines changed

2 files changed

+22
-34
lines changed
 

‎src/hotspot/share/gc/shared/space.cpp

+13-21
Original file line numberDiff line numberDiff line change
@@ -46,24 +46,6 @@
4646
#include "gc/serial/defNewGeneration.hpp"
4747
#endif
4848

49-
void Space::initialize(MemRegion mr,
50-
bool clear_space,
51-
bool mangle_space) {
52-
HeapWord* bottom = mr.start();
53-
HeapWord* end = mr.end();
54-
assert(Universe::on_page_boundary(bottom) && Universe::on_page_boundary(end),
55-
"invalid space boundaries");
56-
set_bottom(bottom);
57-
set_end(end);
58-
if (clear_space) clear(mangle_space);
59-
}
60-
61-
void Space::clear(bool mangle_space) {
62-
if (ZapUnusedHeapArea && mangle_space) {
63-
mangle_unused_area();
64-
}
65-
}
66-
6749
ContiguousSpace::ContiguousSpace(): Space(),
6850
_compaction_top(nullptr),
6951
_next_compaction_space(nullptr),
@@ -79,15 +61,25 @@ void ContiguousSpace::initialize(MemRegion mr,
7961
bool clear_space,
8062
bool mangle_space)
8163
{
82-
Space::initialize(mr, clear_space, mangle_space);
83-
set_compaction_top(bottom());
64+
HeapWord* bottom = mr.start();
65+
HeapWord* end = mr.end();
66+
assert(Universe::on_page_boundary(bottom) && Universe::on_page_boundary(end),
67+
"invalid space boundaries");
68+
set_bottom(bottom);
69+
set_end(end);
70+
if (clear_space) {
71+
clear(mangle_space);
72+
}
73+
set_compaction_top(bottom);
8474
_next_compaction_space = nullptr;
8575
}
8676

8777
void ContiguousSpace::clear(bool mangle_space) {
8878
set_top(bottom());
8979
set_saved_mark();
90-
Space::clear(mangle_space);
80+
if (ZapUnusedHeapArea && mangle_space) {
81+
mangle_unused_area();
82+
}
9183
_compaction_top = bottom();
9284
}
9385

‎src/hotspot/share/gc/shared/space.hpp

+9-13
Original file line numberDiff line numberDiff line change
@@ -112,17 +112,6 @@ class Space: public CHeapObj<mtGC> {
112112
return MemRegion(bottom(), saved_mark_word());
113113
}
114114

115-
// Initialization.
116-
// "initialize" should be called once on a space, before it is used for
117-
// any purpose. The "mr" arguments gives the bounds of the space, and
118-
// the "clear_space" argument should be true unless the memory in "mr" is
119-
// known to be zeroed.
120-
virtual void initialize(MemRegion mr, bool clear_space, bool mangle_space);
121-
122-
// The "clear" method must be called on a region that may have
123-
// had allocation performed in it, but is now to be considered empty.
124-
virtual void clear(bool mangle_space);
125-
126115
// For detecting GC bugs. Should only be called at GC boundaries, since
127116
// some unused space may be used as scratch space during GC's.
128117
// We also call this when expanding a space to satisfy an allocation
@@ -264,9 +253,16 @@ class ContiguousSpace: public Space {
264253
ContiguousSpace();
265254
~ContiguousSpace();
266255

267-
void initialize(MemRegion mr, bool clear_space, bool mangle_space) override;
256+
// Initialization.
257+
// "initialize" should be called once on a space, before it is used for
258+
// any purpose. The "mr" arguments gives the bounds of the space, and
259+
// the "clear_space" argument should be true unless the memory in "mr" is
260+
// known to be zeroed.
261+
void initialize(MemRegion mr, bool clear_space, bool mangle_space);
268262

269-
void clear(bool mangle_space) override;
263+
// The "clear" method must be called on a region that may have
264+
// had allocation performed in it, but is now to be considered empty.
265+
virtual void clear(bool mangle_space);
270266

271267
// Used temporarily during a compaction phase to hold the value
272268
// top should have when compaction is complete.

0 commit comments

Comments
 (0)
Please sign in to comment.