596 _verification_mark_bm(0, Mutex::leaf + 1, "CMS_verification_mark_bm_lock"), |
596 _verification_mark_bm(0, Mutex::leaf + 1, "CMS_verification_mark_bm_lock"), |
597 _completed_initialization(false), |
597 _completed_initialization(false), |
598 _collector_policy(cp), |
598 _collector_policy(cp), |
599 _should_unload_classes(CMSClassUnloadingEnabled), |
599 _should_unload_classes(CMSClassUnloadingEnabled), |
600 _concurrent_cycles_since_last_unload(0), |
600 _concurrent_cycles_since_last_unload(0), |
601 _roots_scanning_options(SharedHeap::SO_None), |
601 _roots_scanning_options(GenCollectedHeap::SO_None), |
602 _inter_sweep_estimate(CMS_SweepWeight, CMS_SweepPadding), |
602 _inter_sweep_estimate(CMS_SweepWeight, CMS_SweepPadding), |
603 _intra_sweep_estimate(CMS_SweepWeight, CMS_SweepPadding), |
603 _intra_sweep_estimate(CMS_SweepWeight, CMS_SweepPadding), |
604 _gc_tracer_cm(new (ResourceObj::C_HEAP, mtGC) CMSTracer()), |
604 _gc_tracer_cm(new (ResourceObj::C_HEAP, mtGC) CMSTracer()), |
605 _gc_timer_cm(new (ResourceObj::C_HEAP, mtGC) ConcurrentGCTimer()), |
605 _gc_timer_cm(new (ResourceObj::C_HEAP, mtGC) ConcurrentGCTimer()), |
606 _cms_start_registered(false) |
606 _cms_start_registered(false) |
3066 gch->rem_set()->prepare_for_younger_refs_iterate(false); // Not parallel. |
3066 gch->rem_set()->prepare_for_younger_refs_iterate(false); // Not parallel. |
3067 |
3067 |
3068 gch->gen_process_roots(_cmsGen->level(), |
3068 gch->gen_process_roots(_cmsGen->level(), |
3069 true, // younger gens are roots |
3069 true, // younger gens are roots |
3070 true, // activate StrongRootsScope |
3070 true, // activate StrongRootsScope |
3071 SharedHeap::ScanningOption(roots_scanning_options()), |
3071 GenCollectedHeap::ScanningOption(roots_scanning_options()), |
3072 should_unload_classes(), |
3072 should_unload_classes(), |
3073 ¬Older, |
3073 ¬Older, |
3074 NULL, |
3074 NULL, |
3075 NULL); // SSS: Provide correct closure |
3075 NULL); // SSS: Provide correct closure |
3076 |
3076 |
3134 gch->rem_set()->prepare_for_younger_refs_iterate(false); // Not parallel. |
3134 gch->rem_set()->prepare_for_younger_refs_iterate(false); // Not parallel. |
3135 |
3135 |
3136 gch->gen_process_roots(_cmsGen->level(), |
3136 gch->gen_process_roots(_cmsGen->level(), |
3137 true, // younger gens are roots |
3137 true, // younger gens are roots |
3138 true, // activate StrongRootsScope |
3138 true, // activate StrongRootsScope |
3139 SharedHeap::ScanningOption(roots_scanning_options()), |
3139 GenCollectedHeap::ScanningOption(roots_scanning_options()), |
3140 should_unload_classes(), |
3140 should_unload_classes(), |
3141 ¬Older, |
3141 ¬Older, |
3142 NULL, |
3142 NULL, |
3143 &cld_closure); |
3143 &cld_closure); |
3144 |
3144 |
3325 } |
3325 } |
3326 |
3326 |
3327 void CMSCollector::setup_cms_unloading_and_verification_state() { |
3327 void CMSCollector::setup_cms_unloading_and_verification_state() { |
3328 const bool should_verify = VerifyBeforeGC || VerifyAfterGC || VerifyDuringGC |
3328 const bool should_verify = VerifyBeforeGC || VerifyAfterGC || VerifyDuringGC |
3329 || VerifyBeforeExit; |
3329 || VerifyBeforeExit; |
3330 const int rso = SharedHeap::SO_AllCodeCache; |
3330 const int rso = GenCollectedHeap::SO_AllCodeCache; |
3331 |
3331 |
3332 // We set the proper root for this CMS cycle here. |
3332 // We set the proper root for this CMS cycle here. |
3333 if (should_unload_classes()) { // Should unload classes this cycle |
3333 if (should_unload_classes()) { // Should unload classes this cycle |
3334 remove_root_scanning_option(rso); // Shrink the root set appropriately |
3334 remove_root_scanning_option(rso); // Shrink the root set appropriately |
3335 set_verifying(should_verify); // Set verification state for this cycle |
3335 set_verifying(should_verify); // Set verification state for this cycle |
3751 CLDToOopClosure cld_closure(¬Older, true); |
3751 CLDToOopClosure cld_closure(¬Older, true); |
3752 gch->rem_set()->prepare_for_younger_refs_iterate(false); // Not parallel. |
3752 gch->rem_set()->prepare_for_younger_refs_iterate(false); // Not parallel. |
3753 gch->gen_process_roots(_cmsGen->level(), |
3753 gch->gen_process_roots(_cmsGen->level(), |
3754 true, // younger gens are roots |
3754 true, // younger gens are roots |
3755 true, // activate StrongRootsScope |
3755 true, // activate StrongRootsScope |
3756 SharedHeap::ScanningOption(roots_scanning_options()), |
3756 GenCollectedHeap::ScanningOption(roots_scanning_options()), |
3757 should_unload_classes(), |
3757 should_unload_classes(), |
3758 ¬Older, |
3758 ¬Older, |
3759 NULL, |
3759 NULL, |
3760 &cld_closure); |
3760 &cld_closure); |
3761 } |
3761 } |
5252 CLDToOopClosure cld_closure(&par_mri_cl, true); |
5252 CLDToOopClosure cld_closure(&par_mri_cl, true); |
5253 |
5253 |
5254 gch->gen_process_roots(_collector->_cmsGen->level(), |
5254 gch->gen_process_roots(_collector->_cmsGen->level(), |
5255 false, // yg was scanned above |
5255 false, // yg was scanned above |
5256 false, // this is parallel code |
5256 false, // this is parallel code |
5257 SharedHeap::ScanningOption(_collector->CMSCollector::roots_scanning_options()), |
5257 GenCollectedHeap::ScanningOption(_collector->CMSCollector::roots_scanning_options()), |
5258 _collector->should_unload_classes(), |
5258 _collector->should_unload_classes(), |
5259 &par_mri_cl, |
5259 &par_mri_cl, |
5260 NULL, |
5260 NULL, |
5261 &cld_closure); |
5261 &cld_closure); |
5262 assert(_collector->should_unload_classes() |
5262 assert(_collector->should_unload_classes() |
5263 || (_collector->CMSCollector::roots_scanning_options() & SharedHeap::SO_AllCodeCache), |
5263 || (_collector->CMSCollector::roots_scanning_options() & GenCollectedHeap::SO_AllCodeCache), |
5264 "if we didn't scan the code cache, we have to be ready to drop nmethods with expired weak oops"); |
5264 "if we didn't scan the code cache, we have to be ready to drop nmethods with expired weak oops"); |
5265 _timer.stop(); |
5265 _timer.stop(); |
5266 if (PrintCMSStatistics != 0) { |
5266 if (PrintCMSStatistics != 0) { |
5267 gclog_or_tty->print_cr( |
5267 gclog_or_tty->print_cr( |
5268 "Finished remaining root initial mark scan work in %dth thread: %3.3f sec", |
5268 "Finished remaining root initial mark scan work in %dth thread: %3.3f sec", |
5388 _timer.reset(); |
5388 _timer.reset(); |
5389 _timer.start(); |
5389 _timer.start(); |
5390 gch->gen_process_roots(_collector->_cmsGen->level(), |
5390 gch->gen_process_roots(_collector->_cmsGen->level(), |
5391 false, // yg was scanned above |
5391 false, // yg was scanned above |
5392 false, // this is parallel code |
5392 false, // this is parallel code |
5393 SharedHeap::ScanningOption(_collector->CMSCollector::roots_scanning_options()), |
5393 GenCollectedHeap::ScanningOption(_collector->CMSCollector::roots_scanning_options()), |
5394 _collector->should_unload_classes(), |
5394 _collector->should_unload_classes(), |
5395 &par_mrias_cl, |
5395 &par_mrias_cl, |
5396 NULL, |
5396 NULL, |
5397 NULL); // The dirty klasses will be handled below |
5397 NULL); // The dirty klasses will be handled below |
5398 |
5398 |
5399 assert(_collector->should_unload_classes() |
5399 assert(_collector->should_unload_classes() |
5400 || (_collector->CMSCollector::roots_scanning_options() & SharedHeap::SO_AllCodeCache), |
5400 || (_collector->CMSCollector::roots_scanning_options() & GenCollectedHeap::SO_AllCodeCache), |
5401 "if we didn't scan the code cache, we have to be ready to drop nmethods with expired weak oops"); |
5401 "if we didn't scan the code cache, we have to be ready to drop nmethods with expired weak oops"); |
5402 _timer.stop(); |
5402 _timer.stop(); |
5403 if (PrintCMSStatistics != 0) { |
5403 if (PrintCMSStatistics != 0) { |
5404 gclog_or_tty->print_cr( |
5404 gclog_or_tty->print_cr( |
5405 "Finished remaining root rescan work in %dth thread: %3.3f sec", |
5405 "Finished remaining root rescan work in %dth thread: %3.3f sec", |
5980 GenCollectedHeap::StrongRootsScope srs(gch); |
5980 GenCollectedHeap::StrongRootsScope srs(gch); |
5981 |
5981 |
5982 gch->gen_process_roots(_cmsGen->level(), |
5982 gch->gen_process_roots(_cmsGen->level(), |
5983 true, // younger gens as roots |
5983 true, // younger gens as roots |
5984 false, // use the local StrongRootsScope |
5984 false, // use the local StrongRootsScope |
5985 SharedHeap::ScanningOption(roots_scanning_options()), |
5985 GenCollectedHeap::ScanningOption(roots_scanning_options()), |
5986 should_unload_classes(), |
5986 should_unload_classes(), |
5987 &mrias_cl, |
5987 &mrias_cl, |
5988 NULL, |
5988 NULL, |
5989 NULL); // The dirty klasses will be handled below |
5989 NULL); // The dirty klasses will be handled below |
5990 |
5990 |
5991 assert(should_unload_classes() |
5991 assert(should_unload_classes() |
5992 || (roots_scanning_options() & SharedHeap::SO_AllCodeCache), |
5992 || (roots_scanning_options() & GenCollectedHeap::SO_AllCodeCache), |
5993 "if we didn't scan the code cache, we have to be ready to drop nmethods with expired weak oops"); |
5993 "if we didn't scan the code cache, we have to be ready to drop nmethods with expired weak oops"); |
5994 } |
5994 } |
5995 |
5995 |
5996 { |
5996 { |
5997 GCTraceTime t("visit unhandled CLDs", PrintGCDetails, false, _gc_timer_cm, _gc_tracer_cm->gc_id()); |
5997 GCTraceTime t("visit unhandled CLDs", PrintGCDetails, false, _gc_timer_cm, _gc_tracer_cm->gc_id()); |