Skip to content
Permalink
Browse files
8274927: Remove unnecessary G1ArchiveAllocator code
Reviewed-by: kbarrett, ayang
  • Loading branch information
Thomas Schatzl committed Oct 11, 2021
1 parent c55dd36 commit aaf2401bc7d766dee5ffc623db86c4723c7e3760
Showing with 10 additions and 36 deletions.
  1. +0 −2 src/hotspot/share/gc/g1/g1Allocator.cpp
  2. +0 −17 src/hotspot/share/gc/g1/g1Allocator.hpp
  3. +10 −17 src/hotspot/share/gc/g1/g1CollectedHeap.cpp
@@ -475,7 +475,6 @@ HeapWord* G1ArchiveAllocator::archive_mem_allocate(size_t word_size) {
// Non-zero space; need to insert the filler
size_t fill_size = free_words;
CollectedHeap::fill_with_object(old_top, fill_size);
_summary_bytes_used += fill_size * HeapWordSize;
}
// Set the current chunk as "full"
_allocation_region->set_top(_max);
@@ -495,7 +494,6 @@ HeapWord* G1ArchiveAllocator::archive_mem_allocate(size_t word_size) {
}
assert(pointer_delta(_max, old_top) >= word_size, "enough space left");
_allocation_region->set_top(old_top + word_size);
_summary_bytes_used += word_size * HeapWordSize;

return old_top;
}
@@ -223,9 +223,6 @@ class G1ArchiveAllocator : public CHeapObj<mtGC> {
// Regions allocated for the current archive range.
GrowableArray<HeapRegion*> _allocated_regions;

// The number of bytes used in the current range.
size_t _summary_bytes_used;

// Current allocation window within the current region.
HeapWord* _bottom;
HeapWord* _top;
@@ -243,7 +240,6 @@ class G1ArchiveAllocator : public CHeapObj<mtGC> {
_allocated_regions((ResourceObj::set_allocation_type((address) &_allocated_regions,
ResourceObj::C_HEAP),
2), mtGC),
_summary_bytes_used(0),
_bottom(NULL),
_top(NULL),
_max(NULL) { }
@@ -261,19 +257,6 @@ class G1ArchiveAllocator : public CHeapObj<mtGC> {
// aligning to the requested alignment.
void complete_archive(GrowableArray<MemRegion>* ranges,
size_t end_alignment_in_bytes);

// The number of bytes allocated by this allocator.
size_t used() {
return _summary_bytes_used;
}

// Clear the count of bytes allocated in prior G1 regions. This
// must be done when recalculate_use is used to reset the counter
// for the generic allocator, since it counts bytes in all G1
// regions, including those still associated with this allocator.
void clear_used() {
_summary_bytes_used = 0;
}
};

#endif // SHARE_GC_G1_G1ALLOCATOR_HPP
@@ -498,9 +498,8 @@ HeapWord* G1CollectedHeap::attempt_allocation_slow(size_t word_size) {

void G1CollectedHeap::begin_archive_alloc_range(bool open) {
assert_at_safepoint_on_vm_thread();
if (_archive_allocator == NULL) {
_archive_allocator = G1ArchiveAllocator::create_allocator(this, open);
}
assert(_archive_allocator == nullptr, "should not be initialized");
_archive_allocator = G1ArchiveAllocator::create_allocator(this, open);
}

bool G1CollectedHeap::is_archive_alloc_too_large(size_t word_size) {
@@ -512,23 +511,23 @@ bool G1CollectedHeap::is_archive_alloc_too_large(size_t word_size) {

HeapWord* G1CollectedHeap::archive_mem_allocate(size_t word_size) {
assert_at_safepoint_on_vm_thread();
assert(_archive_allocator != NULL, "_archive_allocator not initialized");
assert(_archive_allocator != nullptr, "_archive_allocator not initialized");
if (is_archive_alloc_too_large(word_size)) {
return NULL;
return nullptr;
}
return _archive_allocator->archive_mem_allocate(word_size);
}

void G1CollectedHeap::end_archive_alloc_range(GrowableArray<MemRegion>* ranges,
size_t end_alignment_in_bytes) {
assert_at_safepoint_on_vm_thread();
assert(_archive_allocator != NULL, "_archive_allocator not initialized");
assert(_archive_allocator != nullptr, "_archive_allocator not initialized");

// Call complete_archive to do the real work, filling in the MemRegion
// array with the archive regions.
_archive_allocator->complete_archive(ranges, end_alignment_in_bytes);
delete _archive_allocator;
_archive_allocator = NULL;
_archive_allocator = nullptr;
}

bool G1CollectedHeap::check_archive_addresses(MemRegion* ranges, size_t count) {
@@ -1449,7 +1448,7 @@ G1CollectedHeap::G1CollectedHeap() :
_verifier(NULL),
_summary_bytes_used(0),
_bytes_used_during_gc(0),
_archive_allocator(NULL),
_archive_allocator(nullptr),
_survivor_evac_stats("Young", YoungPLABSize, PLABWeight),
_old_evac_stats("Old", OldPLABSize, PLABWeight),
_monitoring_support(nullptr),
@@ -1861,9 +1860,7 @@ void G1CollectedHeap::iterate_hcc_closure(G1CardTableEntryClosure* cl, uint work
// Computes the sum of the storage used by the various regions.
size_t G1CollectedHeap::used() const {
size_t result = _summary_bytes_used + _allocator->used_in_alloc_regions();
if (_archive_allocator != NULL) {
result += _archive_allocator->used();
}
assert(_archive_allocator == nullptr, "must be, should not contribute to used");
return result;
}

@@ -3197,9 +3194,7 @@ void G1CollectedHeap::rebuild_region_sets(bool free_list_only) {

if (!free_list_only) {
set_used(cl.total_used());
if (_archive_allocator != NULL) {
_archive_allocator->clear_used();
}
assert(_archive_allocator == nullptr, "must be, should not contribute to used");
}
assert_used_and_recalculate_used_equal(this);
}
@@ -3393,9 +3388,7 @@ void G1CollectedHeap::update_used_after_gc(bool evacuation_failed) {

set_used(recalculate_used());

if (_archive_allocator != NULL) {
_archive_allocator->clear_used();
}
assert(_archive_allocator == nullptr, "must be, should not contribute to used");
} else {
// The "used" of the the collection set have already been subtracted
// when they were freed. Add in the bytes used.

1 comment on commit aaf2401

@openjdk-notifier
Copy link

@openjdk-notifier openjdk-notifier bot commented on aaf2401 Oct 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.