1.1 --- a/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp Tue Jul 01 09:03:55 2014 +0200 1.2 +++ b/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp Mon Jul 07 10:12:40 2014 +0200 1.3 @@ -1570,11 +1570,11 @@ 1.4 } 1.5 1.6 if (MetaspaceGC::should_concurrent_collect()) { 1.7 - if (Verbose && PrintGCDetails) { 1.8 + if (Verbose && PrintGCDetails) { 1.9 gclog_or_tty->print("CMSCollector: collect for metadata allocation "); 1.10 - } 1.11 - return true; 1.12 - } 1.13 + } 1.14 + return true; 1.15 + } 1.16 1.17 return false; 1.18 } 1.19 @@ -3028,20 +3028,21 @@ 1.20 HandleMark hm; 1.21 GenCollectedHeap* gch = GenCollectedHeap::heap(); 1.22 1.23 - // Get a clear set of claim bits for the strong roots processing to work with. 1.24 + // Get a clear set of claim bits for the roots processing to work with. 1.25 ClassLoaderDataGraph::clear_claimed_marks(); 1.26 1.27 // Mark from roots one level into CMS 1.28 MarkRefsIntoClosure notOlder(_span, verification_mark_bm()); 1.29 gch->rem_set()->prepare_for_younger_refs_iterate(false); // Not parallel. 1.30 1.31 - gch->gen_process_strong_roots(_cmsGen->level(), 1.32 - true, // younger gens are roots 1.33 - true, // activate StrongRootsScope 1.34 - SharedHeap::ScanningOption(roots_scanning_options()), 1.35 - ¬Older, 1.36 - NULL, 1.37 - NULL); // SSS: Provide correct closure 1.38 + gch->gen_process_roots(_cmsGen->level(), 1.39 + true, // younger gens are roots 1.40 + true, // activate StrongRootsScope 1.41 + SharedHeap::ScanningOption(roots_scanning_options()), 1.42 + should_unload_classes(), 1.43 + ¬Older, 1.44 + NULL, 1.45 + NULL); // SSS: Provide correct closure 1.46 1.47 // Now mark from the roots 1.48 MarkFromRootsClosure markFromRootsClosure(this, _span, 1.49 @@ -3092,22 +3093,24 @@ 1.50 HandleMark hm; 1.51 GenCollectedHeap* gch = GenCollectedHeap::heap(); 1.52 1.53 - // Get a clear set of claim bits for the strong roots processing to work with. 1.54 + // Get a clear set of claim bits for the roots processing to work with. 1.55 ClassLoaderDataGraph::clear_claimed_marks(); 1.56 1.57 // Mark from roots one level into CMS 1.58 MarkRefsIntoVerifyClosure notOlder(_span, verification_mark_bm(), 1.59 markBitMap()); 1.60 - KlassToOopClosure klass_closure(¬Older); 1.61 + CLDToOopClosure cld_closure(¬Older, true); 1.62 1.63 gch->rem_set()->prepare_for_younger_refs_iterate(false); // Not parallel. 1.64 - gch->gen_process_strong_roots(_cmsGen->level(), 1.65 - true, // younger gens are roots 1.66 - true, // activate StrongRootsScope 1.67 - SharedHeap::ScanningOption(roots_scanning_options()), 1.68 - ¬Older, 1.69 - NULL, 1.70 - &klass_closure); 1.71 + 1.72 + gch->gen_process_roots(_cmsGen->level(), 1.73 + true, // younger gens are roots 1.74 + true, // activate StrongRootsScope 1.75 + SharedHeap::ScanningOption(roots_scanning_options()), 1.76 + should_unload_classes(), 1.77 + ¬Older, 1.78 + NULL, 1.79 + &cld_closure); 1.80 1.81 // Now mark from the roots 1.82 MarkFromRootsVerifyClosure markFromRootsClosure(this, _span, 1.83 @@ -3294,12 +3297,10 @@ 1.84 void CMSCollector::setup_cms_unloading_and_verification_state() { 1.85 const bool should_verify = VerifyBeforeGC || VerifyAfterGC || VerifyDuringGC 1.86 || VerifyBeforeExit; 1.87 - const int rso = SharedHeap::SO_Strings | SharedHeap::SO_AllCodeCache; 1.88 + const int rso = SharedHeap::SO_AllCodeCache; 1.89 1.90 // We set the proper root for this CMS cycle here. 1.91 if (should_unload_classes()) { // Should unload classes this cycle 1.92 - remove_root_scanning_option(SharedHeap::SO_AllClasses); 1.93 - add_root_scanning_option(SharedHeap::SO_SystemClasses); 1.94 remove_root_scanning_option(rso); // Shrink the root set appropriately 1.95 set_verifying(should_verify); // Set verification state for this cycle 1.96 return; // Nothing else needs to be done at this time 1.97 @@ -3307,8 +3308,6 @@ 1.98 1.99 // Not unloading classes this cycle 1.100 assert(!should_unload_classes(), "Inconsitency!"); 1.101 - remove_root_scanning_option(SharedHeap::SO_SystemClasses); 1.102 - add_root_scanning_option(SharedHeap::SO_AllClasses); 1.103 1.104 if ((!verifying() || unloaded_classes_last_cycle()) && should_verify) { 1.105 // Include symbols, strings and code cache elements to prevent their resurrection. 1.106 @@ -3719,15 +3718,16 @@ 1.107 gch->set_par_threads(0); 1.108 } else { 1.109 // The serial version. 1.110 - KlassToOopClosure klass_closure(¬Older); 1.111 + CLDToOopClosure cld_closure(¬Older, true); 1.112 gch->rem_set()->prepare_for_younger_refs_iterate(false); // Not parallel. 1.113 - gch->gen_process_strong_roots(_cmsGen->level(), 1.114 - true, // younger gens are roots 1.115 - true, // activate StrongRootsScope 1.116 - SharedHeap::ScanningOption(roots_scanning_options()), 1.117 - ¬Older, 1.118 - NULL, 1.119 - &klass_closure); 1.120 + gch->gen_process_roots(_cmsGen->level(), 1.121 + true, // younger gens are roots 1.122 + true, // activate StrongRootsScope 1.123 + SharedHeap::ScanningOption(roots_scanning_options()), 1.124 + should_unload_classes(), 1.125 + ¬Older, 1.126 + NULL, 1.127 + &cld_closure); 1.128 } 1.129 } 1.130 1.131 @@ -5203,7 +5203,6 @@ 1.132 _timer.start(); 1.133 GenCollectedHeap* gch = GenCollectedHeap::heap(); 1.134 Par_MarkRefsIntoClosure par_mri_cl(_collector->_span, &(_collector->_markBitMap)); 1.135 - KlassToOopClosure klass_closure(&par_mri_cl); 1.136 1.137 // ---------- young gen roots -------------- 1.138 { 1.139 @@ -5219,13 +5218,17 @@ 1.140 // ---------- remaining roots -------------- 1.141 _timer.reset(); 1.142 _timer.start(); 1.143 - gch->gen_process_strong_roots(_collector->_cmsGen->level(), 1.144 - false, // yg was scanned above 1.145 - false, // this is parallel code 1.146 - SharedHeap::ScanningOption(_collector->CMSCollector::roots_scanning_options()), 1.147 - &par_mri_cl, 1.148 - NULL, 1.149 - &klass_closure); 1.150 + 1.151 + CLDToOopClosure cld_closure(&par_mri_cl, true); 1.152 + 1.153 + gch->gen_process_roots(_collector->_cmsGen->level(), 1.154 + false, // yg was scanned above 1.155 + false, // this is parallel code 1.156 + SharedHeap::ScanningOption(_collector->CMSCollector::roots_scanning_options()), 1.157 + _collector->should_unload_classes(), 1.158 + &par_mri_cl, 1.159 + NULL, 1.160 + &cld_closure); 1.161 assert(_collector->should_unload_classes() 1.162 || (_collector->CMSCollector::roots_scanning_options() & SharedHeap::SO_AllCodeCache), 1.163 "if we didn't scan the code cache, we have to be ready to drop nmethods with expired weak oops"); 1.164 @@ -5354,13 +5357,15 @@ 1.165 // ---------- remaining roots -------------- 1.166 _timer.reset(); 1.167 _timer.start(); 1.168 - gch->gen_process_strong_roots(_collector->_cmsGen->level(), 1.169 - false, // yg was scanned above 1.170 - false, // this is parallel code 1.171 - SharedHeap::ScanningOption(_collector->CMSCollector::roots_scanning_options()), 1.172 - &par_mrias_cl, 1.173 - NULL, 1.174 - NULL); // The dirty klasses will be handled below 1.175 + gch->gen_process_roots(_collector->_cmsGen->level(), 1.176 + false, // yg was scanned above 1.177 + false, // this is parallel code 1.178 + SharedHeap::ScanningOption(_collector->CMSCollector::roots_scanning_options()), 1.179 + _collector->should_unload_classes(), 1.180 + &par_mrias_cl, 1.181 + NULL, 1.182 + NULL); // The dirty klasses will be handled below 1.183 + 1.184 assert(_collector->should_unload_classes() 1.185 || (_collector->CMSCollector::roots_scanning_options() & SharedHeap::SO_AllCodeCache), 1.186 "if we didn't scan the code cache, we have to be ready to drop nmethods with expired weak oops"); 1.187 @@ -5415,7 +5420,7 @@ 1.188 // We might have added oops to ClassLoaderData::_handles during the 1.189 // concurrent marking phase. These oops point to newly allocated objects 1.190 // that are guaranteed to be kept alive. Either by the direct allocation 1.191 - // code, or when the young collector processes the strong roots. Hence, 1.192 + // code, or when the young collector processes the roots. Hence, 1.193 // we don't have to revisit the _handles block during the remark phase. 1.194 1.195 // ---------- rescan dirty cards ------------ 1.196 @@ -5837,7 +5842,7 @@ 1.197 cms_space, 1.198 n_workers, workers, task_queues()); 1.199 1.200 - // Set up for parallel process_strong_roots work. 1.201 + // Set up for parallel process_roots work. 1.202 gch->set_par_threads(n_workers); 1.203 // We won't be iterating over the cards in the card table updating 1.204 // the younger_gen cards, so we shouldn't call the following else 1.205 @@ -5846,7 +5851,7 @@ 1.206 // gch->rem_set()->prepare_for_younger_refs_iterate(true); // parallel 1.207 1.208 // The young gen rescan work will not be done as part of 1.209 - // process_strong_roots (which currently doesn't knw how to 1.210 + // process_roots (which currently doesn't know how to 1.211 // parallelize such a scan), but rather will be broken up into 1.212 // a set of parallel tasks (via the sampling that the [abortable] 1.213 // preclean phase did of EdenSpace, plus the [two] tasks of 1.214 @@ -5943,13 +5948,15 @@ 1.215 1.216 gch->rem_set()->prepare_for_younger_refs_iterate(false); // Not parallel. 1.217 GenCollectedHeap::StrongRootsScope srs(gch); 1.218 - gch->gen_process_strong_roots(_cmsGen->level(), 1.219 - true, // younger gens as roots 1.220 - false, // use the local StrongRootsScope 1.221 - SharedHeap::ScanningOption(roots_scanning_options()), 1.222 - &mrias_cl, 1.223 - NULL, 1.224 - NULL); // The dirty klasses will be handled below 1.225 + 1.226 + gch->gen_process_roots(_cmsGen->level(), 1.227 + true, // younger gens as roots 1.228 + false, // use the local StrongRootsScope 1.229 + SharedHeap::ScanningOption(roots_scanning_options()), 1.230 + should_unload_classes(), 1.231 + &mrias_cl, 1.232 + NULL, 1.233 + NULL); // The dirty klasses will be handled below 1.234 1.235 assert(should_unload_classes() 1.236 || (roots_scanning_options() & SharedHeap::SO_AllCodeCache), 1.237 @@ -5989,7 +5996,7 @@ 1.238 // We might have added oops to ClassLoaderData::_handles during the 1.239 // concurrent marking phase. These oops point to newly allocated objects 1.240 // that are guaranteed to be kept alive. Either by the direct allocation 1.241 - // code, or when the young collector processes the strong roots. Hence, 1.242 + // code, or when the young collector processes the roots. Hence, 1.243 // we don't have to revisit the _handles block during the remark phase. 1.244 1.245 verify_work_stacks_empty(); 1.246 @@ -6239,15 +6246,14 @@ 1.247 // Clean up unreferenced symbols in symbol table. 1.248 SymbolTable::unlink(); 1.249 } 1.250 - } 1.251 - 1.252 - // CMS doesn't use the StringTable as hard roots when class unloading is turned off. 1.253 - // Need to check if we really scanned the StringTable. 1.254 - if ((roots_scanning_options() & SharedHeap::SO_Strings) == 0) { 1.255 - GCTraceTime t("scrub string table", PrintGCDetails, false, _gc_timer_cm, _gc_tracer_cm->gc_id()); 1.256 - // Delete entries for dead interned strings. 1.257 - StringTable::unlink(&_is_alive_closure); 1.258 - } 1.259 + 1.260 + { 1.261 + GCTraceTime t("scrub string table", PrintGCDetails, false, _gc_timer_cm, _gc_tracer_cm->gc_id()); 1.262 + // Delete entries for dead interned strings. 1.263 + StringTable::unlink(&_is_alive_closure); 1.264 + } 1.265 + } 1.266 + 1.267 1.268 // Restore any preserved marks as a result of mark stack or 1.269 // work queue overflow