< prev index next >

src/hotspot/share/gc/z/zRootsIterator.cpp


10  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License                                                             
11  * version 2 for more details (a copy is included in the LICENSE file that                                                           
12  * accompanied this code).                                                                                                           
13  *                                                                                                                                   
14  * You should have received a copy of the GNU General Public License version                                                         
15  * 2 along with this work; if not, write to the Free Software Foundation,                                                            
16  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.                                                                     
17  *                                                                                                                                   
18  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA                                                           
19  * or visit www.oracle.com if you need additional information or have any                                                            
20  * questions.                                                                                                                        
21  */                                                                                                                                  
22 
23 #include "precompiled.hpp"                                                                                                           
24 #include "classfile/classLoaderDataGraph.hpp"                                                                                        
25 #include "classfile/stringTable.hpp"                                                                                                 
26 #include "classfile/systemDictionary.hpp"                                                                                            
27 #include "code/codeCache.hpp"                                                                                                        
28 #include "compiler/oopMap.hpp"                                                                                                       
29 #include "gc/shared/oopStorageParState.inline.hpp"                                                                                   
                                                                                                                                     
30 #include "gc/z/zGlobals.hpp"                                                                                                         
31 #include "gc/z/zNMethodTable.hpp"                                                                                                    
32 #include "gc/z/zOopClosures.inline.hpp"                                                                                              
33 #include "gc/z/zRootsIterator.hpp"                                                                                                   
34 #include "gc/z/zStat.hpp"                                                                                                            
35 #include "gc/z/zThreadLocalData.hpp"                                                                                                 
36 #include "memory/resourceArea.hpp"                                                                                                   
37 #include "memory/universe.hpp"                                                                                                       
38 #include "prims/jvmtiExport.hpp"                                                                                                     
39 #include "runtime/atomic.hpp"                                                                                                        
40 #include "runtime/jniHandles.hpp"                                                                                                    
41 #include "runtime/thread.hpp"                                                                                                        
42 #include "runtime/safepoint.hpp"                                                                                                     
43 #include "runtime/synchronizer.hpp"                                                                                                  
44 #include "services/management.hpp"                                                                                                   
45 #include "utilities/debug.hpp"                                                                                                       
46 #if INCLUDE_JFR                                                                                                                      
47 #include "jfr/jfr.hpp"                                                                                                               
48 #endif                                                                                                                               
49 
50 static const ZStatSubPhase ZSubPhasePauseRootsSetup("Pause Roots Setup");                                                            
51 static const ZStatSubPhase ZSubPhasePauseRoots("Pause Roots");                                                                       
52 static const ZStatSubPhase ZSubPhasePauseRootsTeardown("Pause Roots Teardown");                                                      
53 static const ZStatSubPhase ZSubPhasePauseRootsUniverse("Pause Roots Universe");                                                      
54 static const ZStatSubPhase ZSubPhasePauseRootsJNIHandles("Pause Roots JNIHandles");                                                  
55 static const ZStatSubPhase ZSubPhasePauseRootsObjectSynchronizer("Pause Roots ObjectSynchronizer");                                  
56 static const ZStatSubPhase ZSubPhasePauseRootsManagement("Pause Roots Management");                                                  
57 static const ZStatSubPhase ZSubPhasePauseRootsJVMTIExport("Pause Roots JVMTIExport");                                                
58 static const ZStatSubPhase ZSubPhasePauseRootsJVMTIWeakExport("Pause Roots JVMTIWeakExport");                                        
59 static const ZStatSubPhase ZSubPhasePauseRootsSystemDictionary("Pause Roots SystemDictionary");                                      
60 static const ZStatSubPhase ZSubPhasePauseRootsClassLoaderDataGraph("Pause Roots ClassLoaderDataGraph");                              
61 static const ZStatSubPhase ZSubPhasePauseRootsThreads("Pause Roots Threads");                                                        
62 static const ZStatSubPhase ZSubPhasePauseRootsCodeCache("Pause Roots CodeCache");                                                    
63 
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
64 static const ZStatSubPhase ZSubPhasePauseWeakRootsSetup("Pause Weak Roots Setup");                                                   
65 static const ZStatSubPhase ZSubPhasePauseWeakRoots("Pause Weak Roots");                                                              
66 static const ZStatSubPhase ZSubPhasePauseWeakRootsTeardown("Pause Weak Roots Teardown");                                             
67 static const ZStatSubPhase ZSubPhasePauseWeakRootsJVMTIWeakExport("Pause Weak Roots JVMTIWeakExport");                               
68 static const ZStatSubPhase ZSubPhasePauseWeakRootsJFRWeak("Pause Weak Roots JFRWeak");                                               
69 
70 static const ZStatSubPhase ZSubPhaseConcurrentWeakRoots("Concurrent Weak Roots");                                                    
71 static const ZStatSubPhase ZSubPhaseConcurrentWeakRootsVMWeakHandles("Concurrent Weak Roots VMWeakHandles");                         
72 static const ZStatSubPhase ZSubPhaseConcurrentWeakRootsJNIWeakHandles("Concurrent Weak Roots JNIWeakHandles");                       
73 static const ZStatSubPhase ZSubPhaseConcurrentWeakRootsStringTable("Concurrent Weak Roots StringTable");                             
74 
75 template <typename T, void (T::*F)(ZRootsIteratorClosure*)>                                                                          
76 ZSerialOopsDo<T, F>::ZSerialOopsDo(T* iter) :                                                                                        
77     _iter(iter),                                                                                                                     
78     _claimed(false) {}                                                                                                               
79 
80 template <typename T, void (T::*F)(ZRootsIteratorClosure*)>                                                                          
81 void ZSerialOopsDo<T, F>::oops_do(ZRootsIteratorClosure* cl) {                                                                       
82   if (!_claimed && Atomic::cmpxchg(true, &_claimed, false) == false) {                                                               

10  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
11  * version 2 for more details (a copy is included in the LICENSE file that
12  * accompanied this code).
13  *
14  * You should have received a copy of the GNU General Public License version
15  * 2 along with this work; if not, write to the Free Software Foundation,
16  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
17  *
18  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
19  * or visit www.oracle.com if you need additional information or have any
20  * questions.
21  */
22 
23 #include "precompiled.hpp"
24 #include "classfile/classLoaderDataGraph.hpp"
25 #include "classfile/stringTable.hpp"
26 #include "classfile/systemDictionary.hpp"
27 #include "code/codeCache.hpp"
28 #include "compiler/oopMap.hpp"
29 #include "gc/shared/oopStorageParState.inline.hpp"
30 #include "gc/shared/suspendibleThreadSet.hpp"
31 #include "gc/z/zGlobals.hpp"
32 #include "gc/z/zNMethodTable.hpp"
33 #include "gc/z/zOopClosures.inline.hpp"
34 #include "gc/z/zRootsIterator.hpp"
35 #include "gc/z/zStat.hpp"
36 #include "gc/z/zThreadLocalData.hpp"
37 #include "memory/resourceArea.hpp"
38 #include "memory/universe.hpp"
39 #include "prims/jvmtiExport.hpp"
40 #include "runtime/atomic.hpp"
41 #include "runtime/jniHandles.hpp"
42 #include "runtime/thread.hpp"
43 #include "runtime/safepoint.hpp"
44 #include "runtime/synchronizer.hpp"
45 #include "services/management.hpp"
46 #include "utilities/debug.hpp"
47 #if INCLUDE_JFR
48 #include "jfr/jfr.hpp"
49 #endif
50 
51 static const ZStatSubPhase ZSubPhasePauseRootsSetup("Pause Roots Setup");
52 static const ZStatSubPhase ZSubPhasePauseRoots("Pause Roots");
53 static const ZStatSubPhase ZSubPhasePauseRootsTeardown("Pause Roots Teardown");
54 static const ZStatSubPhase ZSubPhasePauseRootsUniverse("Pause Roots Universe");

55 static const ZStatSubPhase ZSubPhasePauseRootsObjectSynchronizer("Pause Roots ObjectSynchronizer");
56 static const ZStatSubPhase ZSubPhasePauseRootsManagement("Pause Roots Management");
57 static const ZStatSubPhase ZSubPhasePauseRootsJVMTIExport("Pause Roots JVMTIExport");
58 static const ZStatSubPhase ZSubPhasePauseRootsJVMTIWeakExport("Pause Roots JVMTIWeakExport");
59 static const ZStatSubPhase ZSubPhasePauseRootsSystemDictionary("Pause Roots SystemDictionary");

60 static const ZStatSubPhase ZSubPhasePauseRootsThreads("Pause Roots Threads");
61 static const ZStatSubPhase ZSubPhasePauseRootsCodeCache("Pause Roots CodeCache");
62 
63 static const ZStatSubPhase ZSubPhaseConcurrentRootsSetup("Concurrent Roots Setup");
64 static const ZStatSubPhase ZSubPhaseConcurrentRoots("Concurrent Roots");
65 static const ZStatSubPhase ZSubPhaseConcurrentRootsTeardown("Concurrent Roots Teardown");
66 static const ZStatSubPhase ZSubPhaseConcurrentRootsJNIHandles("Concurrent Roots JNIHandles");
67 static const ZStatSubPhase ZSubPhaseConcurrentRootsClassLoaderDataGraph("Concurrent Roots ClassLoaderDataGraph");
68 
69 static const ZStatSubPhase ZSubPhasePauseWeakRootsSetup("Pause Weak Roots Setup");
70 static const ZStatSubPhase ZSubPhasePauseWeakRoots("Pause Weak Roots");
71 static const ZStatSubPhase ZSubPhasePauseWeakRootsTeardown("Pause Weak Roots Teardown");
72 static const ZStatSubPhase ZSubPhasePauseWeakRootsJVMTIWeakExport("Pause Weak Roots JVMTIWeakExport");
73 static const ZStatSubPhase ZSubPhasePauseWeakRootsJFRWeak("Pause Weak Roots JFRWeak");
74 
75 static const ZStatSubPhase ZSubPhaseConcurrentWeakRoots("Concurrent Weak Roots");
76 static const ZStatSubPhase ZSubPhaseConcurrentWeakRootsVMWeakHandles("Concurrent Weak Roots VMWeakHandles");
77 static const ZStatSubPhase ZSubPhaseConcurrentWeakRootsJNIWeakHandles("Concurrent Weak Roots JNIWeakHandles");
78 static const ZStatSubPhase ZSubPhaseConcurrentWeakRootsStringTable("Concurrent Weak Roots StringTable");
79 
80 template <typename T, void (T::*F)(ZRootsIteratorClosure*)>
81 ZSerialOopsDo<T, F>::ZSerialOopsDo(T* iter) :
82     _iter(iter),
83     _claimed(false) {}
84 
85 template <typename T, void (T::*F)(ZRootsIteratorClosure*)>
86 void ZSerialOopsDo<T, F>::oops_do(ZRootsIteratorClosure* cl) {
87   if (!_claimed && Atomic::cmpxchg(true, &_claimed, false) == false) {

110     (_iter->*F)(is_alive, cl);                                                                                                       
111   }                                                                                                                                  
112 }                                                                                                                                    
113 
114 template <typename T, void (T::*F)(BoolObjectClosure*, ZRootsIteratorClosure*)>                                                      
115 ZParallelWeakOopsDo<T, F>::ZParallelWeakOopsDo(T* iter) :                                                                            
116     _iter(iter),                                                                                                                     
117     _completed(false) {}                                                                                                             
118 
119 template <typename T, void (T::*F)(BoolObjectClosure*, ZRootsIteratorClosure*)>                                                      
120 void ZParallelWeakOopsDo<T, F>::weak_oops_do(BoolObjectClosure* is_alive, ZRootsIteratorClosure* cl) {                               
121   if (!_completed) {                                                                                                                 
122     (_iter->*F)(is_alive, cl);                                                                                                       
123     if (!_completed) {                                                                                                               
124       _completed = true;                                                                                                             
125     }                                                                                                                                
126   }                                                                                                                                  
127 }                                                                                                                                    
128 
129 ZRootsIterator::ZRootsIterator() :                                                                                                   
130     _jni_handles_iter(JNIHandles::global_handles()),                                                                                 
131     _universe(this),                                                                                                                 
132     _object_synchronizer(this),                                                                                                      
133     _management(this),                                                                                                               
134     _jvmti_export(this),                                                                                                             
135     _jvmti_weak_export(this),                                                                                                        
136     _system_dictionary(this),                                                                                                        
137     _jni_handles(this),                                                                                                              
138     _class_loader_data_graph(this),                                                                                                  
139     _threads(this),                                                                                                                  
140     _code_cache(this) {                                                                                                              
141   assert(SafepointSynchronize::is_at_safepoint(), "Should be at safepoint");                                                         
142   ZStatTimer timer(ZSubPhasePauseRootsSetup);                                                                                        
143   Threads::change_thread_claim_parity();                                                                                             
144   ClassLoaderDataGraph::clear_claimed_marks();                                                                                       
145   COMPILER2_PRESENT(DerivedPointerTable::clear());                                                                                   
146   CodeCache::gc_prologue();                                                                                                          
147   ZNMethodTable::gc_prologue();                                                                                                      
148 }                                                                                                                                    
149 
150 ZRootsIterator::~ZRootsIterator() {                                                                                                  
151   ZStatTimer timer(ZSubPhasePauseRootsTeardown);                                                                                     
152   ResourceMark rm;                                                                                                                   
153   ZNMethodTable::gc_epilogue();                                                                                                      
154   CodeCache::gc_epilogue();                                                                                                          
155   JvmtiExport::gc_epilogue();                                                                                                        
156   COMPILER2_PRESENT(DerivedPointerTable::update_pointers());                                                                         
157   Threads::assert_all_threads_claimed();                                                                                             
158 }                                                                                                                                    
159 
160 void ZRootsIterator::do_universe(ZRootsIteratorClosure* cl) {                                                                        
161   ZStatTimer timer(ZSubPhasePauseRootsUniverse);                                                                                     
162   Universe::oops_do(cl);                                                                                                             
163 }                                                                                                                                    
164 
165 void ZRootsIterator::do_jni_handles(ZRootsIteratorClosure* cl) {                                                                     
166   ZStatTimer timer(ZSubPhasePauseRootsJNIHandles);                                                                                   
167   _jni_handles_iter.oops_do(cl);                                                                                                     
168 }                                                                                                                                    
169                                                                                                                                      
170 void ZRootsIterator::do_object_synchronizer(ZRootsIteratorClosure* cl) {                                                             
171   ZStatTimer timer(ZSubPhasePauseRootsObjectSynchronizer);                                                                           
172   ObjectSynchronizer::oops_do(cl);                                                                                                   
173 }                                                                                                                                    
174 
175 void ZRootsIterator::do_management(ZRootsIteratorClosure* cl) {                                                                      
176   ZStatTimer timer(ZSubPhasePauseRootsManagement);                                                                                   
177   Management::oops_do(cl);                                                                                                           
178 }                                                                                                                                    
179 
180 void ZRootsIterator::do_jvmti_export(ZRootsIteratorClosure* cl) {                                                                    
181   ZStatTimer timer(ZSubPhasePauseRootsJVMTIExport);                                                                                  
182   JvmtiExport::oops_do(cl);                                                                                                          
183 }                                                                                                                                    
184 
185 void ZRootsIterator::do_jvmti_weak_export(ZRootsIteratorClosure* cl) {                                                               
186   ZStatTimer timer(ZSubPhasePauseRootsJVMTIWeakExport);                                                                              
187   AlwaysTrueClosure always_alive;                                                                                                    
188   JvmtiExport::weak_oops_do(&always_alive, cl);                                                                                      
189 }                                                                                                                                    
190 
191 void ZRootsIterator::do_system_dictionary(ZRootsIteratorClosure* cl) {                                                               
192   ZStatTimer timer(ZSubPhasePauseRootsSystemDictionary);                                                                             
193   SystemDictionary::oops_do(cl);                                                                                                     
194 }                                                                                                                                    
195 
196 void ZRootsIterator::do_class_loader_data_graph(ZRootsIteratorClosure* cl) {                                                         
197   ZStatTimer timer(ZSubPhasePauseRootsClassLoaderDataGraph);                                                                         
198   CLDToOopClosure cld_cl(cl);                                                                                                        
199   ClassLoaderDataGraph::cld_do(&cld_cl);                                                                                             
200 }                                                                                                                                    
201                                                                                                                                      
202 void ZRootsIterator::do_threads(ZRootsIteratorClosure* cl) {                                                                         
203   ZStatTimer timer(ZSubPhasePauseRootsThreads);                                                                                      
204   ResourceMark rm;                                                                                                                   
205   Threads::possibly_parallel_threads_do(true, cl);                                                                                   
206 }                                                                                                                                    
207 
208 void ZRootsIterator::do_code_cache(ZRootsIteratorClosure* cl) {                                                                      
209   ZStatTimer timer(ZSubPhasePauseRootsCodeCache);                                                                                    
210   ZNMethodTable::oops_do(cl);                                                                                                        
211 }                                                                                                                                    
212 
213 void ZRootsIterator::oops_do(ZRootsIteratorClosure* cl, bool visit_jvmti_weak_export) {                                              
214   ZStatTimer timer(ZSubPhasePauseRoots);                                                                                             
215   _universe.oops_do(cl);                                                                                                             
216   _object_synchronizer.oops_do(cl);                                                                                                  
217   _management.oops_do(cl);                                                                                                           
218   _jvmti_export.oops_do(cl);                                                                                                         
219   _system_dictionary.oops_do(cl);                                                                                                    
220   _jni_handles.oops_do(cl);                                                                                                          
221   _class_loader_data_graph.oops_do(cl);                                                                                              
222   _threads.oops_do(cl);                                                                                                              
223   _code_cache.oops_do(cl);                                                                                                           
224   if (visit_jvmti_weak_export) {                                                                                                     
225     _jvmti_weak_export.oops_do(cl);                                                                                                  
226   }                                                                                                                                  
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
                                                                                                                                     
227 }                                                                                                                                    
228 
229 ZWeakRootsIterator::ZWeakRootsIterator() :                                                                                           
230     _jvmti_weak_export(this),                                                                                                        
231     _jfr_weak(this) {                                                                                                                
232   assert(SafepointSynchronize::is_at_safepoint(), "Should be at safepoint");                                                         
233   ZStatTimer timer(ZSubPhasePauseWeakRootsSetup);                                                                                    
234 }                                                                                                                                    
235 
236 ZWeakRootsIterator::~ZWeakRootsIterator() {                                                                                          
237   ZStatTimer timer(ZSubPhasePauseWeakRootsTeardown);                                                                                 
238 }                                                                                                                                    
239 
240 void ZWeakRootsIterator::do_jvmti_weak_export(BoolObjectClosure* is_alive, ZRootsIteratorClosure* cl) {                              
241   ZStatTimer timer(ZSubPhasePauseWeakRootsJVMTIWeakExport);                                                                          
242   JvmtiExport::weak_oops_do(is_alive, cl);                                                                                           
243 }                                                                                                                                    
244 
245 void ZWeakRootsIterator::do_jfr_weak(BoolObjectClosure* is_alive, ZRootsIteratorClosure* cl) {                                       

115     (_iter->*F)(is_alive, cl);
116   }
117 }
118 
119 template <typename T, void (T::*F)(BoolObjectClosure*, ZRootsIteratorClosure*)>
120 ZParallelWeakOopsDo<T, F>::ZParallelWeakOopsDo(T* iter) :
121     _iter(iter),
122     _completed(false) {}
123 
124 template <typename T, void (T::*F)(BoolObjectClosure*, ZRootsIteratorClosure*)>
125 void ZParallelWeakOopsDo<T, F>::weak_oops_do(BoolObjectClosure* is_alive, ZRootsIteratorClosure* cl) {
126   if (!_completed) {
127     (_iter->*F)(is_alive, cl);
128     if (!_completed) {
129       _completed = true;
130     }
131   }
132 }
133 
134 ZRootsIterator::ZRootsIterator() :

135     _universe(this),
136     _object_synchronizer(this),
137     _management(this),
138     _jvmti_export(this),
139     _jvmti_weak_export(this),
140     _system_dictionary(this),


141     _threads(this),
142     _code_cache(this) {
143   assert(SafepointSynchronize::is_at_safepoint(), "Should be at safepoint");
144   ZStatTimer timer(ZSubPhasePauseRootsSetup);
145   Threads::change_thread_claim_parity();

146   COMPILER2_PRESENT(DerivedPointerTable::clear());
147   CodeCache::gc_prologue();
148   ZNMethodTable::gc_prologue();
149 }
150 
151 ZRootsIterator::~ZRootsIterator() {
152   ZStatTimer timer(ZSubPhasePauseRootsTeardown);
153   ResourceMark rm;
154   ZNMethodTable::gc_epilogue();
155   CodeCache::gc_epilogue();
156   JvmtiExport::gc_epilogue();
157   COMPILER2_PRESENT(DerivedPointerTable::update_pointers());
158   Threads::assert_all_threads_claimed();
159 }
160 
161 void ZRootsIterator::do_universe(ZRootsIteratorClosure* cl) {
162   ZStatTimer timer(ZSubPhasePauseRootsUniverse);
163   Universe::oops_do(cl);
164 }
165 





166 void ZRootsIterator::do_object_synchronizer(ZRootsIteratorClosure* cl) {
167   ZStatTimer timer(ZSubPhasePauseRootsObjectSynchronizer);
168   ObjectSynchronizer::oops_do(cl);
169 }
170 
171 void ZRootsIterator::do_management(ZRootsIteratorClosure* cl) {
172   ZStatTimer timer(ZSubPhasePauseRootsManagement);
173   Management::oops_do(cl);
174 }
175 
176 void ZRootsIterator::do_jvmti_export(ZRootsIteratorClosure* cl) {
177   ZStatTimer timer(ZSubPhasePauseRootsJVMTIExport);
178   JvmtiExport::oops_do(cl);
179 }
180 
181 void ZRootsIterator::do_jvmti_weak_export(ZRootsIteratorClosure* cl) {
182   ZStatTimer timer(ZSubPhasePauseRootsJVMTIWeakExport);
183   AlwaysTrueClosure always_alive;
184   JvmtiExport::weak_oops_do(&always_alive, cl);
185 }
186 
187 void ZRootsIterator::do_system_dictionary(ZRootsIteratorClosure* cl) {
188   ZStatTimer timer(ZSubPhasePauseRootsSystemDictionary);
189   SystemDictionary::oops_do(cl);
190 }
191 






192 void ZRootsIterator::do_threads(ZRootsIteratorClosure* cl) {
193   ZStatTimer timer(ZSubPhasePauseRootsThreads);
194   ResourceMark rm;
195   Threads::possibly_parallel_threads_do(true, cl);
196 }
197 
198 void ZRootsIterator::do_code_cache(ZRootsIteratorClosure* cl) {
199   ZStatTimer timer(ZSubPhasePauseRootsCodeCache);
200   ZNMethodTable::oops_do(cl);
201 }
202 
203 void ZRootsIterator::oops_do(ZRootsIteratorClosure* cl, bool visit_jvmti_weak_export) {
204   ZStatTimer timer(ZSubPhasePauseRoots);
205   _universe.oops_do(cl);
206   _object_synchronizer.oops_do(cl);
207   _management.oops_do(cl);
208   _jvmti_export.oops_do(cl);
209   _system_dictionary.oops_do(cl);


210   _threads.oops_do(cl);
211   _code_cache.oops_do(cl);
212   if (visit_jvmti_weak_export) {
213     _jvmti_weak_export.oops_do(cl);
214   }
215 }
216 
217 ZConcurrentRootsIterator::ZConcurrentRootsIterator(bool marking) :
218     _marking(marking),
219     _sts_joiner(marking),
220     _jni_handles_iter(JNIHandles::global_handles()),
221     _jni_handles(this),
222     _class_loader_data_graph(this) {
223   ZStatTimer timer(ZSubPhaseConcurrentRootsSetup);
224   if (marking) {
225     ClassLoaderDataGraph_lock->lock();
226     ClassLoaderDataGraph::clear_claimed_marks();
227   }
228 }
229 
230 ZConcurrentRootsIterator::~ZConcurrentRootsIterator() {
231   ZStatTimer timer(ZSubPhaseConcurrentRootsTeardown);
232   if (_marking) {
233     ClassLoaderDataGraph_lock->unlock();
234   }
235 }
236 
237 void ZConcurrentRootsIterator::do_jni_handles(ZRootsIteratorClosure* cl) {
238   ZStatTimer timer(ZSubPhaseConcurrentRootsJNIHandles);
239   _jni_handles_iter.oops_do(cl);
240 }
241 
242 void ZConcurrentRootsIterator::do_class_loader_data_graph(ZRootsIteratorClosure* cl) {
243   ZStatTimer timer(ZSubPhaseConcurrentRootsClassLoaderDataGraph);
244   CLDToOopClosure cld_cl(cl, _marking /* must_claim */);
245   ClassLoaderDataGraph::cld_do(&cld_cl);
246 }
247 
248 void ZConcurrentRootsIterator::oops_do(ZRootsIteratorClosure* cl) {
249   ZStatTimer timer(ZSubPhaseConcurrentRoots);
250   _jni_handles.oops_do(cl);
251   _class_loader_data_graph.oops_do(cl);
252 }
253 
254 ZWeakRootsIterator::ZWeakRootsIterator() :
255     _jvmti_weak_export(this),
256     _jfr_weak(this) {
257   assert(SafepointSynchronize::is_at_safepoint(), "Should be at safepoint");
258   ZStatTimer timer(ZSubPhasePauseWeakRootsSetup);
259 }
260 
261 ZWeakRootsIterator::~ZWeakRootsIterator() {
262   ZStatTimer timer(ZSubPhasePauseWeakRootsTeardown);
263 }
264 
265 void ZWeakRootsIterator::do_jvmti_weak_export(BoolObjectClosure* is_alive, ZRootsIteratorClosure* cl) {
266   ZStatTimer timer(ZSubPhasePauseWeakRootsJVMTIWeakExport);
267   JvmtiExport::weak_oops_do(is_alive, cl);
268 }
269 
270 void ZWeakRootsIterator::do_jfr_weak(BoolObjectClosure* is_alive, ZRootsIteratorClosure* cl) {
< prev index next >