--- old/src/hotspot/share/gc/g1/g1ParScanThreadState.cpp 2018-11-26 21:50:55.972488296 +0100 +++ new/src/hotspot/share/gc/g1/g1ParScanThreadState.cpp 2018-11-26 21:50:55.544486173 +0100 @@ -37,7 +37,10 @@ #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()), @@ -51,7 +54,8 @@ _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 @@ -78,6 +82,11 @@ _dest[InCSetState::Old] = InCSetState::Old; _closures = G1EvacuationRootClosures::create_root_closures(this, _g1h); + + _oops_into_optional_regions = NEW_C_HEAP_ARRAY(G1OopStarChunkedList, _num_optional_regions, mtGC); + for (size_t i = 0; i < _num_optional_regions; i++) { + ::new (_oops_into_optional_regions + i) G1OopStarChunkedList(); + } } // Pass locally gathered statistics to global state. @@ -97,6 +106,12 @@ delete _plab_allocator; delete _closures; FREE_C_HEAP_ARRAY(size_t, _surviving_young_words_base); + size_t used_by_optional = 0; + for (size_t i = 0; i < _num_optional_regions; i++) { + used_by_optional += _oops_into_optional_regions[i].free_chunk_lists(); + } + _g1h->g1_policy()->phase_times()->record_thread_work_item(G1GCPhaseTimes::OptScanRS, _worker_id, used_by_optional, G1GCPhaseTimes::OptCSetUsedMemory); + FREE_C_HEAP_ARRAY(G1OopStarChunkedList, _oops_into_optional_regions); } void G1ParScanThreadState::waste(size_t& wasted, size_t& undo_wasted) { @@ -324,7 +339,8 @@ 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]; } @@ -381,11 +397,15 @@ 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) {