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

Print this page

        

*** 786,801 **** && _survivor_chunk_array != NULL) || ( _survivor_chunk_capacity == 0 && _survivor_chunk_index == 0), "Error"); ! // Choose what strong roots should be scanned depending on verification options if (!CMSClassUnloadingEnabled) { // If class unloading is disabled we want to include all classes into the root set. add_root_scanning_option(SharedHeap::SO_AllClasses); - } else { - add_root_scanning_option(SharedHeap::SO_SystemClasses); } NOT_PRODUCT(_overflow_counter = CMSMarkStackOverflowInterval;) _gc_counters = new CollectorCounters("CMS", 1); _completed_initialization = true; --- 786,801 ---- && _survivor_chunk_array != NULL) || ( _survivor_chunk_capacity == 0 && _survivor_chunk_index == 0), "Error"); ! // Choose what strong roots should be scanned depending on verification options. ! // If CMSClassUnloadingEnabled is on, root scanning option is set during ! // setup_cms_unloading_and_verification_state() on each CMS cycle. if (!CMSClassUnloadingEnabled) { // If class unloading is disabled we want to include all classes into the root set. add_root_scanning_option(SharedHeap::SO_AllClasses); } NOT_PRODUCT(_overflow_counter = CMSMarkStackOverflowInterval;) _gc_counters = new CollectorCounters("CMS", 1); _completed_initialization = true;
*** 3308,3317 **** --- 3308,3328 ---- void CMSCollector::setup_cms_unloading_and_verification_state() { const bool should_verify = VerifyBeforeGC || VerifyAfterGC || VerifyDuringGC || VerifyBeforeExit; const int rso = SharedHeap::SO_Strings | SharedHeap::SO_CodeCache; + // We set the proper root for this CMS cycle here. + // When class unloading is disabled, we set the default root scanning option + // once in the CMSCollector constructor. + if (CMSClassUnloadingEnabled) { + if (should_unload_classes()) { + set_root_scanning_option(SharedHeap::SO_SystemClasses); + } else { + set_root_scanning_option(SharedHeap::SO_AllClasses | rso); + } + } + if (should_unload_classes()) { // Should unload classes this cycle remove_root_scanning_option(rso); // Shrink the root set appropriately set_verifying(should_verify); // Set verification state for this cycle return; // Nothing else needs to be done at this time }