371 _space_counters->update_all(_the_space->capacity(), _the_space->used());
372 _gen_counters->update_capacity(_virtual_space.committed_size());
373 }
374 }
375
376 bool TenuredGeneration::promotion_attempt_is_safe(size_t max_promotion_in_bytes) const {
377 size_t available = _the_space->free() + _virtual_space.uncommitted_size();
378
379 size_t avg_promoted = (size_t)_avg_promoted->padded_average();
380 size_t promotion_estimate = MIN2(avg_promoted, max_promotion_in_bytes);
381
382 bool res = (promotion_estimate <= available);
383
384 log_trace(gc)("Tenured: promo attempt is%s safe: available(%zu) %s av_promo(%zu), max_promo(%zu)",
385 res? "":" not", available, res? ">=":"<", avg_promoted, max_promotion_in_bytes);
386
387 return res;
388 }
389
390 oop TenuredGeneration::allocate_for_promotion(oop obj, size_t obj_size) {
391 assert(obj_size == obj->size(), "bad obj_size passed in");
392
393 #ifndef PRODUCT
394 if (SerialHeap::heap()->promotion_should_fail()) {
395 return nullptr;
396 }
397 #endif // #ifndef PRODUCT
398
399 // Allocate new object.
400 HeapWord* result = allocate(obj_size);
401 if (result == nullptr) {
402 // Promotion of obj into gen failed. Try to expand and allocate.
403 result = expand_and_allocate(obj_size);
404 }
405
406 return cast_to_oop<HeapWord*>(result);
407 }
408
409 HeapWord*
410 TenuredGeneration::expand_and_allocate(size_t word_size) {
411 expand(word_size*HeapWordSize, _min_heap_delta_bytes);
|
371 _space_counters->update_all(_the_space->capacity(), _the_space->used());
372 _gen_counters->update_capacity(_virtual_space.committed_size());
373 }
374 }
375
376 bool TenuredGeneration::promotion_attempt_is_safe(size_t max_promotion_in_bytes) const {
377 size_t available = _the_space->free() + _virtual_space.uncommitted_size();
378
379 size_t avg_promoted = (size_t)_avg_promoted->padded_average();
380 size_t promotion_estimate = MIN2(avg_promoted, max_promotion_in_bytes);
381
382 bool res = (promotion_estimate <= available);
383
384 log_trace(gc)("Tenured: promo attempt is%s safe: available(%zu) %s av_promo(%zu), max_promo(%zu)",
385 res? "":" not", available, res? ">=":"<", avg_promoted, max_promotion_in_bytes);
386
387 return res;
388 }
389
390 oop TenuredGeneration::allocate_for_promotion(oop obj, size_t obj_size) {
391 assert(obj_size == obj->size() || UseCompactObjectHeaders, "bad obj_size passed in");
392
393 #ifndef PRODUCT
394 if (SerialHeap::heap()->promotion_should_fail()) {
395 return nullptr;
396 }
397 #endif // #ifndef PRODUCT
398
399 // Allocate new object.
400 HeapWord* result = allocate(obj_size);
401 if (result == nullptr) {
402 // Promotion of obj into gen failed. Try to expand and allocate.
403 result = expand_and_allocate(obj_size);
404 }
405
406 return cast_to_oop<HeapWord*>(result);
407 }
408
409 HeapWord*
410 TenuredGeneration::expand_and_allocate(size_t word_size) {
411 expand(word_size*HeapWordSize, _min_heap_delta_bytes);
|