src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp

changeset 1112
96b229c54d1e
parent 1082
bd441136a5ce
child 1113
4ac7d97e6101
     1.1 --- a/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp	Wed Mar 25 10:36:08 2009 -0400
     1.2 +++ b/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp	Wed Mar 25 13:10:54 2009 -0700
     1.3 @@ -42,21 +42,6 @@
     1.4  
     1.5  // Local to this file.
     1.6  
     1.7 -// Finds the first HeapRegion.
     1.8 -// No longer used, but might be handy someday.
     1.9 -
    1.10 -class FindFirstRegionClosure: public HeapRegionClosure {
    1.11 -  HeapRegion* _a_region;
    1.12 -public:
    1.13 -  FindFirstRegionClosure() : _a_region(NULL) {}
    1.14 -  bool doHeapRegion(HeapRegion* r) {
    1.15 -    _a_region = r;
    1.16 -    return true;
    1.17 -  }
    1.18 -  HeapRegion* result() { return _a_region; }
    1.19 -};
    1.20 -
    1.21 -
    1.22  class RefineCardTableEntryClosure: public CardTableEntryClosure {
    1.23    SuspendibleThreadSet* _sts;
    1.24    G1RemSet* _g1rs;
    1.25 @@ -1207,13 +1192,12 @@
    1.26                                                     bool par) {
    1.27    assert(!hr->continuesHumongous(), "should have filtered these out");
    1.28    size_t res = 0;
    1.29 -  if (!hr->popular() && hr->used() > 0 && hr->garbage_bytes() == hr->used()) {
    1.30 -    if (!hr->is_young()) {
    1.31 -      if (G1PolicyVerbose > 0)
    1.32 -        gclog_or_tty->print_cr("Freeing empty region "PTR_FORMAT "(" SIZE_FORMAT " bytes)"
    1.33 -                               " during cleanup", hr, hr->used());
    1.34 -      free_region_work(hr, pre_used, cleared_h, freed_regions, list, par);
    1.35 -    }
    1.36 +  if (hr->used() > 0 && hr->garbage_bytes() == hr->used() &&
    1.37 +      !hr->is_young()) {
    1.38 +    if (G1PolicyVerbose > 0)
    1.39 +      gclog_or_tty->print_cr("Freeing empty region "PTR_FORMAT "(" SIZE_FORMAT " bytes)"
    1.40 +                                                                               " during cleanup", hr, hr->used());
    1.41 +    free_region_work(hr, pre_used, cleared_h, freed_regions, list, par);
    1.42    }
    1.43  }
    1.44  
    1.45 @@ -1342,10 +1326,6 @@
    1.46    _refine_cte_cl(NULL),
    1.47    _free_region_list(NULL), _free_region_list_size(0),
    1.48    _free_regions(0),
    1.49 -  _popular_object_boundary(NULL),
    1.50 -  _cur_pop_hr_index(0),
    1.51 -  _popular_regions_to_be_evacuated(NULL),
    1.52 -  _pop_obj_rc_at_copy(),
    1.53    _full_collection(false),
    1.54    _unclean_region_list(),
    1.55    _unclean_regions_coming(false),
    1.56 @@ -1520,26 +1500,11 @@
    1.57      _czft = new ConcurrentZFThread();
    1.58    }
    1.59  
    1.60 -
    1.61 -
    1.62 -  // Allocate the popular regions; take them off free lists.
    1.63 -  size_t pop_byte_size = G1NumPopularRegions * HeapRegion::GrainBytes;
    1.64 -  expand(pop_byte_size);
    1.65 -  _popular_object_boundary =
    1.66 -    _g1_reserved.start() + (G1NumPopularRegions * HeapRegion::GrainWords);
    1.67 -  for (int i = 0; i < G1NumPopularRegions; i++) {
    1.68 -    HeapRegion* hr = newAllocRegion(HeapRegion::GrainWords);
    1.69 -    //    assert(hr != NULL && hr->bottom() < _popular_object_boundary,
    1.70 -    //     "Should be enough, and all should be below boundary.");
    1.71 -    hr->set_popular(true);
    1.72 -  }
    1.73 -  assert(_cur_pop_hr_index == 0, "Start allocating at the first region.");
    1.74 -
    1.75    // Initialize the from_card cache structure of HeapRegionRemSet.
    1.76    HeapRegionRemSet::init_heap(max_regions());
    1.77  
    1.78 -  // Now expand into the rest of the initial heap size.
    1.79 -  expand(init_byte_size - pop_byte_size);
    1.80 +  // Now expand into the initial heap size.
    1.81 +  expand(init_byte_size);
    1.82  
    1.83    // Perform any initialization actions delegated to the policy.
    1.84    g1_policy()->init();
    1.85 @@ -1654,8 +1619,7 @@
    1.86  class SumUsedRegionsClosure: public HeapRegionClosure {
    1.87    size_t _num;
    1.88  public:
    1.89 -  // _num is set to 1 to account for the popular region
    1.90 -  SumUsedRegionsClosure() : _num(G1NumPopularRegions) {}
    1.91 +  SumUsedRegionsClosure() : _num(0) {}
    1.92    bool doHeapRegion(HeapRegion* r) {
    1.93      if (r->continuesHumongous() || r->used() > 0 || r->is_gc_alloc_region()) {
    1.94        _num += 1;
    1.95 @@ -2318,9 +2282,6 @@
    1.96    if (SummarizeG1ZFStats) {
    1.97      ConcurrentZFThread::print_summary_info();
    1.98    }
    1.99 -  if (G1SummarizePopularity) {
   1.100 -    print_popularity_summary_info();
   1.101 -  }
   1.102    g1_policy()->print_yg_surv_rate_info();
   1.103  
   1.104    GCOverheadReporter::printGCOverhead();
   1.105 @@ -2495,30 +2456,19 @@
   1.106  // </NEW PREDICTION>
   1.107  
   1.108  void
   1.109 -G1CollectedHeap::do_collection_pause_at_safepoint(HeapRegion* popular_region) {
   1.110 +G1CollectedHeap::do_collection_pause_at_safepoint() {
   1.111    char verbose_str[128];
   1.112    sprintf(verbose_str, "GC pause ");
   1.113 -  if (popular_region != NULL)
   1.114 -    strcat(verbose_str, "(popular)");
   1.115 -  else if (g1_policy()->in_young_gc_mode()) {
   1.116 +  if (g1_policy()->in_young_gc_mode()) {
   1.117      if (g1_policy()->full_young_gcs())
   1.118        strcat(verbose_str, "(young)");
   1.119      else
   1.120        strcat(verbose_str, "(partial)");
   1.121    }
   1.122 -  bool reset_should_initiate_conc_mark = false;
   1.123 -  if (popular_region != NULL && g1_policy()->should_initiate_conc_mark()) {
   1.124 -    // we currently do not allow an initial mark phase to be piggy-backed
   1.125 -    // on a popular pause
   1.126 -    reset_should_initiate_conc_mark = true;
   1.127 -    g1_policy()->unset_should_initiate_conc_mark();
   1.128 -  }
   1.129    if (g1_policy()->should_initiate_conc_mark())
   1.130      strcat(verbose_str, " (initial-mark)");
   1.131  
   1.132 -  GCCauseSetter x(this, (popular_region == NULL ?
   1.133 -                         GCCause::_g1_inc_collection_pause :
   1.134 -                         GCCause::_g1_pop_region_collection_pause));
   1.135 +  GCCauseSetter x(this, GCCause::_g1_inc_collection_pause);
   1.136  
   1.137    // if PrintGCDetails is on, we'll print long statistics information
   1.138    // in the collector policy code, so let's not print this as the output
   1.139 @@ -2609,7 +2559,7 @@
   1.140      save_marks();
   1.141  
   1.142      // We must do this before any possible evacuation that should propagate
   1.143 -    // marks, including evacuation of popular objects in a popular pause.
   1.144 +    // marks.
   1.145      if (mark_in_progress()) {
   1.146        double start_time_sec = os::elapsedTime();
   1.147  
   1.148 @@ -2626,29 +2576,15 @@
   1.149  
   1.150      assert(regions_accounted_for(), "Region leakage.");
   1.151  
   1.152 -    bool abandoned = false;
   1.153 -
   1.154      if (mark_in_progress())
   1.155        concurrent_mark()->newCSet();
   1.156  
   1.157      // Now choose the CS.
   1.158 -    if (popular_region == NULL) {
   1.159 -      g1_policy()->choose_collection_set();
   1.160 -    } else {
   1.161 -      // We may be evacuating a single region (for popularity).
   1.162 -      g1_policy()->record_popular_pause_preamble_start();
   1.163 -      popularity_pause_preamble(popular_region);
   1.164 -      g1_policy()->record_popular_pause_preamble_end();
   1.165 -      abandoned = (g1_policy()->collection_set() == NULL);
   1.166 -      // Now we allow more regions to be added (we have to collect
   1.167 -      // all popular regions).
   1.168 -      if (!abandoned) {
   1.169 -        g1_policy()->choose_collection_set(popular_region);
   1.170 -      }
   1.171 -    }
   1.172 +    g1_policy()->choose_collection_set();
   1.173 +
   1.174      // We may abandon a pause if we find no region that will fit in the MMU
   1.175      // pause.
   1.176 -    abandoned = (g1_policy()->collection_set() == NULL);
   1.177 +    bool abandoned = (g1_policy()->collection_set() == NULL);
   1.178  
   1.179      // Nothing to do if we were unable to choose a collection set.
   1.180      if (!abandoned) {
   1.181 @@ -2673,12 +2609,6 @@
   1.182        _in_cset_fast_test = NULL;
   1.183        _in_cset_fast_test_base = NULL;
   1.184  
   1.185 -      if (popular_region != NULL) {
   1.186 -        // We have to wait until now, because we don't want the region to
   1.187 -        // be rescheduled for pop-evac during RS update.
   1.188 -        popular_region->set_popular_pending(false);
   1.189 -      }
   1.190 -
   1.191        release_gc_alloc_regions(false /* totally */);
   1.192  
   1.193        cleanup_surviving_young_words();
   1.194 @@ -2724,8 +2654,7 @@
   1.195      double pause_time_ms = (end_time_sec - start_time_sec) * MILLIUNITS;
   1.196      g1_policy()->record_pause_time_ms(pause_time_ms);
   1.197      GCOverheadReporter::recordSTWEnd(end_time_sec);
   1.198 -    g1_policy()->record_collection_pause_end(popular_region != NULL,
   1.199 -                                             abandoned);
   1.200 +    g1_policy()->record_collection_pause_end(abandoned);
   1.201  
   1.202      assert(regions_accounted_for(), "Region leakage.");
   1.203  
   1.204 @@ -2759,9 +2688,6 @@
   1.205  
   1.206    assert(verify_region_lists(), "Bad region lists.");
   1.207  
   1.208 -  if (reset_should_initiate_conc_mark)
   1.209 -    g1_policy()->set_should_initiate_conc_mark();
   1.210 -
   1.211    if (ExitAfterGCNum > 0 && total_collections() == ExitAfterGCNum) {
   1.212      gclog_or_tty->print_cr("Stopping after GC #%d", ExitAfterGCNum);
   1.213      print_tracing_info();
   1.214 @@ -4707,7 +4633,6 @@
   1.215                                    size_t& freed_regions,
   1.216                                    UncleanRegionList* list,
   1.217                                    bool par) {
   1.218 -  assert(!hr->popular(), "should not free popular regions");
   1.219    pre_used += hr->used();
   1.220    if (hr->isHumongous()) {
   1.221      assert(hr->startsHumongous(),
   1.222 @@ -4791,12 +4716,6 @@
   1.223  
   1.224  
   1.225  void G1CollectedHeap::do_collection_pause_if_appropriate(size_t word_size) {
   1.226 -  // First do any popular regions.
   1.227 -  HeapRegion* hr;
   1.228 -  while ((hr = popular_region_to_evac()) != NULL) {
   1.229 -    evac_popular_region(hr);
   1.230 -  }
   1.231 -  // Now do heuristic pauses.
   1.232    if (g1_policy()->should_do_collection_pause(word_size)) {
   1.233      do_collection_pause();
   1.234    }
   1.235 @@ -5192,7 +5111,7 @@
   1.236  public:
   1.237    RegionCounter() : _n(0) {}
   1.238    bool doHeapRegion(HeapRegion* r) {
   1.239 -    if (r->is_empty() && !r->popular()) {
   1.240 +    if (r->is_empty()) {
   1.241        assert(!r->isHumongous(), "H regions should not be empty.");
   1.242        _n++;
   1.243      }
   1.244 @@ -5336,14 +5255,8 @@
   1.245        r->set_zero_fill_allocated();
   1.246      } else {
   1.247        assert(r->is_empty(), "tautology");
   1.248 -      if (r->popular()) {
   1.249 -        if (r->zero_fill_state() != HeapRegion::Allocated) {
   1.250 -          r->ensure_zero_filled_locked();
   1.251 -          r->set_zero_fill_allocated();
   1.252 -        }
   1.253 -      } else {
   1.254 -        _n++;
   1.255 -        switch (r->zero_fill_state()) {
   1.256 +      _n++;
   1.257 +      switch (r->zero_fill_state()) {
   1.258          case HeapRegion::NotZeroFilled:
   1.259          case HeapRegion::ZeroFilling:
   1.260            _g1->put_region_on_unclean_list_locked(r);
   1.261 @@ -5354,7 +5267,6 @@
   1.262          case HeapRegion::ZeroFilled:
   1.263            _g1->put_free_region_on_list_locked(r);
   1.264            break;
   1.265 -        }
   1.266        }
   1.267      }
   1.268      return false;
   1.269 @@ -5402,376 +5314,6 @@
   1.270    heap_region_iterate(&rs);
   1.271  }
   1.272  
   1.273 -class CountObjClosure: public ObjectClosure {
   1.274 -  size_t _n;
   1.275 -public:
   1.276 -  CountObjClosure() : _n(0) {}
   1.277 -  void do_object(oop obj) { _n++; }
   1.278 -  size_t n() { return _n; }
   1.279 -};
   1.280 -
   1.281 -size_t G1CollectedHeap::pop_object_used_objs() {
   1.282 -  size_t sum_objs = 0;
   1.283 -  for (int i = 0; i < G1NumPopularRegions; i++) {
   1.284 -    CountObjClosure cl;
   1.285 -    _hrs->at(i)->object_iterate(&cl);
   1.286 -    sum_objs += cl.n();
   1.287 -  }
   1.288 -  return sum_objs;
   1.289 -}
   1.290 -
   1.291 -size_t G1CollectedHeap::pop_object_used_bytes() {
   1.292 -  size_t sum_bytes = 0;
   1.293 -  for (int i = 0; i < G1NumPopularRegions; i++) {
   1.294 -    sum_bytes += _hrs->at(i)->used();
   1.295 -  }
   1.296 -  return sum_bytes;
   1.297 -}
   1.298 -
   1.299 -
   1.300 -static int nq = 0;
   1.301 -
   1.302 -HeapWord* G1CollectedHeap::allocate_popular_object(size_t word_size) {
   1.303 -  while (_cur_pop_hr_index < G1NumPopularRegions) {
   1.304 -    HeapRegion* cur_pop_region = _hrs->at(_cur_pop_hr_index);
   1.305 -    HeapWord* res = cur_pop_region->allocate(word_size);
   1.306 -    if (res != NULL) {
   1.307 -      // We account for popular objs directly in the used summary:
   1.308 -      _summary_bytes_used += (word_size * HeapWordSize);
   1.309 -      return res;
   1.310 -    }
   1.311 -    // Otherwise, try the next region (first making sure that we remember
   1.312 -    // the last "top" value as the "next_top_at_mark_start", so that
   1.313 -    // objects made popular during markings aren't automatically considered
   1.314 -    // live).
   1.315 -    cur_pop_region->note_end_of_copying();
   1.316 -    // Otherwise, try the next region.
   1.317 -    _cur_pop_hr_index++;
   1.318 -  }
   1.319 -  // XXX: For now !!!
   1.320 -  vm_exit_out_of_memory(word_size,
   1.321 -                        "Not enough pop obj space (To Be Fixed)");
   1.322 -  return NULL;
   1.323 -}
   1.324 -
   1.325 -class HeapRegionList: public CHeapObj {
   1.326 -  public:
   1.327 -  HeapRegion* hr;
   1.328 -  HeapRegionList* next;
   1.329 -};
   1.330 -
   1.331 -void G1CollectedHeap::schedule_popular_region_evac(HeapRegion* r) {
   1.332 -  // This might happen during parallel GC, so protect by this lock.
   1.333 -  MutexLockerEx x(ParGCRareEvent_lock, Mutex::_no_safepoint_check_flag);
   1.334 -  // We don't schedule regions whose evacuations are already pending, or
   1.335 -  // are already being evacuated.
   1.336 -  if (!r->popular_pending() && !r->in_collection_set()) {
   1.337 -    r->set_popular_pending(true);
   1.338 -    if (G1TracePopularity) {
   1.339 -      gclog_or_tty->print_cr("Scheduling region "PTR_FORMAT" "
   1.340 -                             "["PTR_FORMAT", "PTR_FORMAT") for pop-object evacuation.",
   1.341 -                             r, r->bottom(), r->end());
   1.342 -    }
   1.343 -    HeapRegionList* hrl = new HeapRegionList;
   1.344 -    hrl->hr = r;
   1.345 -    hrl->next = _popular_regions_to_be_evacuated;
   1.346 -    _popular_regions_to_be_evacuated = hrl;
   1.347 -  }
   1.348 -}
   1.349 -
   1.350 -HeapRegion* G1CollectedHeap::popular_region_to_evac() {
   1.351 -  MutexLockerEx x(ParGCRareEvent_lock, Mutex::_no_safepoint_check_flag);
   1.352 -  HeapRegion* res = NULL;
   1.353 -  while (_popular_regions_to_be_evacuated != NULL && res == NULL) {
   1.354 -    HeapRegionList* hrl = _popular_regions_to_be_evacuated;
   1.355 -    _popular_regions_to_be_evacuated = hrl->next;
   1.356 -    res = hrl->hr;
   1.357 -    // The G1RSPopLimit may have increased, so recheck here...
   1.358 -    if (res->rem_set()->occupied() < (size_t) G1RSPopLimit) {
   1.359 -      // Hah: don't need to schedule.
   1.360 -      if (G1TracePopularity) {
   1.361 -        gclog_or_tty->print_cr("Unscheduling region "PTR_FORMAT" "
   1.362 -                               "["PTR_FORMAT", "PTR_FORMAT") "
   1.363 -                               "for pop-object evacuation (size %d < limit %d)",
   1.364 -                               res, res->bottom(), res->end(),
   1.365 -                               res->rem_set()->occupied(), G1RSPopLimit);
   1.366 -      }
   1.367 -      res->set_popular_pending(false);
   1.368 -      res = NULL;
   1.369 -    }
   1.370 -    // We do not reset res->popular() here; if we did so, it would allow
   1.371 -    // the region to be "rescheduled" for popularity evacuation.  Instead,
   1.372 -    // this is done in the collection pause, with the world stopped.
   1.373 -    // So the invariant is that the regions in the list have the popularity
   1.374 -    // boolean set, but having the boolean set does not imply membership
   1.375 -    // on the list (though there can at most one such pop-pending region
   1.376 -    // not on the list at any time).
   1.377 -    delete hrl;
   1.378 -  }
   1.379 -  return res;
   1.380 -}
   1.381 -
   1.382 -void G1CollectedHeap::evac_popular_region(HeapRegion* hr) {
   1.383 -  while (true) {
   1.384 -    // Don't want to do a GC pause while cleanup is being completed!
   1.385 -    wait_for_cleanup_complete();
   1.386 -
   1.387 -    // Read the GC count while holding the Heap_lock
   1.388 -    int gc_count_before = SharedHeap::heap()->total_collections();
   1.389 -    g1_policy()->record_stop_world_start();
   1.390 -
   1.391 -    {
   1.392 -      MutexUnlocker mu(Heap_lock);  // give up heap lock, execute gets it back
   1.393 -      VM_G1PopRegionCollectionPause op(gc_count_before, hr);
   1.394 -      VMThread::execute(&op);
   1.395 -
   1.396 -      // If the prolog succeeded, we didn't do a GC for this.
   1.397 -      if (op.prologue_succeeded()) break;
   1.398 -    }
   1.399 -    // Otherwise we didn't.  We should recheck the size, though, since
   1.400 -    // the limit may have increased...
   1.401 -    if (hr->rem_set()->occupied() < (size_t) G1RSPopLimit) {
   1.402 -      hr->set_popular_pending(false);
   1.403 -      break;
   1.404 -    }
   1.405 -  }
   1.406 -}
   1.407 -
   1.408 -void G1CollectedHeap::atomic_inc_obj_rc(oop obj) {
   1.409 -  Atomic::inc(obj_rc_addr(obj));
   1.410 -}
   1.411 -
   1.412 -class CountRCClosure: public OopsInHeapRegionClosure {
   1.413 -  G1CollectedHeap* _g1h;
   1.414 -  bool _parallel;
   1.415 -public:
   1.416 -  CountRCClosure(G1CollectedHeap* g1h) :
   1.417 -    _g1h(g1h), _parallel(ParallelGCThreads > 0)
   1.418 -  {}
   1.419 -  void do_oop(narrowOop* p) {
   1.420 -    guarantee(false, "NYI");
   1.421 -  }
   1.422 -  void do_oop(oop* p) {
   1.423 -    oop obj = *p;
   1.424 -    assert(obj != NULL, "Precondition.");
   1.425 -    if (_parallel) {
   1.426 -      // We go sticky at the limit to avoid excess contention.
   1.427 -      // If we want to track the actual RC's further, we'll need to keep a
   1.428 -      // per-thread hash table or something for the popular objects.
   1.429 -      if (_g1h->obj_rc(obj) < G1ObjPopLimit) {
   1.430 -        _g1h->atomic_inc_obj_rc(obj);
   1.431 -      }
   1.432 -    } else {
   1.433 -      _g1h->inc_obj_rc(obj);
   1.434 -    }
   1.435 -  }
   1.436 -};
   1.437 -
   1.438 -class EvacPopObjClosure: public ObjectClosure {
   1.439 -  G1CollectedHeap* _g1h;
   1.440 -  size_t _pop_objs;
   1.441 -  size_t _max_rc;
   1.442 -public:
   1.443 -  EvacPopObjClosure(G1CollectedHeap* g1h) :
   1.444 -    _g1h(g1h), _pop_objs(0), _max_rc(0) {}
   1.445 -
   1.446 -  void do_object(oop obj) {
   1.447 -    size_t rc = _g1h->obj_rc(obj);
   1.448 -    _max_rc = MAX2(rc, _max_rc);
   1.449 -    if (rc >= (size_t) G1ObjPopLimit) {
   1.450 -      _g1h->_pop_obj_rc_at_copy.add((double)rc);
   1.451 -      size_t word_sz = obj->size();
   1.452 -      HeapWord* new_pop_loc = _g1h->allocate_popular_object(word_sz);
   1.453 -      oop new_pop_obj = (oop)new_pop_loc;
   1.454 -      Copy::aligned_disjoint_words((HeapWord*)obj, new_pop_loc, word_sz);
   1.455 -      obj->forward_to(new_pop_obj);
   1.456 -      G1ScanAndBalanceClosure scan_and_balance(_g1h);
   1.457 -      new_pop_obj->oop_iterate_backwards(&scan_and_balance);
   1.458 -      // preserve "next" mark bit if marking is in progress.
   1.459 -      if (_g1h->mark_in_progress() && !_g1h->is_obj_ill(obj)) {
   1.460 -        _g1h->concurrent_mark()->markAndGrayObjectIfNecessary(new_pop_obj);
   1.461 -      }
   1.462 -
   1.463 -      if (G1TracePopularity) {
   1.464 -        gclog_or_tty->print_cr("Found obj " PTR_FORMAT " of word size " SIZE_FORMAT
   1.465 -                               " pop (%d), move to " PTR_FORMAT,
   1.466 -                               (void*) obj, word_sz,
   1.467 -                               _g1h->obj_rc(obj), (void*) new_pop_obj);
   1.468 -      }
   1.469 -      _pop_objs++;
   1.470 -    }
   1.471 -  }
   1.472 -  size_t pop_objs() { return _pop_objs; }
   1.473 -  size_t max_rc() { return _max_rc; }
   1.474 -};
   1.475 -
   1.476 -class G1ParCountRCTask : public AbstractGangTask {
   1.477 -  G1CollectedHeap* _g1h;
   1.478 -  BitMap _bm;
   1.479 -
   1.480 -  size_t getNCards() {
   1.481 -    return (_g1h->capacity() + G1BlockOffsetSharedArray::N_bytes - 1)
   1.482 -      / G1BlockOffsetSharedArray::N_bytes;
   1.483 -  }
   1.484 -  CountRCClosure _count_rc_closure;
   1.485 -public:
   1.486 -  G1ParCountRCTask(G1CollectedHeap* g1h) :
   1.487 -    AbstractGangTask("G1 Par RC Count task"),
   1.488 -    _g1h(g1h), _bm(getNCards()), _count_rc_closure(g1h)
   1.489 -  {}
   1.490 -
   1.491 -  void work(int i) {
   1.492 -    ResourceMark rm;
   1.493 -    HandleMark   hm;
   1.494 -    _g1h->g1_rem_set()->oops_into_collection_set_do(&_count_rc_closure, i);
   1.495 -  }
   1.496 -};
   1.497 -
   1.498 -void G1CollectedHeap::popularity_pause_preamble(HeapRegion* popular_region) {
   1.499 -  // We're evacuating a single region (for popularity).
   1.500 -  if (G1TracePopularity) {
   1.501 -    gclog_or_tty->print_cr("Doing pop region pause for ["PTR_FORMAT", "PTR_FORMAT")",
   1.502 -                           popular_region->bottom(), popular_region->end());
   1.503 -  }
   1.504 -  g1_policy()->set_single_region_collection_set(popular_region);
   1.505 -  size_t max_rc;
   1.506 -  if (!compute_reference_counts_and_evac_popular(popular_region,
   1.507 -                                                 &max_rc)) {
   1.508 -    // We didn't evacuate any popular objects.
   1.509 -    // We increase the RS popularity limit, to prevent this from
   1.510 -    // happening in the future.
   1.511 -    if (G1RSPopLimit < (1 << 30)) {
   1.512 -      G1RSPopLimit *= 2;
   1.513 -    }
   1.514 -    // For now, interesting enough for a message:
   1.515 -#if 1
   1.516 -    gclog_or_tty->print_cr("In pop region pause for ["PTR_FORMAT", "PTR_FORMAT"), "
   1.517 -                           "failed to find a pop object (max = %d).",
   1.518 -                           popular_region->bottom(), popular_region->end(),
   1.519 -                           max_rc);
   1.520 -    gclog_or_tty->print_cr("Increased G1RSPopLimit to %d.", G1RSPopLimit);
   1.521 -#endif // 0
   1.522 -    // Also, we reset the collection set to NULL, to make the rest of
   1.523 -    // the collection do nothing.
   1.524 -    assert(popular_region->next_in_collection_set() == NULL,
   1.525 -           "should be single-region.");
   1.526 -    popular_region->set_in_collection_set(false);
   1.527 -    popular_region->set_popular_pending(false);
   1.528 -    g1_policy()->clear_collection_set();
   1.529 -  }
   1.530 -}
   1.531 -
   1.532 -bool G1CollectedHeap::
   1.533 -compute_reference_counts_and_evac_popular(HeapRegion* popular_region,
   1.534 -                                          size_t* max_rc) {
   1.535 -  HeapWord* rc_region_bot;
   1.536 -  HeapWord* rc_region_end;
   1.537 -
   1.538 -  // Set up the reference count region.
   1.539 -  HeapRegion* rc_region = newAllocRegion(HeapRegion::GrainWords);
   1.540 -  if (rc_region != NULL) {
   1.541 -    rc_region_bot = rc_region->bottom();
   1.542 -    rc_region_end = rc_region->end();
   1.543 -  } else {
   1.544 -    rc_region_bot = NEW_C_HEAP_ARRAY(HeapWord, HeapRegion::GrainWords);
   1.545 -    if (rc_region_bot == NULL) {
   1.546 -      vm_exit_out_of_memory(HeapRegion::GrainWords,
   1.547 -                            "No space for RC region.");
   1.548 -    }
   1.549 -    rc_region_end = rc_region_bot + HeapRegion::GrainWords;
   1.550 -  }
   1.551 -
   1.552 -  if (G1TracePopularity)
   1.553 -    gclog_or_tty->print_cr("RC region is ["PTR_FORMAT", "PTR_FORMAT")",
   1.554 -                           rc_region_bot, rc_region_end);
   1.555 -  if (rc_region_bot > popular_region->bottom()) {
   1.556 -    _rc_region_above = true;
   1.557 -    _rc_region_diff =
   1.558 -      pointer_delta(rc_region_bot, popular_region->bottom(), 1);
   1.559 -  } else {
   1.560 -    assert(rc_region_bot < popular_region->bottom(), "Can't be equal.");
   1.561 -    _rc_region_above = false;
   1.562 -    _rc_region_diff =
   1.563 -      pointer_delta(popular_region->bottom(), rc_region_bot, 1);
   1.564 -  }
   1.565 -  g1_policy()->record_pop_compute_rc_start();
   1.566 -  // Count external references.
   1.567 -  g1_rem_set()->prepare_for_oops_into_collection_set_do();
   1.568 -  if (ParallelGCThreads > 0) {
   1.569 -
   1.570 -    set_par_threads(workers()->total_workers());
   1.571 -    G1ParCountRCTask par_count_rc_task(this);
   1.572 -    workers()->run_task(&par_count_rc_task);
   1.573 -    set_par_threads(0);
   1.574 -
   1.575 -  } else {
   1.576 -    CountRCClosure count_rc_closure(this);
   1.577 -    g1_rem_set()->oops_into_collection_set_do(&count_rc_closure, 0);
   1.578 -  }
   1.579 -  g1_rem_set()->cleanup_after_oops_into_collection_set_do();
   1.580 -  g1_policy()->record_pop_compute_rc_end();
   1.581 -
   1.582 -  // Now evacuate popular objects.
   1.583 -  g1_policy()->record_pop_evac_start();
   1.584 -  EvacPopObjClosure evac_pop_obj_cl(this);
   1.585 -  popular_region->object_iterate(&evac_pop_obj_cl);
   1.586 -  *max_rc = evac_pop_obj_cl.max_rc();
   1.587 -
   1.588 -  // Make sure the last "top" value of the current popular region is copied
   1.589 -  // as the "next_top_at_mark_start", so that objects made popular during
   1.590 -  // markings aren't automatically considered live.
   1.591 -  HeapRegion* cur_pop_region = _hrs->at(_cur_pop_hr_index);
   1.592 -  cur_pop_region->note_end_of_copying();
   1.593 -
   1.594 -  if (rc_region != NULL) {
   1.595 -    free_region(rc_region);
   1.596 -  } else {
   1.597 -    FREE_C_HEAP_ARRAY(HeapWord, rc_region_bot);
   1.598 -  }
   1.599 -  g1_policy()->record_pop_evac_end();
   1.600 -
   1.601 -  return evac_pop_obj_cl.pop_objs() > 0;
   1.602 -}
   1.603 -
   1.604 -class CountPopObjInfoClosure: public HeapRegionClosure {
   1.605 -  size_t _objs;
   1.606 -  size_t _bytes;
   1.607 -
   1.608 -  class CountObjClosure: public ObjectClosure {
   1.609 -    int _n;
   1.610 -  public:
   1.611 -    CountObjClosure() : _n(0) {}
   1.612 -    void do_object(oop obj) { _n++; }
   1.613 -    size_t n() { return _n; }
   1.614 -  };
   1.615 -
   1.616 -public:
   1.617 -  CountPopObjInfoClosure() : _objs(0), _bytes(0) {}
   1.618 -  bool doHeapRegion(HeapRegion* r) {
   1.619 -    _bytes += r->used();
   1.620 -    CountObjClosure blk;
   1.621 -    r->object_iterate(&blk);
   1.622 -    _objs += blk.n();
   1.623 -    return false;
   1.624 -  }
   1.625 -  size_t objs() { return _objs; }
   1.626 -  size_t bytes() { return _bytes; }
   1.627 -};
   1.628 -
   1.629 -
   1.630 -void G1CollectedHeap::print_popularity_summary_info() const {
   1.631 -  CountPopObjInfoClosure blk;
   1.632 -  for (int i = 0; i <= _cur_pop_hr_index; i++) {
   1.633 -    blk.doHeapRegion(_hrs->at(i));
   1.634 -  }
   1.635 -  gclog_or_tty->print_cr("\nPopular objects: %d objs, %d bytes.",
   1.636 -                         blk.objs(), blk.bytes());
   1.637 -  gclog_or_tty->print_cr("   RC at copy = [avg = %5.2f, max = %5.2f, sd = %5.2f].",
   1.638 -                _pop_obj_rc_at_copy.avg(),
   1.639 -                _pop_obj_rc_at_copy.maximum(),
   1.640 -                _pop_obj_rc_at_copy.sd());
   1.641 -}
   1.642 -
   1.643  void G1CollectedHeap::set_refine_cte_cl_concurrency(bool concurrent) {
   1.644    _refine_cte_cl->set_concurrent(concurrent);
   1.645  }
   1.646 @@ -5845,7 +5387,6 @@
   1.647  }
   1.648  
   1.649  bool G1CollectedHeap::print_region_accounting_info() {
   1.650 -  gclog_or_tty->print_cr("P regions: %d.", G1NumPopularRegions);
   1.651    gclog_or_tty->print_cr("Free regions: %d (count: %d count list %d) (clean: %d unclean: %d).",
   1.652                           free_regions(),
   1.653                           count_free_regions(), count_free_regions_list(),

mercurial