98 if (_strong_roots_parity == 3) _strong_roots_parity = 1; |
98 if (_strong_roots_parity == 3) _strong_roots_parity = 1; |
99 assert(_strong_roots_parity >= 1 && _strong_roots_parity <= 2, |
99 assert(_strong_roots_parity >= 1 && _strong_roots_parity <= 2, |
100 "Not in range."); |
100 "Not in range."); |
101 } |
101 } |
102 |
102 |
103 void SharedHeap::process_strong_roots(bool collecting_perm_gen, |
103 SharedHeap::StrongRootsScope::StrongRootsScope(SharedHeap* outer, bool activate) |
|
104 : MarkScope(activate) |
|
105 { |
|
106 if (_active) { |
|
107 outer->change_strong_roots_parity(); |
|
108 } |
|
109 } |
|
110 |
|
111 SharedHeap::StrongRootsScope::~StrongRootsScope() { |
|
112 // nothing particular |
|
113 } |
|
114 |
|
115 void SharedHeap::process_strong_roots(bool activate_scope, |
|
116 bool collecting_perm_gen, |
104 ScanningOption so, |
117 ScanningOption so, |
105 OopClosure* roots, |
118 OopClosure* roots, |
|
119 CodeBlobClosure* code_roots, |
106 OopsInGenClosure* perm_blk) { |
120 OopsInGenClosure* perm_blk) { |
|
121 StrongRootsScope srs(this, activate_scope); |
107 // General strong roots. |
122 // General strong roots. |
108 if (n_par_threads() == 0) change_strong_roots_parity(); |
123 assert(_strong_roots_parity != 0, "must have called prologue code"); |
109 if (!_process_strong_tasks->is_task_claimed(SH_PS_Universe_oops_do)) { |
124 if (!_process_strong_tasks->is_task_claimed(SH_PS_Universe_oops_do)) { |
110 Universe::oops_do(roots); |
125 Universe::oops_do(roots); |
111 ReferenceProcessor::oops_do(roots); |
126 ReferenceProcessor::oops_do(roots); |
112 // Consider perm-gen discovered lists to be strong. |
127 // Consider perm-gen discovered lists to be strong. |
113 perm_gen()->ref_processor()->weak_oops_do(roots); |
128 perm_gen()->ref_processor()->weak_oops_do(roots); |
115 // Global (strong) JNI handles |
130 // Global (strong) JNI handles |
116 if (!_process_strong_tasks->is_task_claimed(SH_PS_JNIHandles_oops_do)) |
131 if (!_process_strong_tasks->is_task_claimed(SH_PS_JNIHandles_oops_do)) |
117 JNIHandles::oops_do(roots); |
132 JNIHandles::oops_do(roots); |
118 // All threads execute this; the individual threads are task groups. |
133 // All threads execute this; the individual threads are task groups. |
119 if (ParallelGCThreads > 0) { |
134 if (ParallelGCThreads > 0) { |
120 Threads::possibly_parallel_oops_do(roots); |
135 Threads::possibly_parallel_oops_do(roots, code_roots); |
121 } else { |
136 } else { |
122 Threads::oops_do(roots); |
137 Threads::oops_do(roots, code_roots); |
123 } |
138 } |
124 if (!_process_strong_tasks-> is_task_claimed(SH_PS_ObjectSynchronizer_oops_do)) |
139 if (!_process_strong_tasks-> is_task_claimed(SH_PS_ObjectSynchronizer_oops_do)) |
125 ObjectSynchronizer::oops_do(roots); |
140 ObjectSynchronizer::oops_do(roots); |
126 if (!_process_strong_tasks->is_task_claimed(SH_PS_FlatProfiler_oops_do)) |
141 if (!_process_strong_tasks->is_task_claimed(SH_PS_FlatProfiler_oops_do)) |
127 FlatProfiler::oops_do(roots); |
142 FlatProfiler::oops_do(roots); |
154 // Verify if the string table contents are in the perm gen |
169 // Verify if the string table contents are in the perm gen |
155 NOT_PRODUCT(StringTable::oops_do(&assert_is_perm_closure)); |
170 NOT_PRODUCT(StringTable::oops_do(&assert_is_perm_closure)); |
156 } |
171 } |
157 |
172 |
158 if (!_process_strong_tasks->is_task_claimed(SH_PS_CodeCache_oops_do)) { |
173 if (!_process_strong_tasks->is_task_claimed(SH_PS_CodeCache_oops_do)) { |
159 if (so & SO_CodeCache) { |
174 if (so & SO_CodeCache) { |
160 CodeCache::oops_do(roots); |
175 // (Currently, CMSCollector uses this to do intermediate-strength collections.) |
161 } |
176 assert(collecting_perm_gen, "scanning all of code cache"); |
|
177 assert(code_roots != NULL, "must supply closure for code cache"); |
|
178 if (code_roots != NULL) { |
|
179 CodeCache::blobs_do(code_roots); |
|
180 } |
|
181 } else if (so & (SO_SystemClasses|SO_AllClasses)) { |
|
182 if (!collecting_perm_gen) { |
|
183 // If we are collecting from class statics, but we are not going to |
|
184 // visit all of the CodeCache, collect from the non-perm roots if any. |
|
185 // This makes the code cache function temporarily as a source of strong |
|
186 // roots for oops, until the next major collection. |
|
187 // |
|
188 // If collecting_perm_gen is true, we require that this phase will call |
|
189 // CodeCache::do_unloading. This will kill off nmethods with expired |
|
190 // weak references, such as stale invokedynamic targets. |
|
191 CodeCache::scavenge_root_nmethods_do(code_roots); |
|
192 } |
|
193 } |
162 // Verify if the code cache contents are in the perm gen |
194 // Verify if the code cache contents are in the perm gen |
163 NOT_PRODUCT(CodeCache::oops_do(&assert_is_perm_closure)); |
195 NOT_PRODUCT(CodeBlobToOopClosure assert_code_is_perm(&assert_is_perm_closure, /*do_marking=*/ false)); |
|
196 NOT_PRODUCT(CodeCache::asserted_non_scavengable_nmethods_do(&assert_code_is_perm)); |
164 } |
197 } |
165 |
198 |
166 // Roots that should point only into permanent generation. |
199 // Roots that should point only into permanent generation. |
167 { |
200 { |
168 OopClosure* blk = NULL; |
201 OopClosure* blk = NULL; |
218 // forwarding StringTable entries which contain unmarked shared |
251 // forwarding StringTable entries which contain unmarked shared |
219 // Strings. Actually, since shared strings won't be moving, we can |
252 // Strings. Actually, since shared strings won't be moving, we can |
220 // just skip adjusting any shared entries in the string table. |
253 // just skip adjusting any shared entries in the string table. |
221 |
254 |
222 void SharedHeap::process_weak_roots(OopClosure* root_closure, |
255 void SharedHeap::process_weak_roots(OopClosure* root_closure, |
|
256 CodeBlobClosure* code_roots, |
223 OopClosure* non_root_closure) { |
257 OopClosure* non_root_closure) { |
224 // Global (weak) JNI handles |
258 // Global (weak) JNI handles |
225 JNIHandles::weak_oops_do(&always_true, root_closure); |
259 JNIHandles::weak_oops_do(&always_true, root_closure); |
226 |
260 |
227 CodeCache::oops_do(non_root_closure); |
261 CodeCache::blobs_do(code_roots); |
228 SymbolTable::oops_do(root_closure); |
262 SymbolTable::oops_do(root_closure); |
229 if (UseSharedSpaces && !DumpSharedSpaces) { |
263 if (UseSharedSpaces && !DumpSharedSpaces) { |
230 SkipAdjustingSharedStrings skip_closure(root_closure); |
264 SkipAdjustingSharedStrings skip_closure(root_closure); |
231 StringTable::oops_do(&skip_closure); |
265 StringTable::oops_do(&skip_closure); |
232 } else { |
266 } else { |