src/hotspot/share/gc/g1/g1ConcurrentMark.cpp
changeset 59249 29b0d0b61615
parent 59221 cc3a82fc7bcb
child 59252 623722a6aeb9
equal deleted inserted replaced
59248:e92153ed8bdc 59249:29b0d0b61615
   205   // wraparound of _hwm.
   205   // wraparound of _hwm.
   206   if (_hwm >= _chunk_capacity) {
   206   if (_hwm >= _chunk_capacity) {
   207     return NULL;
   207     return NULL;
   208   }
   208   }
   209 
   209 
   210   size_t cur_idx = Atomic::add(1u, &_hwm) - 1;
   210   size_t cur_idx = Atomic::add(&_hwm, 1u) - 1;
   211   if (cur_idx >= _chunk_capacity) {
   211   if (cur_idx >= _chunk_capacity) {
   212     return NULL;
   212     return NULL;
   213   }
   213   }
   214 
   214 
   215   TaskQueueEntryChunk* result = ::new (&_base[cur_idx]) TaskQueueEntryChunk;
   215   TaskQueueEntryChunk* result = ::new (&_base[cur_idx]) TaskQueueEntryChunk;
   278   _num_root_regions = 0;
   278   _num_root_regions = 0;
   279 }
   279 }
   280 
   280 
   281 void G1CMRootMemRegions::add(HeapWord* start, HeapWord* end) {
   281 void G1CMRootMemRegions::add(HeapWord* start, HeapWord* end) {
   282   assert_at_safepoint();
   282   assert_at_safepoint();
   283   size_t idx = Atomic::add((size_t)1, &_num_root_regions) - 1;
   283   size_t idx = Atomic::add(&_num_root_regions, (size_t)1) - 1;
   284   assert(idx < _max_regions, "Trying to add more root MemRegions than there is space " SIZE_FORMAT, _max_regions);
   284   assert(idx < _max_regions, "Trying to add more root MemRegions than there is space " SIZE_FORMAT, _max_regions);
   285   assert(start != NULL && end != NULL && start <= end, "Start (" PTR_FORMAT ") should be less or equal to "
   285   assert(start != NULL && end != NULL && start <= end, "Start (" PTR_FORMAT ") should be less or equal to "
   286          "end (" PTR_FORMAT ")", p2i(start), p2i(end));
   286          "end (" PTR_FORMAT ")", p2i(start), p2i(end));
   287   _root_regions[idx].set_start(start);
   287   _root_regions[idx].set_start(start);
   288   _root_regions[idx].set_end(end);
   288   _root_regions[idx].set_end(end);
   306 
   306 
   307   if (_claimed_root_regions >= _num_root_regions) {
   307   if (_claimed_root_regions >= _num_root_regions) {
   308     return NULL;
   308     return NULL;
   309   }
   309   }
   310 
   310 
   311   size_t claimed_index = Atomic::add((size_t)1, &_claimed_root_regions) - 1;
   311   size_t claimed_index = Atomic::add(&_claimed_root_regions, (size_t)1) - 1;
   312   if (claimed_index < _num_root_regions) {
   312   if (claimed_index < _num_root_regions) {
   313     return &_root_regions[claimed_index];
   313     return &_root_regions[claimed_index];
   314   }
   314   }
   315   return NULL;
   315   return NULL;
   316 }
   316 }
  1119     _g1h(g1h), _cm(cm), _hrclaimer(num_workers), _total_selected_for_rebuild(0), _cl("Post-Marking") { }
  1119     _g1h(g1h), _cm(cm), _hrclaimer(num_workers), _total_selected_for_rebuild(0), _cl("Post-Marking") { }
  1120 
  1120 
  1121   virtual void work(uint worker_id) {
  1121   virtual void work(uint worker_id) {
  1122     G1UpdateRemSetTrackingBeforeRebuild update_cl(_g1h, _cm, &_cl);
  1122     G1UpdateRemSetTrackingBeforeRebuild update_cl(_g1h, _cm, &_cl);
  1123     _g1h->heap_region_par_iterate_from_worker_offset(&update_cl, &_hrclaimer, worker_id);
  1123     _g1h->heap_region_par_iterate_from_worker_offset(&update_cl, &_hrclaimer, worker_id);
  1124     Atomic::add(update_cl.num_selected_for_rebuild(), &_total_selected_for_rebuild);
  1124     Atomic::add(&_total_selected_for_rebuild, update_cl.num_selected_for_rebuild());
  1125   }
  1125   }
  1126 
  1126 
  1127   uint total_selected_for_rebuild() const { return _total_selected_for_rebuild; }
  1127   uint total_selected_for_rebuild() const { return _total_selected_for_rebuild; }
  1128 
  1128 
  1129   // Number of regions for which roughly one thread should be spawned for this work.
  1129   // Number of regions for which roughly one thread should be spawned for this work.