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