< prev index next >

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

Print this page

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

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