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

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

Print this page




 199   if (Universe::heap() != NULL) {
 200     size_t capacity   = Universe::heap()->tlab_capacity(myThread()) / HeapWordSize;
 201     double alloc_frac = desired_size() * target_refills() / (double) capacity;
 202     _allocation_fraction.sample(alloc_frac);
 203   }
 204 
 205   set_refill_waste_limit(initial_refill_waste_limit());
 206 
 207   initialize_statistics();
 208 }
 209 
 210 void ThreadLocalAllocBuffer::startup_initialization() {
 211 
 212   // Assuming each thread's active tlab is, on average,
 213   // 1/2 full at a GC
 214   _target_refills = 100 / (2 * TLABWasteTargetPercent);
 215   _target_refills = MAX2(_target_refills, (unsigned)1U);
 216 
 217   _global_stats = new GlobalTLABStats();
 218 
 219   // Need extra space at the end of TLAB, otherwise prefetching
 220   // instructions will fault (due to accessing memory outside of heap).


 221   // The amount of space is the max of the number of lines to
 222   // prefetch for array and for instance allocations. (Extra space must be
 223   // reserved to accommodate both types of allocations.)
 224   //
 225   // Only SPARC-specific BIS instructions are known to fault. (Those
 226   // instructions are generated if AllocatePrefetchStyle==3 and
 227   // AllocatePrefetchInstr==1). To be on the safe side, however,
 228   // extra space is reserved for all combinations of
 229   // AllocatePrefetchStyle and AllocatePrefetchInstr.


 230 
 231   // +1 for rounding up to next cache line, +1 to be safe
 232   int lines =  MAX2(AllocatePrefetchLines, AllocateInstancePrefetchLines) + 2;
 233   _reserve_for_allocation_prefetch = (AllocatePrefetchDistance + AllocatePrefetchStepSize * lines) /
 234                                      (int)HeapWordSize;

 235 
 236   // During jvm startup, the main (primordial) thread is initialized
 237   // before the heap is initialized.  So reinitialize it now.
 238   guarantee(Thread::current()->is_Java_thread(), "tlab initialization thread not Java thread");
 239   Thread::current()->tlab().initialize();
 240 
 241   log_develop_trace(gc, tlab)("TLAB min: " SIZE_FORMAT " initial: " SIZE_FORMAT " max: " SIZE_FORMAT,
 242                                min_size(), Thread::current()->tlab().initial_desired_size(), max_size());
 243 }
 244 
 245 size_t ThreadLocalAllocBuffer::initial_desired_size() {
 246   size_t init_sz = 0;
 247 
 248   if (TLABSize > 0) {
 249     init_sz = TLABSize / HeapWordSize;
 250   } else if (global_stats() != NULL) {
 251     // Initial size is a function of the average number of allocating threads.
 252     unsigned nof_threads = global_stats()->allocating_threads_avg();
 253 
 254     init_sz  = (Universe::heap()->tlab_capacity(myThread()) / HeapWordSize) /




 199   if (Universe::heap() != NULL) {
 200     size_t capacity   = Universe::heap()->tlab_capacity(myThread()) / HeapWordSize;
 201     double alloc_frac = desired_size() * target_refills() / (double) capacity;
 202     _allocation_fraction.sample(alloc_frac);
 203   }
 204 
 205   set_refill_waste_limit(initial_refill_waste_limit());
 206 
 207   initialize_statistics();
 208 }
 209 
 210 void ThreadLocalAllocBuffer::startup_initialization() {
 211 
 212   // Assuming each thread's active tlab is, on average,
 213   // 1/2 full at a GC
 214   _target_refills = 100 / (2 * TLABWasteTargetPercent);
 215   _target_refills = MAX2(_target_refills, (unsigned)1U);
 216 
 217   _global_stats = new GlobalTLABStats();
 218 
 219 #ifdef COMPILER2
 220   // If the C2 compiler is present, extra space is needed at the end of
 221   // TLABs, otherwise prefetching instructions generated by the C2
 222   // compiler will fault (due to accessing memory outside of heap).
 223   // The amount of space is the max of the number of lines to
 224   // prefetch for array and for instance allocations. (Extra space must be
 225   // reserved to accommodate both types of allocations.)
 226   //
 227   // Only SPARC-specific BIS instructions are known to fault. (Those
 228   // instructions are generated if AllocatePrefetchStyle==3 and
 229   // AllocatePrefetchInstr==1). To be on the safe side, however,
 230   // extra space is reserved for all combinations of
 231   // AllocatePrefetchStyle and AllocatePrefetchInstr.
 232   //
 233   // If the C2 compiler is not present, no space is reserved.
 234 
 235   // +1 for rounding up to next cache line, +1 to be safe
 236   int lines =  MAX2(AllocatePrefetchLines, AllocateInstancePrefetchLines) + 2;
 237   _reserve_for_allocation_prefetch = (AllocatePrefetchDistance + AllocatePrefetchStepSize * lines) /
 238                                      (int)HeapWordSize;
 239 #endif
 240 
 241   // During jvm startup, the main (primordial) thread is initialized
 242   // before the heap is initialized.  So reinitialize it now.
 243   guarantee(Thread::current()->is_Java_thread(), "tlab initialization thread not Java thread");
 244   Thread::current()->tlab().initialize();
 245 
 246   log_develop_trace(gc, tlab)("TLAB min: " SIZE_FORMAT " initial: " SIZE_FORMAT " max: " SIZE_FORMAT,
 247                                min_size(), Thread::current()->tlab().initial_desired_size(), max_size());
 248 }
 249 
 250 size_t ThreadLocalAllocBuffer::initial_desired_size() {
 251   size_t init_sz = 0;
 252 
 253   if (TLABSize > 0) {
 254     init_sz = TLABSize / HeapWordSize;
 255   } else if (global_stats() != NULL) {
 256     // Initial size is a function of the average number of allocating threads.
 257     unsigned nof_threads = global_stats()->allocating_threads_avg();
 258 
 259     init_sz  = (Universe::heap()->tlab_capacity(myThread()) / HeapWordSize) /


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