src/share/vm/memory/defNewGeneration.cpp

Print this page




 523   init_assuming_no_promotion_failure();
 524 
 525   TraceTime t1("GC", PrintGC && !PrintGCDetails, true, gclog_or_tty);
 526   // Capture heap used before collection (for printing).
 527   size_t gch_prev_used = gch->used();
 528 
 529   SpecializationStats::clear();
 530 
 531   // These can be shared for all code paths
 532   IsAliveClosure is_alive(this);
 533   ScanWeakRefClosure scan_weak_ref(this);
 534 
 535   age_table()->clear();
 536   to()->clear(SpaceDecorator::Mangle);
 537 
 538   gch->rem_set()->prepare_for_younger_refs_iterate(false);
 539 
 540   assert(gch->no_allocs_since_save_marks(0),
 541          "save marks have not been newly set.");
 542 
 543   // Weak refs.
 544   // FIXME: Are these storage leaks, or are they resource objects?
 545 #ifdef COMPILER2
 546   ReferencePolicy *soft_ref_policy = new LRUMaxHeapPolicy();
 547 #else
 548   ReferencePolicy *soft_ref_policy = new LRUCurrentHeapPolicy();
 549 #endif // COMPILER2
 550 
 551   // Not very pretty.
 552   CollectorPolicy* cp = gch->collector_policy();
 553 
 554   FastScanClosure fsc_with_no_gc_barrier(this, false);
 555   FastScanClosure fsc_with_gc_barrier(this, true);
 556 
 557   set_promo_failure_scan_stack_closure(&fsc_with_no_gc_barrier);
 558   FastEvacuateFollowersClosure evacuate_followers(gch, _level, this,
 559                                                   &fsc_with_no_gc_barrier,
 560                                                   &fsc_with_gc_barrier);
 561 
 562   assert(gch->no_allocs_since_save_marks(0),
 563          "save marks have not been newly set.");
 564 
 565   gch->gen_process_strong_roots(_level,
 566                                 true, // Process younger gens, if any, as
 567                                       // strong roots.
 568                                 false,// not collecting permanent generation.
 569                                 SharedHeap::SO_AllClasses,
 570                                 &fsc_with_gc_barrier,
 571                                 &fsc_with_no_gc_barrier);
 572 
 573   // "evacuate followers".
 574   evacuate_followers.do_void();
 575 
 576   FastKeepAliveClosure keep_alive(this, &scan_weak_ref);
 577   ref_processor()->process_discovered_references(
 578     soft_ref_policy, &is_alive, &keep_alive, &evacuate_followers, NULL);

 579   if (!promotion_failed()) {
 580     // Swap the survivor spaces.
 581     eden()->clear(SpaceDecorator::Mangle);
 582     from()->clear(SpaceDecorator::Mangle);
 583     if (ZapUnusedHeapArea) {
 584       // This is now done here because of the piece-meal mangling which
 585       // can check for valid mangling at intermediate points in the
 586       // collection(s).  When a minor collection fails to collect
 587       // sufficient space resizing of the young generation can occur
 588       // an redistribute the spaces in the young generation.  Mangle
 589       // here so that unzapped regions don't get distributed to
 590       // other spaces.
 591       to()->mangle_unused_area();
 592     }
 593     swap_spaces();
 594 
 595     assert(to()->is_empty(), "to space should be empty now");
 596 
 597     // Set the desired survivor size to half the real survivor space
 598     _tenuring_threshold =




 523   init_assuming_no_promotion_failure();
 524 
 525   TraceTime t1("GC", PrintGC && !PrintGCDetails, true, gclog_or_tty);
 526   // Capture heap used before collection (for printing).
 527   size_t gch_prev_used = gch->used();
 528 
 529   SpecializationStats::clear();
 530 
 531   // These can be shared for all code paths
 532   IsAliveClosure is_alive(this);
 533   ScanWeakRefClosure scan_weak_ref(this);
 534 
 535   age_table()->clear();
 536   to()->clear(SpaceDecorator::Mangle);
 537 
 538   gch->rem_set()->prepare_for_younger_refs_iterate(false);
 539 
 540   assert(gch->no_allocs_since_save_marks(0),
 541          "save marks have not been newly set.");
 542 








 543   // Not very pretty.
 544   CollectorPolicy* cp = gch->collector_policy();
 545 
 546   FastScanClosure fsc_with_no_gc_barrier(this, false);
 547   FastScanClosure fsc_with_gc_barrier(this, true);
 548 
 549   set_promo_failure_scan_stack_closure(&fsc_with_no_gc_barrier);
 550   FastEvacuateFollowersClosure evacuate_followers(gch, _level, this,
 551                                                   &fsc_with_no_gc_barrier,
 552                                                   &fsc_with_gc_barrier);
 553 
 554   assert(gch->no_allocs_since_save_marks(0),
 555          "save marks have not been newly set.");
 556 
 557   gch->gen_process_strong_roots(_level,
 558                                 true, // Process younger gens, if any, as
 559                                       // strong roots.
 560                                 false,// not collecting permanent generation.
 561                                 SharedHeap::SO_AllClasses,
 562                                 &fsc_with_gc_barrier,
 563                                 &fsc_with_no_gc_barrier);
 564 
 565   // "evacuate followers".
 566   evacuate_followers.do_void();
 567 
 568   FastKeepAliveClosure keep_alive(this, &scan_weak_ref);
 569   ReferenceProcessor* rp = ref_processor();
 570   rp->snap_policy(clear_all_soft_refs);
 571   rp->process_discovered_references(&is_alive, &keep_alive, &evacuate_followers, NULL);
 572   if (!promotion_failed()) {
 573     // Swap the survivor spaces.
 574     eden()->clear(SpaceDecorator::Mangle);
 575     from()->clear(SpaceDecorator::Mangle);
 576     if (ZapUnusedHeapArea) {
 577       // This is now done here because of the piece-meal mangling which
 578       // can check for valid mangling at intermediate points in the
 579       // collection(s).  When a minor collection fails to collect
 580       // sufficient space resizing of the young generation can occur
 581       // an redistribute the spaces in the young generation.  Mangle
 582       // here so that unzapped regions don't get distributed to
 583       // other spaces.
 584       to()->mangle_unused_area();
 585     }
 586     swap_spaces();
 587 
 588     assert(to()->is_empty(), "to space should be empty now");
 589 
 590     // Set the desired survivor size to half the real survivor space
 591     _tenuring_threshold =