< prev index next >

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

Print this page

266     // No GCLABs in this thread, fallback to shared allocation
267     return NULL;
268   }
269   HeapWord* obj = gclab->allocate(size);
270   if (obj != NULL) {
271     return obj;
272   }
273   // Otherwise...
274   return allocate_from_gclab_slow(thread, size);
275 }
276 
277 inline oop ShenandoahHeap::evacuate_object(oop p, Thread* thread) {
278   if (ShenandoahThreadLocalData::is_oom_during_evac(Thread::current())) {
279     // This thread went through the OOM during evac protocol and it is safe to return
280     // the forward pointer. It must not attempt to evacuate any more.
281     return ShenandoahBarrierSet::resolve_forwarded(p);
282   }
283 
284   assert(ShenandoahThreadLocalData::is_evac_allowed(thread), "must be enclosed in oom-evac scope");
285 
286   size_t size = p->size();
287 
288   assert(!heap_region_containing(p)->is_humongous(), "never evacuate humongous objects");
289 
290   bool alloc_from_gclab = true;
291   HeapWord* copy = NULL;
292 
293 #ifdef ASSERT
294   if (ShenandoahOOMDuringEvacALot &&
295       (os::random() & 1) == 0) { // Simulate OOM every ~2nd slow-path call
296         copy = NULL;
297   } else {
298 #endif
299     if (UseTLAB) {
300       copy = allocate_from_gclab(thread, size);
301     }
302     if (copy == NULL) {
303       ShenandoahAllocRequest req = ShenandoahAllocRequest::for_shared_gc(size);
304       copy = allocate_memory(req);
305       alloc_from_gclab = false;
306     }

483       assert(oopDesc::is_oop(obj), "sanity");
484       assert(ctx->is_marked(obj), "object expected to be marked");
485       cl->do_object(obj);
486       cb += skip_bitmap_delta;
487       if (cb < limit_bitmap) {
488         cb = ctx->get_next_marked_addr(cb, limit_bitmap);
489       }
490     }
491   }
492 
493   // Step 2. Accurate size-based traversal, happens past the TAMS.
494   // This restarts the scan at TAMS, which makes sure we traverse all objects,
495   // regardless of what happened at Step 1.
496   HeapWord* cs = tams;
497   while (cs < limit) {
498     assert (cs >= tams, "only objects past TAMS here: "   PTR_FORMAT " (" PTR_FORMAT ")", p2i(cs), p2i(tams));
499     assert (cs < limit, "only objects below limit here: " PTR_FORMAT " (" PTR_FORMAT ")", p2i(cs), p2i(limit));
500     oop obj = cast_to_oop(cs);
501     assert(oopDesc::is_oop(obj), "sanity");
502     assert(ctx->is_marked(obj), "object expected to be marked");
503     int size = obj->size();
504     cl->do_object(obj);
505     cs += size;
506   }
507 }
508 
509 template <class T>
510 class ShenandoahObjectToOopClosure : public ObjectClosure {
511   T* _cl;
512 public:
513   ShenandoahObjectToOopClosure(T* cl) : _cl(cl) {}
514 
515   void do_object(oop obj) {
516     obj->oop_iterate(_cl);
517   }
518 };
519 
520 template <class T>
521 class ShenandoahObjectToOopBoundedClosure : public ObjectClosure {
522   T* _cl;
523   MemRegion _bounds;

266     // No GCLABs in this thread, fallback to shared allocation
267     return NULL;
268   }
269   HeapWord* obj = gclab->allocate(size);
270   if (obj != NULL) {
271     return obj;
272   }
273   // Otherwise...
274   return allocate_from_gclab_slow(thread, size);
275 }
276 
277 inline oop ShenandoahHeap::evacuate_object(oop p, Thread* thread) {
278   if (ShenandoahThreadLocalData::is_oom_during_evac(Thread::current())) {
279     // This thread went through the OOM during evac protocol and it is safe to return
280     // the forward pointer. It must not attempt to evacuate any more.
281     return ShenandoahBarrierSet::resolve_forwarded(p);
282   }
283 
284   assert(ShenandoahThreadLocalData::is_evac_allowed(thread), "must be enclosed in oom-evac scope");
285 
286   size_t size = p->forward_safe_size();
287 
288   assert(!heap_region_containing(p)->is_humongous(), "never evacuate humongous objects");
289 
290   bool alloc_from_gclab = true;
291   HeapWord* copy = NULL;
292 
293 #ifdef ASSERT
294   if (ShenandoahOOMDuringEvacALot &&
295       (os::random() & 1) == 0) { // Simulate OOM every ~2nd slow-path call
296         copy = NULL;
297   } else {
298 #endif
299     if (UseTLAB) {
300       copy = allocate_from_gclab(thread, size);
301     }
302     if (copy == NULL) {
303       ShenandoahAllocRequest req = ShenandoahAllocRequest::for_shared_gc(size);
304       copy = allocate_memory(req);
305       alloc_from_gclab = false;
306     }

483       assert(oopDesc::is_oop(obj), "sanity");
484       assert(ctx->is_marked(obj), "object expected to be marked");
485       cl->do_object(obj);
486       cb += skip_bitmap_delta;
487       if (cb < limit_bitmap) {
488         cb = ctx->get_next_marked_addr(cb, limit_bitmap);
489       }
490     }
491   }
492 
493   // Step 2. Accurate size-based traversal, happens past the TAMS.
494   // This restarts the scan at TAMS, which makes sure we traverse all objects,
495   // regardless of what happened at Step 1.
496   HeapWord* cs = tams;
497   while (cs < limit) {
498     assert (cs >= tams, "only objects past TAMS here: "   PTR_FORMAT " (" PTR_FORMAT ")", p2i(cs), p2i(tams));
499     assert (cs < limit, "only objects below limit here: " PTR_FORMAT " (" PTR_FORMAT ")", p2i(cs), p2i(limit));
500     oop obj = cast_to_oop(cs);
501     assert(oopDesc::is_oop(obj), "sanity");
502     assert(ctx->is_marked(obj), "object expected to be marked");
503     size_t size = obj->forward_safe_size();
504     cl->do_object(obj);
505     cs += size;
506   }
507 }
508 
509 template <class T>
510 class ShenandoahObjectToOopClosure : public ObjectClosure {
511   T* _cl;
512 public:
513   ShenandoahObjectToOopClosure(T* cl) : _cl(cl) {}
514 
515   void do_object(oop obj) {
516     obj->oop_iterate(_cl);
517   }
518 };
519 
520 template <class T>
521 class ShenandoahObjectToOopBoundedClosure : public ObjectClosure {
522   T* _cl;
523   MemRegion _bounds;
< prev index next >