303 // point was put and the TLAB still has space.
304 tlab.set_back_allocation_end();
305 mem = tlab.allocate(_word_size);
306 if (mem != NULL) {
307 allocation._tlab_end_reset_for_sample = true;
308 return mem;
309 }
310 }
311
312 // Retain tlab and allocate object in shared space if
313 // the amount free in the tlab is too large to discard.
314 if (tlab.free() > tlab.refill_waste_limit()) {
315 tlab.record_slow_allocation(_word_size);
316 return NULL;
317 }
318
319 // Discard tlab and allocate a new one.
320 // To minimize fragmentation, the last TLAB may be smaller than the rest.
321 size_t new_tlab_size = tlab.compute_size(_word_size);
322
323 tlab.clear_before_allocation();
324
325 if (new_tlab_size == 0) {
326 return NULL;
327 }
328
329 // Allocate a new TLAB requesting new_tlab_size. Any size
330 // between minimal and new_tlab_size is accepted.
331 size_t min_tlab_size = ThreadLocalAllocBuffer::compute_min_size(_word_size);
332 mem = _heap->allocate_new_tlab(min_tlab_size, new_tlab_size, &allocation._allocated_tlab_size);
333 if (mem == NULL) {
334 assert(allocation._allocated_tlab_size == 0,
335 "Allocation failed, but actual size was updated. min: " SIZE_FORMAT
336 ", desired: " SIZE_FORMAT ", actual: " SIZE_FORMAT,
337 min_tlab_size, new_tlab_size, allocation._allocated_tlab_size);
338 return NULL;
339 }
340 assert(allocation._allocated_tlab_size != 0, "Allocation succeeded but actual size not updated. mem at: "
341 PTR_FORMAT " min: " SIZE_FORMAT ", desired: " SIZE_FORMAT,
342 p2i(mem), min_tlab_size, new_tlab_size);
343
|
303 // point was put and the TLAB still has space.
304 tlab.set_back_allocation_end();
305 mem = tlab.allocate(_word_size);
306 if (mem != NULL) {
307 allocation._tlab_end_reset_for_sample = true;
308 return mem;
309 }
310 }
311
312 // Retain tlab and allocate object in shared space if
313 // the amount free in the tlab is too large to discard.
314 if (tlab.free() > tlab.refill_waste_limit()) {
315 tlab.record_slow_allocation(_word_size);
316 return NULL;
317 }
318
319 // Discard tlab and allocate a new one.
320 // To minimize fragmentation, the last TLAB may be smaller than the rest.
321 size_t new_tlab_size = tlab.compute_size(_word_size);
322
323 tlab.retire_before_allocation();
324
325 if (new_tlab_size == 0) {
326 return NULL;
327 }
328
329 // Allocate a new TLAB requesting new_tlab_size. Any size
330 // between minimal and new_tlab_size is accepted.
331 size_t min_tlab_size = ThreadLocalAllocBuffer::compute_min_size(_word_size);
332 mem = _heap->allocate_new_tlab(min_tlab_size, new_tlab_size, &allocation._allocated_tlab_size);
333 if (mem == NULL) {
334 assert(allocation._allocated_tlab_size == 0,
335 "Allocation failed, but actual size was updated. min: " SIZE_FORMAT
336 ", desired: " SIZE_FORMAT ", actual: " SIZE_FORMAT,
337 min_tlab_size, new_tlab_size, allocation._allocated_tlab_size);
338 return NULL;
339 }
340 assert(allocation._allocated_tlab_size != 0, "Allocation succeeded but actual size not updated. mem at: "
341 PTR_FORMAT " min: " SIZE_FORMAT ", desired: " SIZE_FORMAT,
342 p2i(mem), min_tlab_size, new_tlab_size);
343
|