< prev index next >

src/hotspot/share/gc/shenandoah/shenandoahConcurrentMark.inline.hpp

Print this page
rev 50076 : Fold Partial GC into Traversal GC


  25 #define SHARE_VM_GC_SHENANDOAH_SHENANDOAHCONCURRENTMARK_INLINE_HPP
  26 
  27 #include "classfile/javaClasses.inline.hpp"
  28 #include "gc/shenandoah/brooksPointer.hpp"
  29 #include "gc/shenandoah/shenandoahAsserts.hpp"
  30 #include "gc/shenandoah/shenandoahBarrierSet.inline.hpp"
  31 #include "gc/shenandoah/shenandoahConcurrentMark.hpp"
  32 #include "gc/shenandoah/shenandoahStringDedup.hpp"
  33 #include "memory/iterator.inline.hpp"
  34 #include "oops/oop.inline.hpp"
  35 #include "runtime/prefetch.inline.hpp"
  36 
  37 template <class T, bool COUNT_LIVENESS>
  38 void ShenandoahConcurrentMark::do_task(ShenandoahObjToScanQueue* q, T* cl, jushort* live_data, ShenandoahMarkTask* task) {
  39   oop obj = task->obj();
  40 
  41   shenandoah_assert_not_forwarded_except(NULL, obj, _heap->is_concurrent_traversal_in_progress() && _heap->cancelled_concgc());
  42   shenandoah_assert_marked_next(NULL, obj);
  43   shenandoah_assert_not_in_cset_except(NULL, obj, _heap->cancelled_concgc());
  44 

  45   if (task->is_not_chunked()) {
  46     if (COUNT_LIVENESS) count_liveness(live_data, obj);
  47     if (obj->is_instance()) {
  48       // Case 1: Normal oop, process as usual.
  49       obj->oop_iterate(cl);
  50     } else if (obj->is_objArray()) {
  51       // Case 2: Object array instance and no chunk is set. Must be the first
  52       // time we visit it, start the chunked processing.
  53       do_chunked_array_start<T>(q, cl, obj);
  54     } else {
  55       // Case 3: Primitive array. Do nothing, no oops there. We use the same
  56       // performance tweak TypeArrayKlass::oop_oop_iterate_impl is using:
  57       // We skip iterating over the klass pointer since we know that
  58       // Universe::TypeArrayKlass never moves.
  59       assert (obj->is_typeArray(), "should be type array");
  60     }
  61   } else {
  62     // Case 4: Array chunk, has sensible chunk id. Process it.
  63     do_chunked_array<T>(q, cl, obj, task->chunk(), task->pow());
  64   }

  65 }
  66 
  67 inline void ShenandoahConcurrentMark::count_liveness(jushort* live_data, oop obj) {
  68   size_t region_idx = _heap->heap_region_index_containing(obj);
  69   ShenandoahHeapRegion* region = _heap->get_region(region_idx);
  70   if (!region->is_humongous_start()) {
  71     assert(!region->is_humongous(), "Cannot have continuations here");
  72     jushort cur = live_data[region_idx];
  73     size_t size = obj->size() + BrooksPointer::word_size();
  74     size_t max = (1 << (sizeof(jushort) * 8)) - 1;
  75     if (size >= max) {
  76       // too big, add to region data directly
  77       region->increase_live_data_gc_words(size);
  78     } else {
  79       size_t new_val = cur + size;
  80       if (new_val >= max) {
  81         // overflow, flush to region data
  82         region->increase_live_data_gc_words(new_val);
  83         live_data[region_idx] = 0;
  84       } else {




  25 #define SHARE_VM_GC_SHENANDOAH_SHENANDOAHCONCURRENTMARK_INLINE_HPP
  26 
  27 #include "classfile/javaClasses.inline.hpp"
  28 #include "gc/shenandoah/brooksPointer.hpp"
  29 #include "gc/shenandoah/shenandoahAsserts.hpp"
  30 #include "gc/shenandoah/shenandoahBarrierSet.inline.hpp"
  31 #include "gc/shenandoah/shenandoahConcurrentMark.hpp"
  32 #include "gc/shenandoah/shenandoahStringDedup.hpp"
  33 #include "memory/iterator.inline.hpp"
  34 #include "oops/oop.inline.hpp"
  35 #include "runtime/prefetch.inline.hpp"
  36 
  37 template <class T, bool COUNT_LIVENESS>
  38 void ShenandoahConcurrentMark::do_task(ShenandoahObjToScanQueue* q, T* cl, jushort* live_data, ShenandoahMarkTask* task) {
  39   oop obj = task->obj();
  40 
  41   shenandoah_assert_not_forwarded_except(NULL, obj, _heap->is_concurrent_traversal_in_progress() && _heap->cancelled_concgc());
  42   shenandoah_assert_marked_next(NULL, obj);
  43   shenandoah_assert_not_in_cset_except(NULL, obj, _heap->cancelled_concgc());
  44 
  45   cl->set_base_object(obj);
  46   if (task->is_not_chunked()) {
  47     if (COUNT_LIVENESS) count_liveness(live_data, obj);
  48     if (obj->is_instance()) {
  49       // Case 1: Normal oop, process as usual.
  50       obj->oop_iterate(cl);
  51     } else if (obj->is_objArray()) {
  52       // Case 2: Object array instance and no chunk is set. Must be the first
  53       // time we visit it, start the chunked processing.
  54       do_chunked_array_start<T>(q, cl, obj);
  55     } else {
  56       // Case 3: Primitive array. Do nothing, no oops there. We use the same
  57       // performance tweak TypeArrayKlass::oop_oop_iterate_impl is using:
  58       // We skip iterating over the klass pointer since we know that
  59       // Universe::TypeArrayKlass never moves.
  60       assert (obj->is_typeArray(), "should be type array");
  61     }
  62   } else {
  63     // Case 4: Array chunk, has sensible chunk id. Process it.
  64     do_chunked_array<T>(q, cl, obj, task->chunk(), task->pow());
  65   }
  66   cl->set_base_object(NULL);
  67 }
  68 
  69 inline void ShenandoahConcurrentMark::count_liveness(jushort* live_data, oop obj) {
  70   size_t region_idx = _heap->heap_region_index_containing(obj);
  71   ShenandoahHeapRegion* region = _heap->get_region(region_idx);
  72   if (!region->is_humongous_start()) {
  73     assert(!region->is_humongous(), "Cannot have continuations here");
  74     jushort cur = live_data[region_idx];
  75     size_t size = obj->size() + BrooksPointer::word_size();
  76     size_t max = (1 << (sizeof(jushort) * 8)) - 1;
  77     if (size >= max) {
  78       // too big, add to region data directly
  79       region->increase_live_data_gc_words(size);
  80     } else {
  81       size_t new_val = cur + size;
  82       if (new_val >= max) {
  83         // overflow, flush to region data
  84         region->increase_live_data_gc_words(new_val);
  85         live_data[region_idx] = 0;
  86       } else {


< prev index next >