< prev index next >

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

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


   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_GC_SHARED_THREADLOCALALLOCBUFFER_HPP
  26 #define SHARE_VM_GC_SHARED_THREADLOCALALLOCBUFFER_HPP
  27 
  28 #include "gc/shared/gcUtil.hpp"
  29 #include "oops/typeArrayOop.hpp"
  30 #include "runtime/perfData.hpp"
  31 #include "runtime/vm_version.hpp"
  32 
  33 class ThreadLocalAllocStats;
  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 //
  41 //            Heap sampling is performed via the end and allocation_end
  42 //            fields.
  43 //            allocation_end contains the real end of the tlab allocation,
  44 //            whereas end can be set to an arbitrary spot in the tlab to
  45 //            trip the return and sample the allocation.
  46 class ThreadLocalAllocBuffer: public CHeapObj<mtThread> {
  47   friend class VMStructs;
  48   friend class JVMCIVMStructs;
  49 private:


 121   static size_t max_size_in_bytes()              { return max_size() * BytesPerWord; }
 122   static void set_max_size(size_t max_size)      { _max_size = max_size; }
 123 
 124   HeapWord* start() const                        { return _start; }
 125   HeapWord* end() const                          { return _end; }
 126   HeapWord* top() const                          { return _top; }
 127   HeapWord* hard_end();
 128   HeapWord* pf_top() const                       { return _pf_top; }
 129   size_t desired_size() const                    { return _desired_size; }
 130   size_t used() const                            { return pointer_delta(top(), start()); }
 131   size_t used_bytes() const                      { return pointer_delta(top(), start(), 1); }
 132   size_t free() const                            { return pointer_delta(end(), top()); }
 133   // Don't discard tlab if remaining space is larger than this.
 134   size_t refill_waste_limit() const              { return _refill_waste_limit; }
 135   size_t bytes_since_last_sample_point() const   { return _bytes_since_last_sample_point; }
 136 
 137   // Allocate size HeapWords. The memory is NOT initialized to zero.
 138   inline HeapWord* allocate(size_t size);
 139 
 140   // Reserve space at the end of TLAB
 141   static size_t end_reserve() {
 142     int reserve_size = typeArrayOopDesc::header_size(T_INT);
 143     return MAX2(reserve_size, _reserve_for_allocation_prefetch);
 144   }
 145   static size_t alignment_reserve()              { return align_object_size(end_reserve()); }
 146   static size_t alignment_reserve_in_bytes()     { return alignment_reserve() * HeapWordSize; }
 147 
 148   // Return tlab size or remaining space in eden such that the
 149   // space is large enough to hold obj_size and necessary fill space.
 150   // Otherwise return 0;
 151   inline size_t compute_size(size_t obj_size);
 152 
 153   // Compute the minimal needed tlab size for the given object size.
 154   static inline size_t compute_min_size(size_t obj_size);
 155 
 156   // Record slow allocation
 157   inline void record_slow_allocation(size_t obj_size);
 158 
 159   // Initialization at startup
 160   static void startup_initialization();
 161 
 162   // Make an in-use tlab parsable.
 163   void make_parsable();
 164 




   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_GC_SHARED_THREADLOCALALLOCBUFFER_HPP
  26 #define SHARE_VM_GC_SHARED_THREADLOCALALLOCBUFFER_HPP
  27 
  28 #include "gc/shared/gcUtil.hpp"

  29 #include "runtime/perfData.hpp"
  30 #include "runtime/vm_version.hpp"
  31 
  32 class ThreadLocalAllocStats;
  33 
  34 // ThreadLocalAllocBuffer: a descriptor for thread-local storage used by
  35 // the threads for allocation.
  36 //            It is thread-private at any time, but maybe multiplexed over
  37 //            time across multiple threads. The park()/unpark() pair is
  38 //            used to make it available for such multiplexing.
  39 //
  40 //            Heap sampling is performed via the end and allocation_end
  41 //            fields.
  42 //            allocation_end contains the real end of the tlab allocation,
  43 //            whereas end can be set to an arbitrary spot in the tlab to
  44 //            trip the return and sample the allocation.
  45 class ThreadLocalAllocBuffer: public CHeapObj<mtThread> {
  46   friend class VMStructs;
  47   friend class JVMCIVMStructs;
  48 private:


 120   static size_t max_size_in_bytes()              { return max_size() * BytesPerWord; }
 121   static void set_max_size(size_t max_size)      { _max_size = max_size; }
 122 
 123   HeapWord* start() const                        { return _start; }
 124   HeapWord* end() const                          { return _end; }
 125   HeapWord* top() const                          { return _top; }
 126   HeapWord* hard_end();
 127   HeapWord* pf_top() const                       { return _pf_top; }
 128   size_t desired_size() const                    { return _desired_size; }
 129   size_t used() const                            { return pointer_delta(top(), start()); }
 130   size_t used_bytes() const                      { return pointer_delta(top(), start(), 1); }
 131   size_t free() const                            { return pointer_delta(end(), top()); }
 132   // Don't discard tlab if remaining space is larger than this.
 133   size_t refill_waste_limit() const              { return _refill_waste_limit; }
 134   size_t bytes_since_last_sample_point() const   { return _bytes_since_last_sample_point; }
 135 
 136   // Allocate size HeapWords. The memory is NOT initialized to zero.
 137   inline HeapWord* allocate(size_t size);
 138 
 139   // Reserve space at the end of TLAB
 140   static size_t end_reserve();



 141   static size_t alignment_reserve()              { return align_object_size(end_reserve()); }
 142   static size_t alignment_reserve_in_bytes()     { return alignment_reserve() * HeapWordSize; }
 143 
 144   // Return tlab size or remaining space in eden such that the
 145   // space is large enough to hold obj_size and necessary fill space.
 146   // Otherwise return 0;
 147   inline size_t compute_size(size_t obj_size);
 148 
 149   // Compute the minimal needed tlab size for the given object size.
 150   static inline size_t compute_min_size(size_t obj_size);
 151 
 152   // Record slow allocation
 153   inline void record_slow_allocation(size_t obj_size);
 154 
 155   // Initialization at startup
 156   static void startup_initialization();
 157 
 158   // Make an in-use tlab parsable.
 159   void make_parsable();
 160 


< prev index next >