< prev index next >
src/hotspot/share/gc/g1/g1ParScanThreadState.cpp
Print this page
rev 52675 : 8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
Reviewed-by:
Contributed-by: erik.helin@oracle.com, stefan.johansson@oracle.com
rev 52676 : imported patch AMGC-impl
rev 52679 : imported patch AMGC-tsch-rev1-log
rev 52681 : [mq]: AMGC-kbar-rev1
rev 52682 : [mq]: AMGC-kbar-rev1b
@@ -35,11 +35,14 @@
#include "memory/allocation.inline.hpp"
#include "oops/access.inline.hpp"
#include "oops/oop.inline.hpp"
#include "runtime/prefetch.inline.hpp"
-G1ParScanThreadState::G1ParScanThreadState(G1CollectedHeap* g1h, uint worker_id, size_t young_cset_length)
+G1ParScanThreadState::G1ParScanThreadState(G1CollectedHeap* g1h,
+ uint worker_id,
+ size_t young_cset_length,
+ size_t optional_cset_length)
: _g1h(g1h),
_refs(g1h->task_queue(worker_id)),
_dcq(&g1h->dirty_card_queue_set()),
_ct(g1h->card_table()),
_closures(NULL),
@@ -49,11 +52,12 @@
_scanner(g1h, this),
_worker_id(worker_id),
_stack_trim_upper_threshold(GCDrainStackTargetSize * 2 + 1),
_stack_trim_lower_threshold(GCDrainStackTargetSize),
_trim_ticks(),
- _old_gen_is_full(false)
+ _old_gen_is_full(false),
+ _num_optional_regions(optional_cset_length)
{
// we allocate G1YoungSurvRateNumRegions plus one entries, since
// we "sacrifice" entry 0 to keep track of surviving bytes for
// non-young regions (where the age is -1)
// We also add a few elements at the beginning and at the end in
@@ -76,10 +80,12 @@
// need to be moved to the next space.
_dest[InCSetState::Young] = InCSetState::Old;
_dest[InCSetState::Old] = InCSetState::Old;
_closures = G1EvacuationRootClosures::create_root_closures(this, _g1h);
+
+ _oops_into_optional_regions = new G1OopStarChunkedList[_num_optional_regions];
}
// Pass locally gathered statistics to global state.
void G1ParScanThreadState::flush(size_t* surviving_young_words) {
_dcq.flush();
@@ -95,10 +101,11 @@
G1ParScanThreadState::~G1ParScanThreadState() {
delete _plab_allocator;
delete _closures;
FREE_C_HEAP_ARRAY(size_t, _surviving_young_words_base);
+ delete[] _oops_into_optional_regions;
}
void G1ParScanThreadState::waste(size_t& wasted, size_t& undo_wasted) {
_plab_allocator->waste(wasted, undo_wasted);
}
@@ -322,11 +329,12 @@
}
G1ParScanThreadState* G1ParScanThreadStateSet::state_for_worker(uint worker_id) {
assert(worker_id < _n_workers, "out of bounds access");
if (_states[worker_id] == NULL) {
- _states[worker_id] = new G1ParScanThreadState(_g1h, worker_id, _young_cset_length);
+ _states[worker_id] =
+ new G1ParScanThreadState(_g1h, worker_id, _young_cset_length, _optional_cset_length);
}
return _states[worker_id];
}
const size_t* G1ParScanThreadStateSet::surviving_young_words() const {
@@ -349,10 +357,23 @@
_states[worker_index] = NULL;
}
_flushed = true;
}
+void G1ParScanThreadStateSet::record_unused_optional_region(HeapRegion* hr) {
+ for (uint worker_index = 0; worker_index < _n_workers; ++worker_index) {
+ G1ParScanThreadState* pss = _states[worker_index];
+
+ if (pss == NULL) {
+ continue;
+ }
+
+ size_t used_memory = pss->oops_into_optional_region(hr)->used_memory();
+ _g1h->g1_policy()->phase_times()->record_or_add_thread_work_item(G1GCPhaseTimes::OptScanRS, worker_index, used_memory, G1GCPhaseTimes::OptCSetUsedMemory);
+ }
+}
+
oop G1ParScanThreadState::handle_evacuation_failure_par(oop old, markOop m) {
assert(_g1h->is_in_cset(old), "Object " PTR_FORMAT " should be in the CSet", p2i(old));
oop forward_ptr = old->forward_to_atomic(old, m, memory_order_relaxed);
if (forward_ptr == NULL) {
@@ -379,15 +400,19 @@
"should not be in the CSet",
p2i(old), p2i(forward_ptr));
return forward_ptr;
}
}
-G1ParScanThreadStateSet::G1ParScanThreadStateSet(G1CollectedHeap* g1h, uint n_workers, size_t young_cset_length) :
+G1ParScanThreadStateSet::G1ParScanThreadStateSet(G1CollectedHeap* g1h,
+ uint n_workers,
+ size_t young_cset_length,
+ size_t optional_cset_length) :
_g1h(g1h),
_states(NEW_C_HEAP_ARRAY(G1ParScanThreadState*, n_workers, mtGC)),
_surviving_young_words_total(NEW_C_HEAP_ARRAY(size_t, young_cset_length, mtGC)),
_young_cset_length(young_cset_length),
+ _optional_cset_length(optional_cset_length),
_n_workers(n_workers),
_flushed(false) {
for (uint i = 0; i < n_workers; ++i) {
_states[i] = NULL;
}
< prev index next >