< prev index next >

src/share/vm/gc_implementation/shenandoah/shenandoahHeapRegionCounters.cpp

Print this page
rev 11463 : Backport Traversal GC


  67     }
  68   }
  69 }
  70 
  71 ShenandoahHeapRegionCounters::~ShenandoahHeapRegionCounters() {
  72   if (_name_space != NULL) FREE_C_HEAP_ARRAY(char, _name_space, mtGC);
  73 }
  74 
  75 void ShenandoahHeapRegionCounters::update() {
  76   if (ShenandoahRegionSampling) {
  77     jlong current = os::javaTimeMillis();
  78     jlong last = _last_sample_millis;
  79     if (current - last > ShenandoahRegionSamplingRate &&
  80             Atomic::cmpxchg(current, &_last_sample_millis, last) == last) {
  81 
  82       ShenandoahHeap* heap = ShenandoahHeap::heap();
  83       jlong status = 0;
  84       if (heap->is_concurrent_mark_in_progress()) status |= 1 << 0;
  85       if (heap->is_evacuation_in_progress())   status |= 1 << 1;
  86       if (heap->is_update_refs_in_progress())  status |= 1 << 2;

  87       _status->set_value(status);
  88 
  89       _timestamp->set_value(os::elapsed_counter());
  90 
  91       size_t num_regions = heap->num_regions();
  92 
  93       {
  94         ShenandoahHeapLocker locker(heap->lock());
  95         size_t rs = ShenandoahHeapRegion::region_size_bytes();
  96         for (uint i = 0; i < num_regions; i++) {
  97           ShenandoahHeapRegion* r = heap->get_region(i);
  98           jlong data = 0;
  99           data |= ((100 * r->used() / rs)                & PERCENT_MASK) << USED_SHIFT;
 100           data |= ((100 * r->get_live_data_bytes() / rs) & PERCENT_MASK) << LIVE_SHIFT;
 101           data |= ((100 * r->get_tlab_allocs() / rs)     & PERCENT_MASK) << TLAB_SHIFT;
 102           data |= ((100 * r->get_gclab_allocs() / rs)    & PERCENT_MASK) << GCLAB_SHIFT;
 103           data |= ((100 * r->get_shared_allocs() / rs)   & PERCENT_MASK) << SHARED_SHIFT;
 104           data |= (r->state_ordinal() & STATUS_MASK) << STATUS_SHIFT;
 105           _regions_data[i]->set_value(data);
 106         }


  67     }
  68   }
  69 }
  70 
  71 ShenandoahHeapRegionCounters::~ShenandoahHeapRegionCounters() {
  72   if (_name_space != NULL) FREE_C_HEAP_ARRAY(char, _name_space, mtGC);
  73 }
  74 
  75 void ShenandoahHeapRegionCounters::update() {
  76   if (ShenandoahRegionSampling) {
  77     jlong current = os::javaTimeMillis();
  78     jlong last = _last_sample_millis;
  79     if (current - last > ShenandoahRegionSamplingRate &&
  80             Atomic::cmpxchg(current, &_last_sample_millis, last) == last) {
  81 
  82       ShenandoahHeap* heap = ShenandoahHeap::heap();
  83       jlong status = 0;
  84       if (heap->is_concurrent_mark_in_progress())      status |= 1 << 0;
  85       if (heap->is_evacuation_in_progress())           status |= 1 << 1;
  86       if (heap->is_update_refs_in_progress())          status |= 1 << 2;
  87       if (heap->is_concurrent_traversal_in_progress()) status |= 1 << 3;
  88      _status->set_value(status);
  89 
  90       _timestamp->set_value(os::elapsed_counter());
  91 
  92       size_t num_regions = heap->num_regions();
  93 
  94       {
  95         ShenandoahHeapLocker locker(heap->lock());
  96         size_t rs = ShenandoahHeapRegion::region_size_bytes();
  97         for (uint i = 0; i < num_regions; i++) {
  98           ShenandoahHeapRegion* r = heap->get_region(i);
  99           jlong data = 0;
 100           data |= ((100 * r->used() / rs)                & PERCENT_MASK) << USED_SHIFT;
 101           data |= ((100 * r->get_live_data_bytes() / rs) & PERCENT_MASK) << LIVE_SHIFT;
 102           data |= ((100 * r->get_tlab_allocs() / rs)     & PERCENT_MASK) << TLAB_SHIFT;
 103           data |= ((100 * r->get_gclab_allocs() / rs)    & PERCENT_MASK) << GCLAB_SHIFT;
 104           data |= ((100 * r->get_shared_allocs() / rs)   & PERCENT_MASK) << SHARED_SHIFT;
 105           data |= (r->state_ordinal() & STATUS_MASK) << STATUS_SHIFT;
 106           _regions_data[i]->set_value(data);
 107         }
< prev index next >