< prev index next >

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

Print this page
rev 52059 : 8211955: GC abstraction for LAB reserve


  26 #include "gc/shared/collectedHeap.hpp"
  27 #include "gc/shared/plab.inline.hpp"
  28 #include "gc/shared/threadLocalAllocBuffer.hpp"
  29 #include "logging/log.hpp"
  30 #include "oops/arrayOop.hpp"
  31 #include "oops/oop.inline.hpp"
  32 
  33 size_t PLAB::min_size() {
  34   // Make sure that we return something that is larger than AlignmentReserve
  35   return align_object_size(MAX2(MinTLABSize / HeapWordSize, (size_t)oopDesc::header_size())) + AlignmentReserve;
  36 }
  37 
  38 size_t PLAB::max_size() {
  39   return ThreadLocalAllocBuffer::max_size();
  40 }
  41 
  42 PLAB::PLAB(size_t desired_plab_sz_) :
  43   _word_sz(desired_plab_sz_), _bottom(NULL), _top(NULL),
  44   _end(NULL), _hard_end(NULL), _allocated(0), _wasted(0), _undo_wasted(0)
  45 {
  46   // ArrayOopDesc::header_size depends on command line initialization.
  47   AlignmentReserve = oopDesc::header_size() > MinObjAlignment ? align_object_size(arrayOopDesc::header_size(T_INT)) : 0;
  48   assert(min_size() > AlignmentReserve,
  49          "Minimum PLAB size " SIZE_FORMAT " must be larger than alignment reserve " SIZE_FORMAT " "
  50          "to be able to contain objects", min_size(), AlignmentReserve);
  51 }
  52 
  53 // If the minimum object size is greater than MinObjAlignment, we can
  54 // end up with a shard at the end of the buffer that's smaller than
  55 // the smallest object.  We can't allow that because the buffer must
  56 // look like it's full of objects when we retire it, so we make
  57 // sure we have enough space for a filler int array object.
  58 size_t PLAB::AlignmentReserve;
  59 
  60 void PLAB::flush_and_retire_stats(PLABStats* stats) {
  61   // Retire the last allocation buffer.
  62   size_t unused = retire_internal();
  63 
  64   // Now flush the statistics.
  65   stats->add_allocated(_allocated);
  66   stats->add_wasted(_wasted);
  67   stats->add_undo_wasted(_undo_wasted);




  26 #include "gc/shared/collectedHeap.hpp"
  27 #include "gc/shared/plab.inline.hpp"
  28 #include "gc/shared/threadLocalAllocBuffer.hpp"
  29 #include "logging/log.hpp"
  30 #include "oops/arrayOop.hpp"
  31 #include "oops/oop.inline.hpp"
  32 
  33 size_t PLAB::min_size() {
  34   // Make sure that we return something that is larger than AlignmentReserve
  35   return align_object_size(MAX2(MinTLABSize / HeapWordSize, (size_t)oopDesc::header_size())) + AlignmentReserve;
  36 }
  37 
  38 size_t PLAB::max_size() {
  39   return ThreadLocalAllocBuffer::max_size();
  40 }
  41 
  42 PLAB::PLAB(size_t desired_plab_sz_) :
  43   _word_sz(desired_plab_sz_), _bottom(NULL), _top(NULL),
  44   _end(NULL), _hard_end(NULL), _allocated(0), _wasted(0), _undo_wasted(0)
  45 {
  46   AlignmentReserve = Universe::heap()->tlab_alloc_reserve();

  47   assert(min_size() > AlignmentReserve,
  48          "Minimum PLAB size " SIZE_FORMAT " must be larger than alignment reserve " SIZE_FORMAT " "
  49          "to be able to contain objects", min_size(), AlignmentReserve);
  50 }
  51 
  52 // If the minimum object size is greater than MinObjAlignment, we can
  53 // end up with a shard at the end of the buffer that's smaller than
  54 // the smallest object.  We can't allow that because the buffer must
  55 // look like it's full of objects when we retire it, so we make
  56 // sure we have enough space for a filler int array object.
  57 size_t PLAB::AlignmentReserve;
  58 
  59 void PLAB::flush_and_retire_stats(PLABStats* stats) {
  60   // Retire the last allocation buffer.
  61   size_t unused = retire_internal();
  62 
  63   // Now flush the statistics.
  64   stats->add_allocated(_allocated);
  65   stats->add_wasted(_wasted);
  66   stats->add_undo_wasted(_undo_wasted);


< prev index next >