< 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

@@ -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,15 @@
   // 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_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.
 void G1ParScanThreadState::flush(size_t* surviving_young_words) {
   _dcq.flush();

@@ -95,10 +104,16 @@
 
 G1ParScanThreadState::~G1ParScanThreadState() {
   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) {
   _plab_allocator->waste(wasted, undo_wasted);
 }

@@ -322,11 +337,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 {

@@ -379,15 +395,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 >