@@ -313,12 +313,6 @@ bool PSScavenge::invoke(bool clear_soft_refs) {
313313 assert (SafepointSynchronize::is_at_safepoint (), " should be at safepoint" );
314314 assert (Thread::current () == (Thread*)VMThread::vm_thread (), " should be in vm thread" );
315315
316- // Check for potential problems.
317- if (!should_attempt_scavenge ()) {
318- log_info (gc, ergo)(" Young-gc might fail so skipping" );
319- return false ;
320- }
321-
322316 IsSTWGCActiveMark mark;
323317
324318 _gc_timer.register_gc_start ();
@@ -336,8 +330,7 @@ bool PSScavenge::invoke(bool clear_soft_refs) {
336330 PSOldGen* old_gen = heap->old_gen ();
337331 PSAdaptiveSizePolicy* size_policy = heap->size_policy ();
338332
339- assert (young_gen->to_space ()->is_empty (),
340- " Attempt to scavenge with live objects in to_space" );
333+ assert (young_gen->to_space ()->is_empty (), " precondition" );
341334
342335 heap->increment_total_collections ();
343336
@@ -520,59 +513,6 @@ void PSScavenge::clean_up_failed_promotion() {
520513 NOT_PRODUCT (ParallelScavengeHeap::heap ()->reset_promotion_should_fail ();)
521514}
522515
523- bool PSScavenge::should_attempt_scavenge () {
524- const bool ShouldRunYoungGC = true ;
525- const bool ShouldRunFullGC = false ;
526-
527- ParallelScavengeHeap* heap = ParallelScavengeHeap::heap ();
528- PSYoungGen* young_gen = heap->young_gen ();
529- PSOldGen* old_gen = heap->old_gen ();
530-
531- if (!young_gen->to_space ()->is_empty ()) {
532- log_debug (gc, ergo)(" To-space is not empty; run full-gc instead." );
533- return ShouldRunFullGC;
534- }
535-
536- // Check if the predicted promoted bytes will overflow free space in old-gen.
537- PSAdaptiveSizePolicy* policy = heap->size_policy ();
538-
539- size_t avg_promoted = (size_t ) policy->padded_average_promoted_in_bytes ();
540- size_t promotion_estimate = MIN2 (avg_promoted, young_gen->used_in_bytes ());
541- // Total free size after possible old gen expansion
542- size_t free_in_old_gen_with_expansion = old_gen->max_gen_size () - old_gen->used_in_bytes ();
543-
544- log_trace (gc, ergo)(" average_promoted %zu; padded_average_promoted %zu" ,
545- (size_t ) policy->average_promoted_in_bytes (),
546- (size_t ) policy->padded_average_promoted_in_bytes ());
547-
548- if (promotion_estimate >= free_in_old_gen_with_expansion) {
549- log_debug (gc, ergo)(" Run full-gc; predicted promotion size >= max free space in old-gen: %zu >= %zu" ,
550- promotion_estimate, free_in_old_gen_with_expansion);
551- return ShouldRunFullGC;
552- }
553-
554- if (UseAdaptiveSizePolicy) {
555- // Also checking OS has enough free memory to commit and expand old-gen.
556- // Otherwise, the recorded gc-pause-time might be inflated to include time
557- // of OS preparing free memory, resulting in inaccurate young-gen resizing.
558- assert (old_gen->committed ().byte_size () >= old_gen->used_in_bytes (), " inv" );
559- // Use uint64_t instead of size_t for 32bit compatibility.
560- uint64_t free_mem_in_os;
561- if (os::free_memory (free_mem_in_os)) {
562- size_t actual_free = (size_t )MIN2 (old_gen->committed ().byte_size () - old_gen->used_in_bytes () + free_mem_in_os,
563- (uint64_t )SIZE_MAX);
564- if (promotion_estimate > actual_free) {
565- log_debug (gc, ergo)(" Run full-gc; predicted promotion size > free space in old-gen and OS: %zu > %zu" ,
566- promotion_estimate, actual_free);
567- return ShouldRunFullGC;
568- }
569- }
570- }
571-
572- // No particular reasons to run full-gc, so young-gc.
573- return ShouldRunYoungGC;
574- }
575-
576516// Adaptive size policy support.
577517void PSScavenge::set_young_generation_boundary (HeapWord* v) {
578518 _young_generation_boundary = v;
0 commit comments