Skip to content

Commit 5f2b8d0

Browse files
committed
8332448: Make SpaceMangler inherit AllStatic
Reviewed-by: kbarrett, iwalulya
1 parent 8a49d47 commit 5f2b8d0

26 files changed

+35
-514
lines changed

src/hotspot/share/gc/parallel/mutableNUMASpace.cpp

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -83,18 +83,7 @@ void MutableNUMASpace::mangle_unused_area() {
8383
void MutableNUMASpace::mangle_region(MemRegion mr) {
8484
// This method should do nothing because numa spaces are not mangled.
8585
}
86-
void MutableNUMASpace::set_top_for_allocations(HeapWord* v) {
87-
assert(false, "Do not mangle MutableNUMASpace's");
88-
}
89-
void MutableNUMASpace::set_top_for_allocations() {
90-
// This method should do nothing.
91-
}
92-
void MutableNUMASpace::check_mangled_unused_area(HeapWord* limit) {
93-
// This method should do nothing.
94-
}
95-
void MutableNUMASpace::check_mangled_unused_area_complete() {
96-
// This method should do nothing.
97-
}
86+
9887
#endif // NOT_PRODUCT
9988

10089
// There may be unallocated holes in the middle chunks

src/hotspot/share/gc/parallel/mutableNUMASpace.hpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,10 +175,6 @@ class MutableNUMASpace : public MutableSpace {
175175
virtual void mangle_unused_area() PRODUCT_RETURN;
176176

177177
virtual void mangle_region(MemRegion mr) PRODUCT_RETURN;
178-
virtual void check_mangled_unused_area(HeapWord* limit) PRODUCT_RETURN;
179-
virtual void check_mangled_unused_area_complete() PRODUCT_RETURN;
180-
virtual void set_top_for_allocations(HeapWord* v) PRODUCT_RETURN;
181-
virtual void set_top_for_allocations() PRODUCT_RETURN;
182178

183179
virtual void ensure_parsability();
184180
virtual size_t used_in_words() const;

src/hotspot/share/gc/parallel/mutableSpace.cpp

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#include "precompiled.hpp"
2626
#include "gc/parallel/mutableSpace.hpp"
2727
#include "gc/shared/pretouchTask.hpp"
28-
#include "gc/shared/spaceDecorator.inline.hpp"
2928
#include "memory/iterator.inline.hpp"
3029
#include "memory/universe.hpp"
3130
#include "oops/oop.inline.hpp"
@@ -36,7 +35,6 @@
3635
#include "utilities/macros.hpp"
3736

3837
MutableSpace::MutableSpace(size_t alignment) :
39-
_mangler(nullptr),
4038
_last_setup_region(),
4139
_alignment(alignment),
4240
_bottom(nullptr),
@@ -45,11 +43,6 @@ MutableSpace::MutableSpace(size_t alignment) :
4543
{
4644
assert(MutableSpace::alignment() % os::vm_page_size() == 0,
4745
"Space should be aligned");
48-
_mangler = new MutableSpaceMangler(this);
49-
}
50-
51-
MutableSpace::~MutableSpace() {
52-
delete _mangler;
5346
}
5447

5548
void MutableSpace::numa_setup_pages(MemRegion mr, size_t page_size, bool clear_space) {
@@ -152,32 +145,15 @@ void MutableSpace::clear(bool mangle_space) {
152145
}
153146

154147
#ifndef PRODUCT
155-
void MutableSpace::check_mangled_unused_area(HeapWord* limit) {
156-
mangler()->check_mangled_unused_area(limit);
157-
}
158-
159-
void MutableSpace::check_mangled_unused_area_complete() {
160-
mangler()->check_mangled_unused_area_complete();
161-
}
162148

163-
// Mangle only the unused space that has not previously
164-
// been mangled and that has not been allocated since being
165-
// mangled.
166149
void MutableSpace::mangle_unused_area() {
167-
mangler()->mangle_unused_area();
150+
mangle_region(MemRegion(_top, _end));
168151
}
169152

170153
void MutableSpace::mangle_region(MemRegion mr) {
171154
SpaceMangler::mangle_region(mr);
172155
}
173156

174-
void MutableSpace::set_top_for_allocations(HeapWord* v) {
175-
mangler()->set_top_for_allocations(v);
176-
}
177-
178-
void MutableSpace::set_top_for_allocations() {
179-
mangler()->set_top_for_allocations(top());
180-
}
181157
#endif
182158

183159
HeapWord* MutableSpace::cas_allocate(size_t size) {

src/hotspot/share/gc/parallel/mutableSpace.hpp

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -46,29 +46,23 @@ class WorkerThreads;
4646
// Invariant: bottom() <= top() <= end()
4747
// top() and end() are exclusive.
4848

49-
class MutableSpaceMangler;
50-
5149
class MutableSpace: public CHeapObj<mtGC> {
5250
friend class VMStructs;
5351

54-
// Helper for mangling unused space in debug builds
55-
MutableSpaceMangler* _mangler;
5652
// The last region which page had been setup to be interleaved.
5753
MemRegion _last_setup_region;
5854
size_t _alignment;
5955
HeapWord* _bottom;
6056
HeapWord* volatile _top;
6157
HeapWord* _end;
6258

63-
MutableSpaceMangler* mangler() { return _mangler; }
64-
6559
void numa_setup_pages(MemRegion mr, size_t page_size, bool clear_space);
6660

6761
void set_last_setup_region(MemRegion mr) { _last_setup_region = mr; }
6862
MemRegion last_setup_region() const { return _last_setup_region; }
6963

7064
public:
71-
virtual ~MutableSpace();
65+
virtual ~MutableSpace() = default;
7266
MutableSpace(size_t page_size);
7367

7468
// Accessors
@@ -107,20 +101,11 @@ class MutableSpace: public CHeapObj<mtGC> {
107101
virtual void update() { }
108102
virtual void accumulate_statistics() { }
109103

110-
// Methods used in mangling. See descriptions under SpaceMangler.
111104
virtual void mangle_unused_area() PRODUCT_RETURN;
112-
113-
virtual void check_mangled_unused_area(HeapWord* limit) PRODUCT_RETURN;
114-
virtual void check_mangled_unused_area_complete() PRODUCT_RETURN;
115-
virtual void set_top_for_allocations(HeapWord* v) PRODUCT_RETURN;
116-
117-
// Used to save the space's current top for later use during mangling.
118-
virtual void set_top_for_allocations() PRODUCT_RETURN;
105+
virtual void mangle_region(MemRegion mr) PRODUCT_RETURN;
119106

120107
virtual void ensure_parsability() { }
121108

122-
virtual void mangle_region(MemRegion mr) PRODUCT_RETURN;
123-
124109
// Boolean queries.
125110
bool is_empty() const { return used_in_words() == 0; }
126111
bool not_empty() const { return used_in_words() > 0; }

src/hotspot/share/gc/parallel/parallelScavengeHeap.cpp

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -841,24 +841,6 @@ void ParallelScavengeHeap::complete_loaded_archive_space(MemRegion archive_space
841841
_old_gen->complete_loaded_archive_space(archive_space);
842842
}
843843

844-
#ifndef PRODUCT
845-
void ParallelScavengeHeap::record_gen_tops_before_GC() {
846-
if (ZapUnusedHeapArea) {
847-
young_gen()->record_spaces_top();
848-
old_gen()->record_spaces_top();
849-
}
850-
}
851-
852-
void ParallelScavengeHeap::gen_mangle_unused_area() {
853-
if (ZapUnusedHeapArea) {
854-
young_gen()->eden_space()->mangle_unused_area();
855-
young_gen()->to_space()->mangle_unused_area();
856-
young_gen()->from_space()->mangle_unused_area();
857-
old_gen()->object_space()->mangle_unused_area();
858-
}
859-
}
860-
#endif
861-
862844
void ParallelScavengeHeap::register_nmethod(nmethod* nm) {
863845
ScavengableNMethods::register_nmethod(nm);
864846
}

src/hotspot/share/gc/parallel/parallelScavengeHeap.hpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -243,12 +243,6 @@ class ParallelScavengeHeap : public CollectedHeap {
243243
// generation may be expanded in preparation for the resize.
244244
void resize_old_gen(size_t desired_free_space);
245245

246-
// Save the tops of the spaces in all generations
247-
void record_gen_tops_before_GC() PRODUCT_RETURN;
248-
249-
// Mangle the unused parts of all spaces in the heap
250-
void gen_mangle_unused_area() PRODUCT_RETURN;
251-
252246
GCMemoryManager* old_gc_manager() const { return _old_manager; }
253247
GCMemoryManager* young_gc_manager() const { return _young_manager; }
254248

src/hotspot/share/gc/parallel/psOldGen.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
#include "gc/parallel/psOldGen.hpp"
3232
#include "gc/shared/cardTableBarrierSet.hpp"
3333
#include "gc/shared/gcLocker.hpp"
34-
#include "gc/shared/spaceDecorator.inline.hpp"
3534
#include "logging/log.hpp"
3635
#include "oops/oop.inline.hpp"
3736
#include "runtime/java.hpp"
@@ -376,10 +375,3 @@ void PSOldGen::update_counters() {
376375
void PSOldGen::verify() {
377376
object_space()->verify();
378377
}
379-
380-
#ifndef PRODUCT
381-
void PSOldGen::record_spaces_top() {
382-
assert(ZapUnusedHeapArea, "Not mangling unused space");
383-
object_space()->set_top_for_allocations();
384-
}
385-
#endif

src/hotspot/share/gc/parallel/psOldGen.hpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,6 @@ class PSOldGen : public CHeapObj<mtGC> {
156156
// Printing support
157157
const char* name() const { return "ParOldGen"; }
158158

159-
// Debugging support
160-
// Save the tops of all spaces for later use during mangling.
161-
void record_spaces_top() PRODUCT_RETURN;
162159
};
163160

164161
#endif // SHARE_GC_PARALLEL_PSOLDGEN_HPP

src/hotspot/share/gc/parallel/psParallelCompact.cpp

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@
5757
#include "gc/shared/referencePolicy.hpp"
5858
#include "gc/shared/referenceProcessor.hpp"
5959
#include "gc/shared/referenceProcessorPhaseTimes.hpp"
60-
#include "gc/shared/spaceDecorator.inline.hpp"
6160
#include "gc/shared/strongRootsScope.hpp"
6261
#include "gc/shared/taskTerminator.hpp"
6362
#include "gc/shared/weakProcessor.inline.hpp"
@@ -963,8 +962,16 @@ void PSParallelCompact::post_compact()
963962
for (unsigned int id = old_space_id; id < last_space_id; ++id) {
964963
// Clear the marking bitmap, summary data and split info.
965964
clear_data_covering_space(SpaceId(id));
966-
// Update top(). Must be done after clearing the bitmap and summary data.
967-
_space_info[id].publish_new_top();
965+
{
966+
MutableSpace* space = _space_info[id].space();
967+
HeapWord* top = space->top();
968+
HeapWord* new_top = _space_info[id].new_top();
969+
if (ZapUnusedHeapArea && new_top < top) {
970+
space->mangle_region(MemRegion(new_top, top));
971+
}
972+
// Update top(). Must be done after clearing the bitmap and summary data.
973+
space->set_top(new_top);
974+
}
968975
}
969976

970977
ParCompactionManager::flush_all_string_dedup_requests();
@@ -1007,10 +1014,6 @@ void PSParallelCompact::post_compact()
10071014
DerivedPointerTable::update_pointers();
10081015
#endif
10091016

1010-
if (ZapUnusedHeapArea) {
1011-
heap->gen_mangle_unused_area();
1012-
}
1013-
10141017
// Signal that we have completed a visit to all live objects.
10151018
Universe::heap()->record_whole_heap_examined_timestamp();
10161019
}
@@ -1307,11 +1310,6 @@ bool PSParallelCompact::invoke_no_policy(bool maximum_heap_compaction) {
13071310
ClearedAllSoftRefs casr(maximum_heap_compaction,
13081311
heap->soft_ref_policy());
13091312

1310-
if (ZapUnusedHeapArea) {
1311-
// Save information needed to minimize mangling
1312-
heap->record_gen_tops_before_GC();
1313-
}
1314-
13151313
// Make sure data structures are sane, make the heap parsable, and do other
13161314
// miscellaneous bookkeeping.
13171315
pre_compact();
@@ -1469,10 +1467,6 @@ bool PSParallelCompact::invoke_no_policy(bool maximum_heap_compaction) {
14691467
Universe::verify("After GC");
14701468
}
14711469

1472-
if (ZapUnusedHeapArea) {
1473-
old_gen->object_space()->check_mangled_unused_area_complete();
1474-
}
1475-
14761470
heap->print_heap_after_gc();
14771471
heap->trace_heap_after_gc(&_gc_tracer);
14781472

src/hotspot/share/gc/parallel/psScavenge.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@
5050
#include "gc/shared/referenceProcessor.hpp"
5151
#include "gc/shared/referenceProcessorPhaseTimes.hpp"
5252
#include "gc/shared/scavengableNMethods.hpp"
53-
#include "gc/shared/spaceDecorator.inline.hpp"
5453
#include "gc/shared/strongRootsScope.hpp"
5554
#include "gc/shared/taskTerminator.hpp"
5655
#include "gc/shared/weakProcessor.inline.hpp"

0 commit comments

Comments
 (0)