Skip to content
Permalink
Browse files
8268556: Use bitmap for storing regions that failed evacuation
Reviewed-by: kbarrett, iwalulya, sjohanss
  • Loading branch information
Thomas Schatzl committed Jun 17, 2021
1 parent 2d088fa commit f2afe0a5130fd3162403ecc18c827bcf56e9c883
Showing 3 changed files with 8 additions and 11 deletions.
@@ -1477,7 +1477,7 @@ G1CollectedHeap::G1CollectedHeap() :
_cr(NULL),
_task_queues(NULL),
_num_regions_failed_evacuation(0),
_regions_failed_evacuation(NULL),
_regions_failed_evacuation(mtGC),
_evacuation_failed_info_array(NULL),
_preserved_marks_set(true /* in_c_heap */),
#ifndef PRODUCT
@@ -1770,7 +1770,7 @@ jint G1CollectedHeap::initialize() {

_collection_set.initialize(max_reserved_regions());

_regions_failed_evacuation = NEW_C_HEAP_ARRAY(volatile bool, max_regions(), mtGC);
_regions_failed_evacuation.resize(max_regions());

G1InitLogger::print();

@@ -3470,7 +3470,7 @@ void G1CollectedHeap::pre_evacuate_collection_set(G1EvacuationInfo& evacuation_i
_expand_heap_after_alloc_failure = true;
Atomic::store(&_num_regions_failed_evacuation, 0u);

memset((void*)_regions_failed_evacuation, false, sizeof(bool) * max_regions());
_regions_failed_evacuation.clear();

// Disable the hot card cache.
_hot_card_cache->reset_hot_cache_claimed_index();
@@ -55,6 +55,7 @@
#include "gc/shared/softRefPolicy.hpp"
#include "gc/shared/taskqueue.hpp"
#include "memory/memRegion.hpp"
#include "utilities/bitMap.hpp"
#include "utilities/stack.hpp"

// A "G1CollectedHeap" is an implementation of a java heap for HotSpot.
@@ -868,7 +869,7 @@ class G1CollectedHeap : public CollectedHeap {
// Number of regions evacuation failed in the current collection.
volatile uint _num_regions_failed_evacuation;
// Records for every region on the heap whether evacuation failed for it.
volatile bool* _regions_failed_evacuation;
CHeapBitMap _regions_failed_evacuation;

EvacuationFailedInfo* _evacuation_failed_info_array;

@@ -37,6 +37,7 @@
#include "gc/shared/markBitMap.inline.hpp"
#include "gc/shared/taskqueue.inline.hpp"
#include "runtime/atomic.hpp"
#include "utilities/bitMap.inline.hpp"

G1GCPhaseTimes* G1CollectedHeap::phase_times() const {
return _policy->phase_times();
@@ -195,20 +196,15 @@ bool G1CollectedHeap::evacuation_failed() const {
}

bool G1CollectedHeap::evacuation_failed(uint region_idx) const {
assert(region_idx < max_regions(), "Invalid region index %u", region_idx);

return Atomic::load(&_regions_failed_evacuation[region_idx]);
return _regions_failed_evacuation.par_at(region_idx, memory_order_relaxed);
}

uint G1CollectedHeap::num_regions_failed_evacuation() const {
return Atomic::load(&_num_regions_failed_evacuation);
}

bool G1CollectedHeap::notify_region_failed_evacuation(uint const region_idx) {
assert(region_idx < max_regions(), "Invalid region index %u", region_idx);

volatile bool* region_failed_addr = &_regions_failed_evacuation[region_idx];
bool result = !Atomic::load(region_failed_addr) && !Atomic::cmpxchg(region_failed_addr, false, true, memory_order_relaxed);
bool result = _regions_failed_evacuation.par_set_bit(region_idx, memory_order_relaxed);
if (result) {
Atomic::inc(&_num_regions_failed_evacuation, memory_order_relaxed);
}

1 comment on commit f2afe0a

@openjdk-notifier
Copy link

@openjdk-notifier openjdk-notifier bot commented on f2afe0a Jun 17, 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.