hotspot/src/share/vm/gc_interface/collectedHeap.cpp
changeset 22552 a29022212180
parent 21561 c619b1cb4554
child 23464 ae470a2efd44
--- a/hotspot/src/share/vm/gc_interface/collectedHeap.cpp	Thu Jan 23 14:47:23 2014 +0100
+++ b/hotspot/src/share/vm/gc_interface/collectedHeap.cpp	Mon Jan 27 13:14:53 2014 +0100
@@ -320,6 +320,21 @@
   assert(thread->deferred_card_mark().is_empty(), "invariant");
 }
 
+size_t CollectedHeap::max_tlab_size() const {
+  // TLABs can't be bigger than we can fill with a int[Integer.MAX_VALUE].
+  // This restriction could be removed by enabling filling with multiple arrays.
+  // If we compute that the reasonable way as
+  //    header_size + ((sizeof(jint) * max_jint) / HeapWordSize)
+  // we'll overflow on the multiply, so we do the divide first.
+  // We actually lose a little by dividing first,
+  // but that just makes the TLAB  somewhat smaller than the biggest array,
+  // which is fine, since we'll be able to fill that.
+  size_t max_int_size = typeArrayOopDesc::header_size(T_INT) +
+              sizeof(jint) *
+              ((juint) max_jint / (size_t) HeapWordSize);
+  return align_size_down(max_int_size, MinObjAlignment);
+}
+
 // Helper for ReduceInitialCardMarks. For performance,
 // compiled code may elide card-marks for initializing stores
 // to a newly allocated object along the fast-path. We