--- old/src/hotspot/share/gc/shared/collectedHeap.cpp 2018-05-02 11:23:00.452968049 +0200 +++ new/src/hotspot/share/gc/shared/collectedHeap.cpp 2018-05-02 11:23:00.084953489 +0200 @@ -384,17 +384,24 @@ 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 min_tlab_size = ThreadLocalAllocBuffer::compute_min_size(size); + HeapWord* obj = Universe::heap()->allocate_new_tlab(min_tlab_size, new_tlab_size, &actual_tlab_size); if (obj == NULL) { + assert(actual_tlab_size == 0, "Allocation failed, but actual size was updated. min: " SIZE_FORMAT ", desired: " SIZE_FORMAT ", actual: " SIZE_FORMAT, + min_tlab_size, new_tlab_size, actual_tlab_size); 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), min_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 @@ -402,10 +409,10 @@ // 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; } @@ -506,7 +513,9 @@ fill_with_object_impl(start, words, zap); } -HeapWord* CollectedHeap::allocate_new_tlab(size_t size) { +HeapWord* CollectedHeap::allocate_new_tlab(size_t min_size, + size_t requested_size, + size_t* actual_size) { guarantee(false, "thread-local allocation buffers not supported"); return NULL; }