< prev index next >

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

Print this page
rev 49851 : imported patch 8191471-g1-varying-tlab-allocation
rev 49852 : imported patch 8191471-g1-retained-mutator-region

@@ -366,32 +366,37 @@
 
   if (new_tlab_size == 0) {
     return NULL;
   }
 
-  // Allocate a new TLAB...
-  HeapWord* obj = Universe::heap()->allocate_new_tlab(new_tlab_size);
+  // Allocate a new TLAB requesting new_tlab_size. Any size
+  // between minimal and new_tlab_size is accepted.
+  size_t actual_tlab_size = 0;
+  size_t minimal_tlab_size = MAX2(ThreadLocalAllocBuffer::compute_min_size(size), MinTLABSize);
+  HeapWord* obj = Universe::heap()->allocate_new_tlab(minimal_tlab_size, new_tlab_size, &actual_tlab_size);
   if (obj == NULL) {
     return NULL;
   }
+  assert(actual_tlab_size != 0, "Allocation succeeded but actual size not updated. obj at: " PTR_FORMAT " min: " SIZE_FORMAT ", desired: " SIZE_FORMAT,
+         p2i(obj), minimal_tlab_size, new_tlab_size);
 
-  AllocTracer::send_allocation_in_new_tlab(klass, obj, new_tlab_size * HeapWordSize, size * HeapWordSize, thread);
+  AllocTracer::send_allocation_in_new_tlab(klass, obj, actual_tlab_size * HeapWordSize, size * HeapWordSize, thread);
 
   if (ZeroTLAB) {
     // ..and clear it.
-    Copy::zero_to_words(obj, new_tlab_size);
+    Copy::zero_to_words(obj, actual_tlab_size);
   } else {
     // ...and zap just allocated object.
 #ifdef ASSERT
     // Skip mangling the space corresponding to the object header to
     // ensure that the returned space is not considered parsable by
     // any concurrent GC thread.
     size_t hdr_size = oopDesc::header_size();
-    Copy::fill_to_words(obj + hdr_size, new_tlab_size - hdr_size, badHeapWordVal);
+    Copy::fill_to_words(obj + hdr_size, actual_tlab_size - hdr_size, badHeapWordVal);
 #endif // ASSERT
   }
-  thread->tlab().fill(obj, obj + size, new_tlab_size);
+  thread->tlab().fill(obj, obj + size, actual_tlab_size);
   return obj;
 }
 
 size_t CollectedHeap::max_tlab_size() const {
   // TLABs can't be bigger than we can fill with a int[Integer.MAX_VALUE].

@@ -488,11 +493,13 @@
   }
 
   fill_with_object_impl(start, words, zap);
 }
 
-HeapWord* CollectedHeap::allocate_new_tlab(size_t size) {
+HeapWord* CollectedHeap::allocate_new_tlab(size_t min_word_size,
+                                           size_t desired_word_size,
+                                           size_t* actual_word_size) {
   guarantee(false, "thread-local allocation buffers not supported");
   return NULL;
 }
 
 void CollectedHeap::ensure_parsability(bool retire_tlabs) {
< prev index next >