< prev index next >

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

Print this page
rev 13130 : Interleave partial GCs with concurrent GCs.


 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           conn_matrix->set_connected(p, obj);
 255         }
 256       }
 257 
 258       if (heap->mark_next(obj)) {
 259         log_develop_trace(gc, marking)("Marked obj: " PTR_FORMAT, p2i((HeapWord*) obj));
 260 
 261         bool pushed = q->push(SCMTask(obj));
 262         assert(pushed, "overflow queue should always succeed pushing");
 263       } else {
 264         log_develop_trace(gc, marking)("Failed to mark obj (already marked): " PTR_FORMAT, p2i((HeapWord*) obj));
 265         assert(heap->is_marked_next(obj), "Consistency: should be marked.");
 266       }
 267     }
 268   }
 269 }
 270 
 271 #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>(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 
 252       if (heap->mark_next(obj)) {
 253         log_develop_trace(gc, marking)("Marked obj: " PTR_FORMAT, p2i((HeapWord*) obj));
 254 
 255         bool pushed = q->push(SCMTask(obj));
 256         assert(pushed, "overflow queue should always succeed pushing");
 257       } else {
 258         log_develop_trace(gc, marking)("Failed to mark obj (already marked): " PTR_FORMAT, p2i((HeapWord*) obj));
 259         assert(heap->is_marked_next(obj), "Consistency: should be marked.");
 260       }
 261     }
 262   }
 263 }
 264 
 265 #endif // SHARE_VM_GC_SHENANDOAH_SHENANDOAHCONCURRENTMARK_INLINE_HPP
< prev index next >