< prev index next >

src/hotspot/share/gc/serial/tenuredGeneration.cpp

Print this page

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

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