hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp

Print this page




 771           _survivor_chunk_array = NULL;
 772           _survivor_chunk_capacity = 0;
 773           break;
 774         } else {
 775           ChunkArray* cur =
 776             ::new (&_survivor_plab_array[i]) ChunkArray(vec,
 777                                                         max_plab_samples);
 778           assert(cur->end() == 0, "Should be 0");
 779           assert(cur->array() == vec, "Should be vec");
 780           assert(cur->capacity() == max_plab_samples, "Error");
 781         }
 782       }
 783     }
 784   }
 785   assert(   (   _survivor_plab_array  != NULL
 786              && _survivor_chunk_array != NULL)
 787          || (   _survivor_chunk_capacity == 0
 788              && _survivor_chunk_index == 0),
 789          "Error");
 790 
 791   // Choose what strong roots should be scanned depending on verification options


 792   if (!CMSClassUnloadingEnabled) {
 793     // If class unloading is disabled we want to include all classes into the root set.
 794     add_root_scanning_option(SharedHeap::SO_AllClasses);
 795   } else {
 796     add_root_scanning_option(SharedHeap::SO_SystemClasses);
 797   }
 798 
 799   NOT_PRODUCT(_overflow_counter = CMSMarkStackOverflowInterval;)
 800   _gc_counters = new CollectorCounters("CMS", 1);
 801   _completed_initialization = true;
 802   _inter_sweep_timer.start();  // start of time
 803 }
 804 
 805 const char* ConcurrentMarkSweepGeneration::name() const {
 806   return "concurrent mark-sweep generation";
 807 }
 808 void ConcurrentMarkSweepGeneration::update_counters() {
 809   if (UsePerfData) {
 810     _space_counters->update_all();
 811     _gen_counters->update_all();
 812   }
 813 }
 814 
 815 // this is an optimized version of update_counters(). it takes the
 816 // used value as a parameter rather than computing it.


3292   if (_full_gc_requested && ExplicitGCInvokesConcurrentAndUnloadsClasses) {
3293     _should_unload_classes = true;
3294   } else if (CMSClassUnloadingEnabled) { // Condition 2.a above
3295     // Disjuncts 2.b.(i,ii,iii) above
3296     _should_unload_classes = (concurrent_cycles_since_last_unload() >=
3297                               CMSClassUnloadingMaxInterval)
3298                            || _cmsGen->is_too_full();
3299   }
3300 }
3301 
3302 bool ConcurrentMarkSweepGeneration::is_too_full() const {
3303   bool res = should_concurrent_collect();
3304   res = res && (occupancy() > (double)CMSIsTooFullPercentage/100.0);
3305   return res;
3306 }
3307 
3308 void CMSCollector::setup_cms_unloading_and_verification_state() {
3309   const  bool should_verify =   VerifyBeforeGC || VerifyAfterGC || VerifyDuringGC
3310                              || VerifyBeforeExit;
3311   const  int  rso           =   SharedHeap::SO_Strings | SharedHeap::SO_CodeCache;











3312 
3313   if (should_unload_classes()) {   // Should unload classes this cycle
3314     remove_root_scanning_option(rso);  // Shrink the root set appropriately
3315     set_verifying(should_verify);    // Set verification state for this cycle
3316     return;                            // Nothing else needs to be done at this time
3317   }
3318 
3319   // Not unloading classes this cycle
3320   assert(!should_unload_classes(), "Inconsitency!");
3321   if ((!verifying() || unloaded_classes_last_cycle()) && should_verify) {
3322     // Include symbols, strings and code cache elements to prevent their resurrection.
3323     add_root_scanning_option(rso);
3324     set_verifying(true);
3325   } else if (verifying() && !should_verify) {
3326     // We were verifying, but some verification flags got disabled.
3327     set_verifying(false);
3328     // Exclude symbols, strings and code cache elements from root scanning to
3329     // reduce IM and RM pauses.
3330     remove_root_scanning_option(rso);
3331   }




 771           _survivor_chunk_array = NULL;
 772           _survivor_chunk_capacity = 0;
 773           break;
 774         } else {
 775           ChunkArray* cur =
 776             ::new (&_survivor_plab_array[i]) ChunkArray(vec,
 777                                                         max_plab_samples);
 778           assert(cur->end() == 0, "Should be 0");
 779           assert(cur->array() == vec, "Should be vec");
 780           assert(cur->capacity() == max_plab_samples, "Error");
 781         }
 782       }
 783     }
 784   }
 785   assert(   (   _survivor_plab_array  != NULL
 786              && _survivor_chunk_array != NULL)
 787          || (   _survivor_chunk_capacity == 0
 788              && _survivor_chunk_index == 0),
 789          "Error");
 790 
 791   // Choose what strong roots should be scanned depending on verification options.
 792   // If CMSClassUnloadingEnabled is on, root scanning option is set during
 793   // setup_cms_unloading_and_verification_state() on each CMS cycle.
 794   if (!CMSClassUnloadingEnabled) {
 795     // If class unloading is disabled we want to include all classes into the root set.
 796     add_root_scanning_option(SharedHeap::SO_AllClasses);


 797   }
 798 
 799   NOT_PRODUCT(_overflow_counter = CMSMarkStackOverflowInterval;)
 800   _gc_counters = new CollectorCounters("CMS", 1);
 801   _completed_initialization = true;
 802   _inter_sweep_timer.start();  // start of time
 803 }
 804 
 805 const char* ConcurrentMarkSweepGeneration::name() const {
 806   return "concurrent mark-sweep generation";
 807 }
 808 void ConcurrentMarkSweepGeneration::update_counters() {
 809   if (UsePerfData) {
 810     _space_counters->update_all();
 811     _gen_counters->update_all();
 812   }
 813 }
 814 
 815 // this is an optimized version of update_counters(). it takes the
 816 // used value as a parameter rather than computing it.


3292   if (_full_gc_requested && ExplicitGCInvokesConcurrentAndUnloadsClasses) {
3293     _should_unload_classes = true;
3294   } else if (CMSClassUnloadingEnabled) { // Condition 2.a above
3295     // Disjuncts 2.b.(i,ii,iii) above
3296     _should_unload_classes = (concurrent_cycles_since_last_unload() >=
3297                               CMSClassUnloadingMaxInterval)
3298                            || _cmsGen->is_too_full();
3299   }
3300 }
3301 
3302 bool ConcurrentMarkSweepGeneration::is_too_full() const {
3303   bool res = should_concurrent_collect();
3304   res = res && (occupancy() > (double)CMSIsTooFullPercentage/100.0);
3305   return res;
3306 }
3307 
3308 void CMSCollector::setup_cms_unloading_and_verification_state() {
3309   const  bool should_verify =   VerifyBeforeGC || VerifyAfterGC || VerifyDuringGC
3310                              || VerifyBeforeExit;
3311   const  int  rso           =   SharedHeap::SO_Strings | SharedHeap::SO_CodeCache;
3312 
3313   // We set the proper root for this CMS cycle here.
3314   // When class unloading is disabled, we set the default root scanning option
3315   // once in the CMSCollector constructor.
3316   if (CMSClassUnloadingEnabled) {
3317     if (should_unload_classes()) {
3318       set_root_scanning_option(SharedHeap::SO_SystemClasses);
3319     } else {
3320       set_root_scanning_option(SharedHeap::SO_AllClasses | rso);
3321     }
3322   }
3323 
3324   if (should_unload_classes()) {   // Should unload classes this cycle
3325     remove_root_scanning_option(rso);  // Shrink the root set appropriately
3326     set_verifying(should_verify);    // Set verification state for this cycle
3327     return;                            // Nothing else needs to be done at this time
3328   }
3329 
3330   // Not unloading classes this cycle
3331   assert(!should_unload_classes(), "Inconsitency!");
3332   if ((!verifying() || unloaded_classes_last_cycle()) && should_verify) {
3333     // Include symbols, strings and code cache elements to prevent their resurrection.
3334     add_root_scanning_option(rso);
3335     set_verifying(true);
3336   } else if (verifying() && !should_verify) {
3337     // We were verifying, but some verification flags got disabled.
3338     set_verifying(false);
3339     // Exclude symbols, strings and code cache elements from root scanning to
3340     // reduce IM and RM pauses.
3341     remove_root_scanning_option(rso);
3342   }