< prev index next >

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

Print this page
rev 13055 : Implement barriers for maintaining connection matrix.


 189 
 190 inline bool ShenandoahConcurrentMark::try_queue(SCMObjToScanQueue* q, SCMTask &task) {
 191   return (q->pop_buffer(task) ||
 192           q->pop_local(task) ||
 193           q->pop_overflow(task));
 194 }
 195 
 196 class ShenandoahSATBBufferClosure : public SATBBufferClosure {
 197 private:
 198   SCMObjToScanQueue* _queue;
 199   ShenandoahHeap* _heap;
 200 public:
 201   ShenandoahSATBBufferClosure(SCMObjToScanQueue* q) :
 202     _queue(q), _heap(ShenandoahHeap::heap())
 203   {
 204   }
 205 
 206   void do_buffer(void** buffer, size_t size) {
 207     for (size_t i = 0; i < size; ++i) {
 208       oop* p = (oop*) &buffer[i];
 209       ShenandoahConcurrentMark::mark_through_ref<oop, RESOLVE>(p, _heap, _queue);
 210     }
 211   }
 212 };
 213 
 214 inline bool ShenandoahConcurrentMark::try_draining_satb_buffer(SCMObjToScanQueue *q, SCMTask &task) {
 215   ShenandoahSATBBufferClosure cl(q);
 216   SATBMarkQueueSet& satb_mq_set = JavaThread::satb_mark_queue_set();
 217   bool had_refs = satb_mq_set.apply_closure_to_completed_buffer(&cl);
 218   return had_refs && try_queue(q, task);
 219 }
 220 
 221 template<class T, UpdateRefsMode UPDATE_REFS>
 222 inline void ShenandoahConcurrentMark::mark_through_ref(T *p, ShenandoahHeap* heap, SCMObjToScanQueue* q) {
 223   T o = oopDesc::load_heap_oop(p);
 224   if (! oopDesc::is_null(o)) {
 225     oop obj = oopDesc::decode_heap_oop_not_null(o);
 226     switch (UPDATE_REFS) {
 227     case NONE:
 228       break;
 229     case RESOLVE:
 230       obj = ShenandoahBarrierSet::resolve_oop_static_not_null(obj);
 231       break;
 232     case SIMPLE:
 233       // We piggy-back reference updating to the marking tasks.
 234       obj = heap->update_oop_ref_not_null(p, obj);
 235       break;
 236     case CONCURRENT:
 237       obj = heap->maybe_update_oop_ref_not_null(p, obj);
 238       break;
 239     default:
 240       ShouldNotReachHere();
 241     }
 242     assert(oopDesc::unsafe_equals(obj, ShenandoahBarrierSet::resolve_oop_static(obj)), "need to-space object here");
 243 
 244     // Note: Only when concurrently updating references can obj become NULL here.
 245     // It happens when a mutator thread beats us by writing another value. In that
 246     // case we don't need to do anything else.
 247     if (UPDATE_REFS != CONCURRENT || !oopDesc::is_null(obj)) {
 248       assert(!oopDesc::is_null(obj), "Must not be null here");
 249       assert(heap->is_in(obj), "We shouldn't be calling this on objects not in the heap: " PTR_FORMAT, p2i(obj));
 250       assert(oopDesc::bs()->is_safe(obj), "Only mark objects in from-space");









 251       if (heap->mark_next(obj)) {
 252         log_develop_trace(gc, marking)("Marked obj: " PTR_FORMAT, p2i((HeapWord*) obj));
 253 
 254         bool pushed = q->push(SCMTask(obj));
 255         assert(pushed, "overflow queue should always succeed pushing");
 256       } else {
 257         log_develop_trace(gc, marking)("Failed to mark obj (already marked): " PTR_FORMAT, p2i((HeapWord*) obj));
 258         assert(heap->is_marked_next(obj), "Consistency: should be marked.");
 259       }
 260     }
 261   }
 262 }
 263 
 264 #endif // SHARE_VM_GC_SHENANDOAH_SHENANDOAHCONCURRENTMARK_INLINE_HPP


 189 
 190 inline bool ShenandoahConcurrentMark::try_queue(SCMObjToScanQueue* q, SCMTask &task) {
 191   return (q->pop_buffer(task) ||
 192           q->pop_local(task) ||
 193           q->pop_overflow(task));
 194 }
 195 
 196 class ShenandoahSATBBufferClosure : public SATBBufferClosure {
 197 private:
 198   SCMObjToScanQueue* _queue;
 199   ShenandoahHeap* _heap;
 200 public:
 201   ShenandoahSATBBufferClosure(SCMObjToScanQueue* q) :
 202     _queue(q), _heap(ShenandoahHeap::heap())
 203   {
 204   }
 205 
 206   void do_buffer(void** buffer, size_t size) {
 207     for (size_t i = 0; i < size; ++i) {
 208       oop* p = (oop*) &buffer[i];
 209       ShenandoahConcurrentMark::mark_through_ref<oop, RESOLVE, false>(p, _heap, _queue, NULL);
 210     }
 211   }
 212 };
 213 
 214 inline bool ShenandoahConcurrentMark::try_draining_satb_buffer(SCMObjToScanQueue *q, SCMTask &task) {
 215   ShenandoahSATBBufferClosure cl(q);
 216   SATBMarkQueueSet& satb_mq_set = JavaThread::satb_mark_queue_set();
 217   bool had_refs = satb_mq_set.apply_closure_to_completed_buffer(&cl);
 218   return had_refs && try_queue(q, task);
 219 }
 220 
 221 template<class T, UpdateRefsMode UPDATE_REFS, bool UPDATE_MATRIX>
 222 inline void ShenandoahConcurrentMark::mark_through_ref(T *p, ShenandoahHeap* heap, SCMObjToScanQueue* q, ShenandoahConnectionMatrix* conn_matrix) {
 223   T o = oopDesc::load_heap_oop(p);
 224   if (! oopDesc::is_null(o)) {
 225     oop obj = oopDesc::decode_heap_oop_not_null(o);
 226     switch (UPDATE_REFS) {
 227     case NONE:
 228       break;
 229     case RESOLVE:
 230       obj = ShenandoahBarrierSet::resolve_oop_static_not_null(obj);
 231       break;
 232     case SIMPLE:
 233       // We piggy-back reference updating to the marking tasks.
 234       obj = heap->update_oop_ref_not_null(p, obj);
 235       break;
 236     case CONCURRENT:
 237       obj = heap->maybe_update_oop_ref_not_null(p, obj);
 238       break;
 239     default:
 240       ShouldNotReachHere();
 241     }
 242     assert(oopDesc::unsafe_equals(obj, ShenandoahBarrierSet::resolve_oop_static(obj)), "need to-space object here");
 243 
 244     // Note: Only when concurrently updating references can obj become NULL here.
 245     // It happens when a mutator thread beats us by writing another value. In that
 246     // case we don't need to do anything else.
 247     if (UPDATE_REFS != CONCURRENT || !oopDesc::is_null(obj)) {
 248       assert(!oopDesc::is_null(obj), "Must not be null here");
 249       assert(heap->is_in(obj), "We shouldn't be calling this on objects not in the heap: " PTR_FORMAT, p2i(obj));
 250       assert(oopDesc::bs()->is_safe(obj), "Only mark objects in from-space");
 251 
 252       if (UPDATE_MATRIX) {
 253         if (heap->is_in_reserved(p)) { // Could also be in CLD, when marking through metadata.
 254           uint from_idx = heap->heap_region_index_containing(p);
 255           uint to_idx = heap->heap_region_index_containing(obj);
 256           conn_matrix->set_connected(from_idx, to_idx, true);
 257         }
 258       }
 259 
 260       if (heap->mark_next(obj)) {
 261         log_develop_trace(gc, marking)("Marked obj: " PTR_FORMAT, p2i((HeapWord*) obj));
 262 
 263         bool pushed = q->push(SCMTask(obj));
 264         assert(pushed, "overflow queue should always succeed pushing");
 265       } else {
 266         log_develop_trace(gc, marking)("Failed to mark obj (already marked): " PTR_FORMAT, p2i((HeapWord*) obj));
 267         assert(heap->is_marked_next(obj), "Consistency: should be marked.");
 268       }
 269     }
 270   }
 271 }
 272 
 273 #endif // SHARE_VM_GC_SHENANDOAH_SHENANDOAHCONCURRENTMARK_INLINE_HPP
< prev index next >