Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/hotspot/share/gc/g1/g1Allocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,14 @@ void G1Allocator::reuse_retained_old_region(G1EvacInfo* evacuation_info,
}
}

size_t G1Allocator::free_bytes_in_retained_old_region() const {
if (_retained_old_gc_alloc_region == nullptr) {
return 0;
} else {
return _retained_old_gc_alloc_region->free();
}
}

void G1Allocator::init_gc_alloc_regions(G1EvacInfo* evacuation_info) {
assert_at_safepoint_on_vm_thread();

Expand Down
3 changes: 3 additions & 0 deletions src/hotspot/share/gc/g1/g1Allocator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,10 @@ class G1Allocator : public CHeapObj<mtGC> {
void init_gc_alloc_regions(G1EvacInfo* evacuation_info);
void release_gc_alloc_regions(G1EvacInfo* evacuation_info);
void abandon_gc_alloc_regions();

bool is_retained_old_region(G1HeapRegion* hr);
// Return the amount of free bytes in the current retained old region.
size_t free_bytes_in_retained_old_region() const;

// Node index of current thread.
inline uint current_node_index() const;
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/gc/g1/g1CollectedHeap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2964,8 +2964,8 @@ void G1CollectedHeap::abandon_collection_set() {
}

size_t G1CollectedHeap::non_young_occupancy_after_allocation(size_t allocation_word_size) {
// For simplicity, just count whole regions.
const size_t cur_occupancy = (old_regions_count() + humongous_regions_count()) * G1HeapRegion::GrainBytes;
const size_t cur_occupancy = (old_regions_count() + humongous_regions_count()) * G1HeapRegion::GrainBytes -
_allocator->free_bytes_in_retained_old_region();
// Humongous allocations will always be assigned to non-young heap, so consider
// that allocation in the result as well. Otherwise the allocation will always
// be in young gen, so there is no need to account it here.
Expand Down