src/share/vm/gc/shared/threadLocalAllocBuffer.hpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File 8153340 Sdiff src/share/vm/gc/shared

src/share/vm/gc/shared/threadLocalAllocBuffer.hpp

Print this page




  33 class GlobalTLABStats;
  34 
  35 // ThreadLocalAllocBuffer: a descriptor for thread-local storage used by
  36 // the threads for allocation.
  37 //            It is thread-private at any time, but maybe multiplexed over
  38 //            time across multiple threads. The park()/unpark() pair is
  39 //            used to make it available for such multiplexing.
  40 class ThreadLocalAllocBuffer: public CHeapObj<mtThread> {
  41   friend class VMStructs;
  42   friend class JVMCIVMStructs;
  43 private:
  44   HeapWord* _start;                              // address of TLAB
  45   HeapWord* _top;                                // address after last allocation
  46   HeapWord* _pf_top;                             // allocation prefetch watermark
  47   HeapWord* _end;                                // allocation end (excluding alignment_reserve)
  48   size_t    _desired_size;                       // desired size   (including alignment_reserve)
  49   size_t    _refill_waste_limit;                 // hold onto tlab if free() is larger than this
  50   size_t    _allocated_before_last_gc;           // total bytes allocated up until the last gc
  51 
  52   static size_t   _max_size;                     // maximum size of any TLAB

  53   static unsigned _target_refills;               // expected number of refills between GCs
  54 
  55   unsigned  _number_of_refills;
  56   unsigned  _fast_refill_waste;
  57   unsigned  _slow_refill_waste;
  58   unsigned  _gc_waste;
  59   unsigned  _slow_allocations;
  60 
  61   AdaptiveWeightedAverage _allocation_fraction;  // fraction of eden allocated in tlabs
  62 
  63   void accumulate_statistics();
  64   void initialize_statistics();
  65 
  66   void set_start(HeapWord* start)                { _start = start; }
  67   void set_end(HeapWord* end)                    { _end = end; }
  68   void set_top(HeapWord* top)                    { _top = top; }
  69   void set_pf_top(HeapWord* pf_top)              { _pf_top = pf_top; }
  70   void set_desired_size(size_t desired_size)     { _desired_size = desired_size; }
  71   void set_refill_waste_limit(size_t waste)      { _refill_waste_limit = waste;  }
  72 


 112   static void set_max_size(size_t max_size)      { _max_size = max_size; }
 113 
 114   HeapWord* start() const                        { return _start; }
 115   HeapWord* end() const                          { return _end; }
 116   HeapWord* hard_end() const                     { return _end + alignment_reserve(); }
 117   HeapWord* top() const                          { return _top; }
 118   HeapWord* pf_top() const                       { return _pf_top; }
 119   size_t desired_size() const                    { return _desired_size; }
 120   size_t used() const                            { return pointer_delta(top(), start()); }
 121   size_t used_bytes() const                      { return pointer_delta(top(), start(), 1); }
 122   size_t free() const                            { return pointer_delta(end(), top()); }
 123   // Don't discard tlab if remaining space is larger than this.
 124   size_t refill_waste_limit() const              { return _refill_waste_limit; }
 125 
 126   // Allocate size HeapWords. The memory is NOT initialized to zero.
 127   inline HeapWord* allocate(size_t size);
 128 
 129   // Reserve space at the end of TLAB
 130   static size_t end_reserve() {
 131     int reserve_size = typeArrayOopDesc::header_size(T_INT);
 132     return MAX2(reserve_size, VM_Version::reserve_for_allocation_prefetch());
 133   }
 134   static size_t alignment_reserve()              { return align_object_size(end_reserve()); }
 135   static size_t alignment_reserve_in_bytes()     { return alignment_reserve() * HeapWordSize; }
 136 
 137   // Return tlab size or remaining space in eden such that the
 138   // space is large enough to hold obj_size and necessary fill space.
 139   // Otherwise return 0;
 140   inline size_t compute_size(size_t obj_size);
 141 
 142   // Record slow allocation
 143   inline void record_slow_allocation(size_t obj_size);
 144 
 145   // Initialization at startup
 146   static void startup_initialization();
 147 
 148   // Make an in-use tlab parsable, optionally retiring and/or zapping it.
 149   void make_parsable(bool retire, bool zap = true);
 150 
 151   // Retire in-use tlab before allocation of a new tlab
 152   void clear_before_allocation();




  33 class GlobalTLABStats;
  34 
  35 // ThreadLocalAllocBuffer: a descriptor for thread-local storage used by
  36 // the threads for allocation.
  37 //            It is thread-private at any time, but maybe multiplexed over
  38 //            time across multiple threads. The park()/unpark() pair is
  39 //            used to make it available for such multiplexing.
  40 class ThreadLocalAllocBuffer: public CHeapObj<mtThread> {
  41   friend class VMStructs;
  42   friend class JVMCIVMStructs;
  43 private:
  44   HeapWord* _start;                              // address of TLAB
  45   HeapWord* _top;                                // address after last allocation
  46   HeapWord* _pf_top;                             // allocation prefetch watermark
  47   HeapWord* _end;                                // allocation end (excluding alignment_reserve)
  48   size_t    _desired_size;                       // desired size   (including alignment_reserve)
  49   size_t    _refill_waste_limit;                 // hold onto tlab if free() is larger than this
  50   size_t    _allocated_before_last_gc;           // total bytes allocated up until the last gc
  51 
  52   static size_t   _max_size;                          // maximum size of any TLAB
  53   static int      _reserve_for_allocation_prefetch;   // Reserve at the end of the TLAB
  54   static unsigned _target_refills;                    // expected number of refills between GCs
  55 
  56   unsigned  _number_of_refills;
  57   unsigned  _fast_refill_waste;
  58   unsigned  _slow_refill_waste;
  59   unsigned  _gc_waste;
  60   unsigned  _slow_allocations;
  61 
  62   AdaptiveWeightedAverage _allocation_fraction;  // fraction of eden allocated in tlabs
  63 
  64   void accumulate_statistics();
  65   void initialize_statistics();
  66 
  67   void set_start(HeapWord* start)                { _start = start; }
  68   void set_end(HeapWord* end)                    { _end = end; }
  69   void set_top(HeapWord* top)                    { _top = top; }
  70   void set_pf_top(HeapWord* pf_top)              { _pf_top = pf_top; }
  71   void set_desired_size(size_t desired_size)     { _desired_size = desired_size; }
  72   void set_refill_waste_limit(size_t waste)      { _refill_waste_limit = waste;  }
  73 


 113   static void set_max_size(size_t max_size)      { _max_size = max_size; }
 114 
 115   HeapWord* start() const                        { return _start; }
 116   HeapWord* end() const                          { return _end; }
 117   HeapWord* hard_end() const                     { return _end + alignment_reserve(); }
 118   HeapWord* top() const                          { return _top; }
 119   HeapWord* pf_top() const                       { return _pf_top; }
 120   size_t desired_size() const                    { return _desired_size; }
 121   size_t used() const                            { return pointer_delta(top(), start()); }
 122   size_t used_bytes() const                      { return pointer_delta(top(), start(), 1); }
 123   size_t free() const                            { return pointer_delta(end(), top()); }
 124   // Don't discard tlab if remaining space is larger than this.
 125   size_t refill_waste_limit() const              { return _refill_waste_limit; }
 126 
 127   // Allocate size HeapWords. The memory is NOT initialized to zero.
 128   inline HeapWord* allocate(size_t size);
 129 
 130   // Reserve space at the end of TLAB
 131   static size_t end_reserve() {
 132     int reserve_size = typeArrayOopDesc::header_size(T_INT);
 133     return MAX2(reserve_size, _reserve_for_allocation_prefetch);
 134   }
 135   static size_t alignment_reserve()              { return align_object_size(end_reserve()); }
 136   static size_t alignment_reserve_in_bytes()     { return alignment_reserve() * HeapWordSize; }
 137 
 138   // Return tlab size or remaining space in eden such that the
 139   // space is large enough to hold obj_size and necessary fill space.
 140   // Otherwise return 0;
 141   inline size_t compute_size(size_t obj_size);
 142 
 143   // Record slow allocation
 144   inline void record_slow_allocation(size_t obj_size);
 145 
 146   // Initialization at startup
 147   static void startup_initialization();
 148 
 149   // Make an in-use tlab parsable, optionally retiring and/or zapping it.
 150   void make_parsable(bool retire, bool zap = true);
 151 
 152   // Retire in-use tlab before allocation of a new tlab
 153   void clear_before_allocation();


src/share/vm/gc/shared/threadLocalAllocBuffer.hpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File