Skip to content

Commit

Permalink
8332448: Make SpaceMangler inherit AllStatic
Browse files Browse the repository at this point in the history
Reviewed-by: kbarrett, iwalulya
  • Loading branch information
albertnetymk committed May 21, 2024
1 parent 8a49d47 commit 5f2b8d0
Show file tree
Hide file tree
Showing 26 changed files with 35 additions and 514 deletions.
13 changes: 1 addition & 12 deletions src/hotspot/share/gc/parallel/mutableNUMASpace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,18 +83,7 @@ void MutableNUMASpace::mangle_unused_area() {
void MutableNUMASpace::mangle_region(MemRegion mr) {
// This method should do nothing because numa spaces are not mangled.
}
void MutableNUMASpace::set_top_for_allocations(HeapWord* v) {
assert(false, "Do not mangle MutableNUMASpace's");
}
void MutableNUMASpace::set_top_for_allocations() {
// This method should do nothing.
}
void MutableNUMASpace::check_mangled_unused_area(HeapWord* limit) {
// This method should do nothing.
}
void MutableNUMASpace::check_mangled_unused_area_complete() {
// This method should do nothing.
}

#endif // NOT_PRODUCT

// There may be unallocated holes in the middle chunks
Expand Down
4 changes: 0 additions & 4 deletions src/hotspot/share/gc/parallel/mutableNUMASpace.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,6 @@ class MutableNUMASpace : public MutableSpace {
virtual void mangle_unused_area() PRODUCT_RETURN;

virtual void mangle_region(MemRegion mr) PRODUCT_RETURN;
virtual void check_mangled_unused_area(HeapWord* limit) PRODUCT_RETURN;
virtual void check_mangled_unused_area_complete() PRODUCT_RETURN;
virtual void set_top_for_allocations(HeapWord* v) PRODUCT_RETURN;
virtual void set_top_for_allocations() PRODUCT_RETURN;

virtual void ensure_parsability();
virtual size_t used_in_words() const;
Expand Down
26 changes: 1 addition & 25 deletions src/hotspot/share/gc/parallel/mutableSpace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#include "precompiled.hpp"
#include "gc/parallel/mutableSpace.hpp"
#include "gc/shared/pretouchTask.hpp"
#include "gc/shared/spaceDecorator.inline.hpp"
#include "memory/iterator.inline.hpp"
#include "memory/universe.hpp"
#include "oops/oop.inline.hpp"
Expand All @@ -36,7 +35,6 @@
#include "utilities/macros.hpp"

MutableSpace::MutableSpace(size_t alignment) :
_mangler(nullptr),
_last_setup_region(),
_alignment(alignment),
_bottom(nullptr),
Expand All @@ -45,11 +43,6 @@ MutableSpace::MutableSpace(size_t alignment) :
{
assert(MutableSpace::alignment() % os::vm_page_size() == 0,
"Space should be aligned");
_mangler = new MutableSpaceMangler(this);
}

MutableSpace::~MutableSpace() {
delete _mangler;
}

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

#ifndef PRODUCT
void MutableSpace::check_mangled_unused_area(HeapWord* limit) {
mangler()->check_mangled_unused_area(limit);
}

void MutableSpace::check_mangled_unused_area_complete() {
mangler()->check_mangled_unused_area_complete();
}

// Mangle only the unused space that has not previously
// been mangled and that has not been allocated since being
// mangled.
void MutableSpace::mangle_unused_area() {
mangler()->mangle_unused_area();
mangle_region(MemRegion(_top, _end));
}

void MutableSpace::mangle_region(MemRegion mr) {
SpaceMangler::mangle_region(mr);
}

void MutableSpace::set_top_for_allocations(HeapWord* v) {
mangler()->set_top_for_allocations(v);
}

void MutableSpace::set_top_for_allocations() {
mangler()->set_top_for_allocations(top());
}
#endif

HeapWord* MutableSpace::cas_allocate(size_t size) {
Expand Down
19 changes: 2 additions & 17 deletions src/hotspot/share/gc/parallel/mutableSpace.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,29 +46,23 @@ class WorkerThreads;
// Invariant: bottom() <= top() <= end()
// top() and end() are exclusive.

class MutableSpaceMangler;

class MutableSpace: public CHeapObj<mtGC> {
friend class VMStructs;

// Helper for mangling unused space in debug builds
MutableSpaceMangler* _mangler;
// The last region which page had been setup to be interleaved.
MemRegion _last_setup_region;
size_t _alignment;
HeapWord* _bottom;
HeapWord* volatile _top;
HeapWord* _end;

MutableSpaceMangler* mangler() { return _mangler; }

void numa_setup_pages(MemRegion mr, size_t page_size, bool clear_space);

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

public:
virtual ~MutableSpace();
virtual ~MutableSpace() = default;
MutableSpace(size_t page_size);

// Accessors
Expand Down Expand Up @@ -107,20 +101,11 @@ class MutableSpace: public CHeapObj<mtGC> {
virtual void update() { }
virtual void accumulate_statistics() { }

// Methods used in mangling. See descriptions under SpaceMangler.
virtual void mangle_unused_area() PRODUCT_RETURN;

virtual void check_mangled_unused_area(HeapWord* limit) PRODUCT_RETURN;
virtual void check_mangled_unused_area_complete() PRODUCT_RETURN;
virtual void set_top_for_allocations(HeapWord* v) PRODUCT_RETURN;

// Used to save the space's current top for later use during mangling.
virtual void set_top_for_allocations() PRODUCT_RETURN;
virtual void mangle_region(MemRegion mr) PRODUCT_RETURN;

virtual void ensure_parsability() { }

virtual void mangle_region(MemRegion mr) PRODUCT_RETURN;

// Boolean queries.
bool is_empty() const { return used_in_words() == 0; }
bool not_empty() const { return used_in_words() > 0; }
Expand Down
18 changes: 0 additions & 18 deletions src/hotspot/share/gc/parallel/parallelScavengeHeap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -841,24 +841,6 @@ void ParallelScavengeHeap::complete_loaded_archive_space(MemRegion archive_space
_old_gen->complete_loaded_archive_space(archive_space);
}

#ifndef PRODUCT
void ParallelScavengeHeap::record_gen_tops_before_GC() {
if (ZapUnusedHeapArea) {
young_gen()->record_spaces_top();
old_gen()->record_spaces_top();
}
}

void ParallelScavengeHeap::gen_mangle_unused_area() {
if (ZapUnusedHeapArea) {
young_gen()->eden_space()->mangle_unused_area();
young_gen()->to_space()->mangle_unused_area();
young_gen()->from_space()->mangle_unused_area();
old_gen()->object_space()->mangle_unused_area();
}
}
#endif

void ParallelScavengeHeap::register_nmethod(nmethod* nm) {
ScavengableNMethods::register_nmethod(nm);
}
Expand Down
6 changes: 0 additions & 6 deletions src/hotspot/share/gc/parallel/parallelScavengeHeap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,12 +243,6 @@ class ParallelScavengeHeap : public CollectedHeap {
// generation may be expanded in preparation for the resize.
void resize_old_gen(size_t desired_free_space);

// Save the tops of the spaces in all generations
void record_gen_tops_before_GC() PRODUCT_RETURN;

// Mangle the unused parts of all spaces in the heap
void gen_mangle_unused_area() PRODUCT_RETURN;

GCMemoryManager* old_gc_manager() const { return _old_manager; }
GCMemoryManager* young_gc_manager() const { return _young_manager; }

Expand Down
8 changes: 0 additions & 8 deletions src/hotspot/share/gc/parallel/psOldGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
#include "gc/parallel/psOldGen.hpp"
#include "gc/shared/cardTableBarrierSet.hpp"
#include "gc/shared/gcLocker.hpp"
#include "gc/shared/spaceDecorator.inline.hpp"
#include "logging/log.hpp"
#include "oops/oop.inline.hpp"
#include "runtime/java.hpp"
Expand Down Expand Up @@ -376,10 +375,3 @@ void PSOldGen::update_counters() {
void PSOldGen::verify() {
object_space()->verify();
}

#ifndef PRODUCT
void PSOldGen::record_spaces_top() {
assert(ZapUnusedHeapArea, "Not mangling unused space");
object_space()->set_top_for_allocations();
}
#endif
3 changes: 0 additions & 3 deletions src/hotspot/share/gc/parallel/psOldGen.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,6 @@ class PSOldGen : public CHeapObj<mtGC> {
// Printing support
const char* name() const { return "ParOldGen"; }

// Debugging support
// Save the tops of all spaces for later use during mangling.
void record_spaces_top() PRODUCT_RETURN;
};

#endif // SHARE_GC_PARALLEL_PSOLDGEN_HPP
26 changes: 10 additions & 16 deletions src/hotspot/share/gc/parallel/psParallelCompact.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
#include "gc/shared/referencePolicy.hpp"
#include "gc/shared/referenceProcessor.hpp"
#include "gc/shared/referenceProcessorPhaseTimes.hpp"
#include "gc/shared/spaceDecorator.inline.hpp"
#include "gc/shared/strongRootsScope.hpp"
#include "gc/shared/taskTerminator.hpp"
#include "gc/shared/weakProcessor.inline.hpp"
Expand Down Expand Up @@ -963,8 +962,16 @@ void PSParallelCompact::post_compact()
for (unsigned int id = old_space_id; id < last_space_id; ++id) {
// Clear the marking bitmap, summary data and split info.
clear_data_covering_space(SpaceId(id));
// Update top(). Must be done after clearing the bitmap and summary data.
_space_info[id].publish_new_top();
{
MutableSpace* space = _space_info[id].space();
HeapWord* top = space->top();
HeapWord* new_top = _space_info[id].new_top();
if (ZapUnusedHeapArea && new_top < top) {
space->mangle_region(MemRegion(new_top, top));
}
// Update top(). Must be done after clearing the bitmap and summary data.
space->set_top(new_top);
}
}

ParCompactionManager::flush_all_string_dedup_requests();
Expand Down Expand Up @@ -1007,10 +1014,6 @@ void PSParallelCompact::post_compact()
DerivedPointerTable::update_pointers();
#endif

if (ZapUnusedHeapArea) {
heap->gen_mangle_unused_area();
}

// Signal that we have completed a visit to all live objects.
Universe::heap()->record_whole_heap_examined_timestamp();
}
Expand Down Expand Up @@ -1307,11 +1310,6 @@ bool PSParallelCompact::invoke_no_policy(bool maximum_heap_compaction) {
ClearedAllSoftRefs casr(maximum_heap_compaction,
heap->soft_ref_policy());

if (ZapUnusedHeapArea) {
// Save information needed to minimize mangling
heap->record_gen_tops_before_GC();
}

// Make sure data structures are sane, make the heap parsable, and do other
// miscellaneous bookkeeping.
pre_compact();
Expand Down Expand Up @@ -1469,10 +1467,6 @@ bool PSParallelCompact::invoke_no_policy(bool maximum_heap_compaction) {
Universe::verify("After GC");
}

if (ZapUnusedHeapArea) {
old_gen->object_space()->check_mangled_unused_area_complete();
}

heap->print_heap_after_gc();
heap->trace_heap_after_gc(&_gc_tracer);

Expand Down
1 change: 0 additions & 1 deletion src/hotspot/share/gc/parallel/psScavenge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
#include "gc/shared/referenceProcessor.hpp"
#include "gc/shared/referenceProcessorPhaseTimes.hpp"
#include "gc/shared/scavengableNMethods.hpp"
#include "gc/shared/spaceDecorator.inline.hpp"
#include "gc/shared/strongRootsScope.hpp"
#include "gc/shared/taskTerminator.hpp"
#include "gc/shared/weakProcessor.inline.hpp"
Expand Down
24 changes: 0 additions & 24 deletions src/hotspot/share/gc/parallel/psYoungGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
#include "gc/parallel/psYoungGen.hpp"
#include "gc/shared/gcUtil.hpp"
#include "gc/shared/genArguments.hpp"
#include "gc/shared/spaceDecorator.inline.hpp"
#include "logging/log.hpp"
#include "oops/oop.inline.hpp"
#include "runtime/java.hpp"
Expand Down Expand Up @@ -622,20 +621,6 @@ void PSYoungGen::resize_spaces(size_t requested_eden_size,
mangle_survivors(to_space(), toMR, from_space(), fromMR);
}
}

// If not mangling the spaces, do some checking to verify that
// the spaces are already mangled.
// The spaces should be correctly mangled at this point so
// do some checking here. Note that they are not being mangled
// in the calls to initialize().
// Must check mangling before the spaces are reshaped. Otherwise,
// the bottom or end of one space may have moved into an area
// covered by another space and a failure of the check may
// not correctly indicate which space is not properly mangled.
HeapWord* limit = (HeapWord*) virtual_space()->high();
eden_space()->check_mangled_unused_area(limit);
from_space()->check_mangled_unused_area(limit);
to_space()->check_mangled_unused_area(limit);
}

WorkerThreads* workers = &ParallelScavengeHeap::heap()->workers();
Expand Down Expand Up @@ -833,12 +818,3 @@ void PSYoungGen::verify() {
from_space()->verify();
to_space()->verify();
}

#ifndef PRODUCT
void PSYoungGen::record_spaces_top() {
assert(ZapUnusedHeapArea, "Not mangling unused space");
eden_space()->set_top_for_allocations();
from_space()->set_top_for_allocations();
to_space()->set_top_for_allocations();
}
#endif
2 changes: 0 additions & 2 deletions src/hotspot/share/gc/parallel/psYoungGen.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,6 @@ class PSYoungGen : public CHeapObj<mtGC> {
MemRegion s1MR,
MutableSpace* s2,
MemRegion s2MR) PRODUCT_RETURN;

void record_spaces_top() PRODUCT_RETURN;
};

#endif // SHARE_GC_PARALLEL_PSYOUNGGEN_HPP
Loading

0 comments on commit 5f2b8d0

Please sign in to comment.