< prev index next >

src/hotspot/share/gc/shared/plab.cpp

Print this page
rev 48920 : [backport] Use PLAB for evacuations instead of TLAB

@@ -42,11 +42,13 @@
 PLAB::PLAB(size_t desired_plab_sz_) :
   _word_sz(desired_plab_sz_), _bottom(NULL), _top(NULL),
   _end(NULL), _hard_end(NULL), _allocated(0), _wasted(0), _undo_wasted(0)
 {
   // ArrayOopDesc::header_size depends on command line initialization.
-  AlignmentReserve = oopDesc::header_size() > MinObjAlignment ? align_object_size(arrayOopDesc::header_size(T_INT)) : 0;
+  int rsv_regular = oopDesc::header_size() + (int) Universe::heap()->oop_extra_words();
+  int rsv_array   = align_object_size(arrayOopDesc::header_size(T_INT) + Universe::heap()->oop_extra_words());
+  AlignmentReserve = rsv_regular > MinObjAlignment ? rsv_array : 0;
   assert(min_size() > AlignmentReserve,
          "Minimum PLAB size " SIZE_FORMAT " must be larger than alignment reserve " SIZE_FORMAT " "
          "to be able to contain objects", min_size(), AlignmentReserve);
 }
 

@@ -80,18 +82,22 @@
 }
 
 size_t PLAB::retire_internal() {
   size_t result = 0;
   if (_top < _hard_end) {
-    CollectedHeap::fill_with_object(_top, _hard_end);
+    assert(pointer_delta(_hard_end, _top) >= (size_t)(oopDesc::header_size() + Universe::heap()->oop_extra_words()),
+           "better have enough space left to fill with dummy");
+    HeapWord* obj = Universe::heap()->tlab_post_allocation_setup(_top);
+    CollectedHeap::fill_with_object(obj, _hard_end);
     result += invalidate();
   }
   return result;
 }
 
 void PLAB::add_undo_waste(HeapWord* obj, size_t word_sz) {
-  CollectedHeap::fill_with_object(obj, word_sz);
+  HeapWord* head_obj = Universe::heap()->tlab_post_allocation_setup(obj);
+  CollectedHeap::fill_with_object(head_obj, word_sz - (head_obj - obj));
   _undo_wasted += word_sz;
 }
 
 void PLAB::undo_last_allocation(HeapWord* obj, size_t word_sz) {
   assert(pointer_delta(_top, _bottom) >= word_sz, "Bad undo");
< prev index next >