< prev index next >

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

Print this page

313       copy = allocate_from_gclab(thread, size);
314     }
315     if (copy == NULL) {
316       ShenandoahAllocRequest req = ShenandoahAllocRequest::for_shared_gc(size);
317       copy = allocate_memory(req);
318       alloc_from_gclab = false;
319     }
320 #ifdef ASSERT
321   }
322 #endif
323 
324   if (copy == NULL) {
325     control_thread()->handle_alloc_failure_evac(size);
326 
327     _oom_evac_handler.handle_out_of_memory_during_evacuation();
328 
329     return ShenandoahBarrierSet::resolve_forwarded(p);
330   }
331 
332   // Copy the object:
333   Copy::aligned_disjoint_words(cast_from_oop<HeapWord*>(p), copy, size);
334 
335   // Try to install the new forwarding pointer.
336   oop copy_val = cast_to_oop(copy);
337   oop result = ShenandoahForwarding::try_update_forwardee(p, copy_val);
338   if (result == copy_val) {
339     // Successfully evacuated. Our copy is now the public one!
340     shenandoah_assert_correct(NULL, copy_val);
341     return copy_val;
342   }  else {
343     // Failed to evacuate. We need to deal with the object that is left behind. Since this
344     // new allocation is certainly after TAMS, it will be considered live in the next cycle.
345     // But if it happens to contain references to evacuated regions, those references would
346     // not get updated for this stale copy during this cycle, and we will crash while scanning
347     // it the next cycle.
348     //
349     // For GCLAB allocations, it is enough to rollback the allocation ptr. Either the next
350     // object will overwrite this stale copy, or the filler object on LAB retirement will
351     // do this. For non-GCLAB allocations, we have no way to retract the allocation, and
352     // have to explicitly overwrite the copy with the filler object. With that overwrite,
353     // we have to keep the fwdptr initialized and pointing to our (stale) copy.

313       copy = allocate_from_gclab(thread, size);
314     }
315     if (copy == NULL) {
316       ShenandoahAllocRequest req = ShenandoahAllocRequest::for_shared_gc(size);
317       copy = allocate_memory(req);
318       alloc_from_gclab = false;
319     }
320 #ifdef ASSERT
321   }
322 #endif
323 
324   if (copy == NULL) {
325     control_thread()->handle_alloc_failure_evac(size);
326 
327     _oom_evac_handler.handle_out_of_memory_during_evacuation();
328 
329     return ShenandoahBarrierSet::resolve_forwarded(p);
330   }
331 
332   // Copy the object:
333   p->copy_disjoint(copy, size);
334 
335   // Try to install the new forwarding pointer.
336   oop copy_val = cast_to_oop(copy);
337   oop result = ShenandoahForwarding::try_update_forwardee(p, copy_val);
338   if (result == copy_val) {
339     // Successfully evacuated. Our copy is now the public one!
340     shenandoah_assert_correct(NULL, copy_val);
341     return copy_val;
342   }  else {
343     // Failed to evacuate. We need to deal with the object that is left behind. Since this
344     // new allocation is certainly after TAMS, it will be considered live in the next cycle.
345     // But if it happens to contain references to evacuated regions, those references would
346     // not get updated for this stale copy during this cycle, and we will crash while scanning
347     // it the next cycle.
348     //
349     // For GCLAB allocations, it is enough to rollback the allocation ptr. Either the next
350     // object will overwrite this stale copy, or the filler object on LAB retirement will
351     // do this. For non-GCLAB allocations, we have no way to retract the allocation, and
352     // have to explicitly overwrite the copy with the filler object. With that overwrite,
353     // we have to keep the fwdptr initialized and pointing to our (stale) copy.
< prev index next >