< prev index next >

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

Print this page




  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_GC_SHENANDOAH_SHENANDOAHBARRIERSETCLONE_INLINE_HPP
  26 #define SHARE_GC_SHENANDOAH_SHENANDOAHBARRIERSETCLONE_INLINE_HPP
  27 
  28 #include "gc/shenandoah/shenandoahBarrierSet.inline.hpp"
  29 #include "gc/shenandoah/shenandoahCollectionSet.inline.hpp"
  30 #include "gc/shenandoah/shenandoahEvacOOMHandler.hpp"
  31 #include "gc/shenandoah/shenandoahHeap.inline.hpp"
  32 #include "memory/iterator.hpp"
  33 #include "oops/access.hpp"
  34 #include "oops/compressedOops.hpp"
  35 
  36 template <bool EVAC, bool ENQUEUE>
  37 class ShenandoahUpdateRefsForOopClosure: public BasicOopIterateClosure {
  38 private:
  39   ShenandoahHeap* const _heap;
  40   ShenandoahBarrierSet* const _bs;
  41   const ShenandoahCollectionSet* const _cset;
  42   Thread* const _thread;
  43 
  44   template <class T>
  45   inline void do_oop_work(T* p) {
  46     T o = RawAccess<>::oop_load(p);
  47     if (!CompressedOops::is_null(o)) {
  48       oop obj = CompressedOops::decode_not_null(o);
  49       if (_cset->is_in(obj)) {
  50         oop fwd = _bs->resolve_forwarded_not_null(obj);
  51         if (EVAC && obj == fwd) {
  52           fwd = _heap->evacuate_object(obj, _thread);
  53         }
  54         if (ENQUEUE) {
  55           _bs->enqueue(fwd);
  56         }
  57         assert(obj != fwd || _heap->cancelled_gc(), "must be forwarded");
  58         ShenandoahHeap::cas_oop(fwd, p, o);




  59       }
  60 
  61     }
  62   }
  63 public:
  64   ShenandoahUpdateRefsForOopClosure() :
  65           _heap(ShenandoahHeap::heap()),
  66           _bs(ShenandoahBarrierSet::barrier_set()),
  67           _cset(_heap->collection_set()),
  68           _thread(Thread::current()) {
  69   }
  70 
  71   virtual void do_oop(oop* p)       { do_oop_work(p); }
  72   virtual void do_oop(narrowOop* p) { do_oop_work(p); }
  73 };
  74 
  75 void ShenandoahBarrierSet::clone_barrier(oop obj) {
  76   assert(ShenandoahCloneBarrier, "only get here with clone barriers enabled");
  77   assert(_heap->has_forwarded_objects(), "only when heap is unstable");
  78 
  79   // This is called for cloning an object (see jvm.cpp) after the clone
  80   // has been made. We are not interested in any 'previous value' because
  81   // it would be NULL in any case. But we *are* interested in any oop*
  82   // that potentially need to be updated.
  83 
  84   shenandoah_assert_correct(NULL, obj);







  85   if (skip_bulk_update(cast_from_oop<HeapWord*>(obj))) return;
  86   if (_heap->is_evacuation_in_progress()) {
  87     ShenandoahEvacOOMScope evac_scope;
  88     ShenandoahUpdateRefsForOopClosure</* evac = */ true, /* enqueue */ false> cl;
  89     obj->oop_iterate(&cl);
  90   } else if (_heap->is_concurrent_traversal_in_progress()) {
  91     ShenandoahEvacOOMScope evac_scope;
  92     ShenandoahUpdateRefsForOopClosure</* evac = */ true, /* enqueue */ true> cl;
  93     obj->oop_iterate(&cl);
  94   } else {
  95     ShenandoahUpdateRefsForOopClosure</* evac = */ false, /* enqueue */ false> cl;

  96     obj->oop_iterate(&cl);
  97   }
  98 }
  99 
 100 #endif // SHARE_GC_SHENANDOAH_SHENANDOAHBARRIERSETCLONE_INLINE_HPP


  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_GC_SHENANDOAH_SHENANDOAHBARRIERSETCLONE_INLINE_HPP
  26 #define SHARE_GC_SHENANDOAH_SHENANDOAHBARRIERSETCLONE_INLINE_HPP
  27 
  28 #include "gc/shenandoah/shenandoahBarrierSet.inline.hpp"
  29 #include "gc/shenandoah/shenandoahCollectionSet.inline.hpp"
  30 #include "gc/shenandoah/shenandoahEvacOOMHandler.hpp"
  31 #include "gc/shenandoah/shenandoahHeap.inline.hpp"
  32 #include "memory/iterator.hpp"
  33 #include "oops/access.hpp"
  34 #include "oops/compressedOops.hpp"
  35 
  36 template <bool HAS_FWD, bool EVAC, bool ENQUEUE>
  37 class ShenandoahUpdateRefsForOopClosure: public BasicOopIterateClosure {
  38 private:
  39   ShenandoahHeap* const _heap;
  40   ShenandoahBarrierSet* const _bs;
  41   const ShenandoahCollectionSet* const _cset;
  42   Thread* const _thread;
  43 
  44   template <class T>
  45   inline void do_oop_work(T* p) {
  46     T o = RawAccess<>::oop_load(p);
  47     if (!CompressedOops::is_null(o)) {
  48       oop obj = CompressedOops::decode_not_null(o);
  49       if (HAS_FWD && _cset->is_in(obj)) {
  50         oop fwd = _bs->resolve_forwarded_not_null(obj);
  51         if (EVAC && obj == fwd) {
  52           fwd = _heap->evacuate_object(obj, _thread);
  53         }



  54         assert(obj != fwd || _heap->cancelled_gc(), "must be forwarded");
  55         ShenandoahHeap::cas_oop(fwd, p, o);
  56         obj = fwd;
  57       }
  58       if (ENQUEUE) {
  59         _bs->enqueue(obj);
  60       }

  61     }
  62   }
  63 public:
  64   ShenandoahUpdateRefsForOopClosure() :
  65           _heap(ShenandoahHeap::heap()),
  66           _bs(ShenandoahBarrierSet::barrier_set()),
  67           _cset(_heap->collection_set()),
  68           _thread(Thread::current()) {
  69   }
  70 
  71   virtual void do_oop(oop* p)       { do_oop_work(p); }
  72   virtual void do_oop(narrowOop* p) { do_oop_work(p); }
  73 };
  74 
  75 void ShenandoahBarrierSet::clone_barrier(oop obj) {
  76   assert(ShenandoahCloneBarrier, "only get here with clone barriers enabled");

  77 
  78   // This is called for cloning an object (see jvm.cpp) after the clone
  79   // has been made. We are not interested in any 'previous value' because
  80   // it would be NULL in any case. But we *are* interested in any oop*
  81   // that potentially need to be updated.
  82 
  83   shenandoah_assert_correct(NULL, obj);
  84   if (_heap->is_concurrent_mark_in_progress() &&
  85       ShenandoahStoreValEnqueueBarrier) {
  86     ShenandoahUpdateRefsForOopClosure<false, false, true> cl;
  87     obj->oop_iterate(&cl);
  88     return;
  89   }
  90 
  91   if (skip_bulk_update(cast_from_oop<HeapWord*>(obj))) return;
  92   if (_heap->is_evacuation_in_progress()) {
  93     ShenandoahEvacOOMScope evac_scope;
  94     ShenandoahUpdateRefsForOopClosure</* has_fwd = */ true, /* evac = */ true, /* enqueue */ false> cl;
  95     obj->oop_iterate(&cl);
  96   } else if (_heap->is_concurrent_traversal_in_progress()) {
  97     ShenandoahEvacOOMScope evac_scope;
  98     ShenandoahUpdateRefsForOopClosure</* has_fwd = */ true, /* evac = */ true, /* enqueue */ true> cl;
  99     obj->oop_iterate(&cl);
 100   } else {
 101     assert(_heap->has_forwarded_objects(), "only with forwarded objects");
 102     ShenandoahUpdateRefsForOopClosure</* has_fwd = */ true, /* evac = */ false, /* enqueue */ false> cl;
 103     obj->oop_iterate(&cl);
 104   }
 105 }
 106 
 107 #endif // SHARE_GC_SHENANDOAH_SHENANDOAHBARRIERSETCLONE_INLINE_HPP
< prev index next >