< prev index next >

src/hotspot/share/gc/shenandoah/shenandoahCollectionSet.cpp

Print this page
*** 38,13 ***
--- 38,15 ---
    _region_size_bytes_shift(ShenandoahHeapRegion::region_size_bytes_shift()),
    _map_space(space),
    _cset_map(_map_space.base() + ((uintx)heap_base >> _region_size_bytes_shift)),
    _biased_cset_map(_map_space.base()),
    _heap(heap),
+   _has_old_regions(false),
    _garbage(0),
    _used(0),
    _region_count(0),
+   _old_garbage(0),
    _current_index(0) {
  
    // The collection set map is reserved to cover the entire heap *and* zero addresses.
    // This is needed to accept in-cset checks for both heap oops and NULLs, freeing
    // high-performance code from checking for NULL first.

*** 81,15 ***
  
  void ShenandoahCollectionSet::add_region(ShenandoahHeapRegion* r) {
    assert(ShenandoahSafepoint::is_at_shenandoah_safepoint(), "Must be at a safepoint");
    assert(Thread::current()->is_VM_thread(), "Must be VMThread");
    assert(!is_in(r), "Already in collection set");
    _cset_map[r->index()] = 1;
    _region_count++;
    _garbage += r->garbage();
    _used += r->used();
- 
    // Update the region status too. State transition would be checked internally.
    r->make_cset();
  }
  
  void ShenandoahCollectionSet::clear() {
--- 83,30 ---
  
  void ShenandoahCollectionSet::add_region(ShenandoahHeapRegion* r) {
    assert(ShenandoahSafepoint::is_at_shenandoah_safepoint(), "Must be at a safepoint");
    assert(Thread::current()->is_VM_thread(), "Must be VMThread");
    assert(!is_in(r), "Already in collection set");
+   assert(!r->is_humongous(), "Only add regular regions to the collection set");
+ 
    _cset_map[r->index()] = 1;
+ 
+   if (r->affiliation() == YOUNG_GENERATION) {
+     _young_region_count++;
+     _young_bytes_to_evacuate += r->get_live_data_bytes();
+     if (r->age() >= InitialTenuringThreshold) {
+       _young_bytes_to_promote += r->get_live_data_bytes();
+     }
+   } else if (r->affiliation() == OLD_GENERATION) {
+     _old_region_count++;
+     _old_bytes_to_evacuate += r->get_live_data_bytes();
+     _old_garbage += r->garbage();
+   }
+ 
    _region_count++;
+   _has_old_regions |= r->is_old();
    _garbage += r->garbage();
    _used += r->used();
    // Update the region status too. State transition would be checked internally.
    r->make_cset();
  }
  
  void ShenandoahCollectionSet::clear() {

*** 101,14 ***
--- 118,24 ---
      assert (!_heap->get_region(index)->is_cset(), "should have been cleared before");
    }
  #endif
  
    _garbage = 0;
+   _old_garbage = 0;
    _used = 0;
  
    _region_count = 0;
    _current_index = 0;
+ 
+   _young_region_count = 0;
+   _young_bytes_to_evacuate = 0;
+   _young_bytes_to_promote = 0;
+ 
+   _old_region_count = 0;
+   _old_bytes_to_evacuate = 0;
+ 
+   _has_old_regions = false;
  }
  
  ShenandoahHeapRegion* ShenandoahCollectionSet::claim_next() {
    // This code is optimized for the case when collection set contains only
    // a few regions. In this case, it is more constructive to check for is_in
< prev index next >