16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 #include "precompiled.hpp"
25 #include "classfile/classLoaderDataGraph.hpp"
26 #include "classfile/stringTable.hpp"
27 #include "classfile/systemDictionary.hpp"
28 #include "code/codeCache.hpp"
29 #include "compiler/oopMap.hpp"
30 #include "gc/shared/barrierSet.hpp"
31 #include "gc/shared/barrierSetNMethod.hpp"
32 #include "gc/shared/oopStorageParState.inline.hpp"
33 #include "gc/shared/suspendibleThreadSet.hpp"
34 #include "gc/z/zBarrierSetNMethod.hpp"
35 #include "gc/z/zGlobals.hpp"
36 #include "gc/z/zNMethodTable.hpp"
37 #include "gc/z/zOopClosures.inline.hpp"
38 #include "gc/z/zRootsIterator.hpp"
39 #include "gc/z/zStat.hpp"
40 #include "gc/z/zThreadLocalData.hpp"
41 #include "memory/resourceArea.hpp"
42 #include "memory/universe.hpp"
43 #include "prims/jvmtiExport.hpp"
44 #include "runtime/atomic.hpp"
45 #include "runtime/jniHandles.hpp"
46 #include "runtime/thread.hpp"
47 #include "runtime/safepoint.hpp"
48 #include "runtime/synchronizer.hpp"
49 #include "services/management.hpp"
50 #include "utilities/debug.hpp"
51 #if INCLUDE_JFR
52 #include "jfr/jfr.hpp"
53 #endif
54
55 static const ZStatSubPhase ZSubPhasePauseRootsSetup("Pause Roots Setup");
56 static const ZStatSubPhase ZSubPhasePauseRoots("Pause Roots");
158 ZCodeBlobClosure code_cl(this);
159 thread->oops_do(this, ClassUnloading ? &code_cl : NULL);
160 }
161
162 ZRootsIterator::ZRootsIterator() :
163 _universe(this),
164 _object_synchronizer(this),
165 _management(this),
166 _jvmti_export(this),
167 _jvmti_weak_export(this),
168 _system_dictionary(this),
169 _threads(this),
170 _code_cache(this) {
171 assert(SafepointSynchronize::is_at_safepoint(), "Should be at safepoint");
172 ZStatTimer timer(ZSubPhasePauseRootsSetup);
173 Threads::change_thread_claim_parity();
174 COMPILER2_PRESENT(DerivedPointerTable::clear());
175 if (ClassUnloading) {
176 nmethod::oops_do_marking_prologue();
177 } else {
178 ZNMethodTable::nmethods_do_begin();
179 }
180 }
181
182 ZRootsIterator::~ZRootsIterator() {
183 ZStatTimer timer(ZSubPhasePauseRootsTeardown);
184 ResourceMark rm;
185 if (ClassUnloading) {
186 nmethod::oops_do_marking_epilogue();
187 } else {
188 ZNMethodTable::nmethods_do_end();
189 }
190 JvmtiExport::gc_epilogue();
191
192 COMPILER2_PRESENT(DerivedPointerTable::update_pointers());
193 Threads::assert_all_threads_claimed();
194 }
195
196 void ZRootsIterator::do_universe(ZRootsIteratorClosure* cl) {
197 ZStatTimer timer(ZSubPhasePauseRootsUniverse);
198 Universe::oops_do(cl);
199 }
200
201 void ZRootsIterator::do_object_synchronizer(ZRootsIteratorClosure* cl) {
202 ZStatTimer timer(ZSubPhasePauseRootsObjectSynchronizer);
203 ObjectSynchronizer::oops_do(cl);
204 }
205
206 void ZRootsIterator::do_management(ZRootsIteratorClosure* cl) {
207 ZStatTimer timer(ZSubPhasePauseRootsManagement);
208 Management::oops_do(cl);
215
216 void ZRootsIterator::do_jvmti_weak_export(ZRootsIteratorClosure* cl) {
217 ZStatTimer timer(ZSubPhasePauseRootsJVMTIWeakExport);
218 AlwaysTrueClosure always_alive;
219 JvmtiExport::weak_oops_do(&always_alive, cl);
220 }
221
222 void ZRootsIterator::do_system_dictionary(ZRootsIteratorClosure* cl) {
223 ZStatTimer timer(ZSubPhasePauseRootsSystemDictionary);
224 SystemDictionary::oops_do(cl);
225 }
226
227 void ZRootsIterator::do_threads(ZRootsIteratorClosure* cl) {
228 ZStatTimer timer(ZSubPhasePauseRootsThreads);
229 ResourceMark rm;
230 Threads::possibly_parallel_threads_do(true, cl);
231 }
232
233 void ZRootsIterator::do_code_cache(ZRootsIteratorClosure* cl) {
234 ZStatTimer timer(ZSubPhasePauseRootsCodeCache);
235 ZNMethodTable::oops_do(cl);
236 }
237
238 void ZRootsIterator::oops_do(ZRootsIteratorClosure* cl, bool visit_jvmti_weak_export) {
239 ZStatTimer timer(ZSubPhasePauseRoots);
240 _universe.oops_do(cl);
241 _object_synchronizer.oops_do(cl);
242 _management.oops_do(cl);
243 _jvmti_export.oops_do(cl);
244 _system_dictionary.oops_do(cl);
245 _threads.oops_do(cl);
246 if (!ClassUnloading) {
247 _code_cache.oops_do(cl);
248 }
249 if (visit_jvmti_weak_export) {
250 _jvmti_weak_export.oops_do(cl);
251 }
252 }
253
254 ZConcurrentRootsIterator::ZConcurrentRootsIterator(bool marking) :
255 _marking(marking),
|
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 #include "precompiled.hpp"
25 #include "classfile/classLoaderDataGraph.hpp"
26 #include "classfile/stringTable.hpp"
27 #include "classfile/systemDictionary.hpp"
28 #include "code/codeCache.hpp"
29 #include "compiler/oopMap.hpp"
30 #include "gc/shared/barrierSet.hpp"
31 #include "gc/shared/barrierSetNMethod.hpp"
32 #include "gc/shared/oopStorageParState.inline.hpp"
33 #include "gc/shared/suspendibleThreadSet.hpp"
34 #include "gc/z/zBarrierSetNMethod.hpp"
35 #include "gc/z/zGlobals.hpp"
36 #include "gc/z/zNMethod.hpp"
37 #include "gc/z/zOopClosures.inline.hpp"
38 #include "gc/z/zRootsIterator.hpp"
39 #include "gc/z/zStat.hpp"
40 #include "gc/z/zThreadLocalData.hpp"
41 #include "memory/resourceArea.hpp"
42 #include "memory/universe.hpp"
43 #include "prims/jvmtiExport.hpp"
44 #include "runtime/atomic.hpp"
45 #include "runtime/jniHandles.hpp"
46 #include "runtime/thread.hpp"
47 #include "runtime/safepoint.hpp"
48 #include "runtime/synchronizer.hpp"
49 #include "services/management.hpp"
50 #include "utilities/debug.hpp"
51 #if INCLUDE_JFR
52 #include "jfr/jfr.hpp"
53 #endif
54
55 static const ZStatSubPhase ZSubPhasePauseRootsSetup("Pause Roots Setup");
56 static const ZStatSubPhase ZSubPhasePauseRoots("Pause Roots");
158 ZCodeBlobClosure code_cl(this);
159 thread->oops_do(this, ClassUnloading ? &code_cl : NULL);
160 }
161
162 ZRootsIterator::ZRootsIterator() :
163 _universe(this),
164 _object_synchronizer(this),
165 _management(this),
166 _jvmti_export(this),
167 _jvmti_weak_export(this),
168 _system_dictionary(this),
169 _threads(this),
170 _code_cache(this) {
171 assert(SafepointSynchronize::is_at_safepoint(), "Should be at safepoint");
172 ZStatTimer timer(ZSubPhasePauseRootsSetup);
173 Threads::change_thread_claim_parity();
174 COMPILER2_PRESENT(DerivedPointerTable::clear());
175 if (ClassUnloading) {
176 nmethod::oops_do_marking_prologue();
177 } else {
178 ZNMethod::oops_do_begin();
179 }
180 }
181
182 ZRootsIterator::~ZRootsIterator() {
183 ZStatTimer timer(ZSubPhasePauseRootsTeardown);
184 ResourceMark rm;
185 if (ClassUnloading) {
186 nmethod::oops_do_marking_epilogue();
187 } else {
188 ZNMethod::oops_do_end();
189 }
190 JvmtiExport::gc_epilogue();
191
192 COMPILER2_PRESENT(DerivedPointerTable::update_pointers());
193 Threads::assert_all_threads_claimed();
194 }
195
196 void ZRootsIterator::do_universe(ZRootsIteratorClosure* cl) {
197 ZStatTimer timer(ZSubPhasePauseRootsUniverse);
198 Universe::oops_do(cl);
199 }
200
201 void ZRootsIterator::do_object_synchronizer(ZRootsIteratorClosure* cl) {
202 ZStatTimer timer(ZSubPhasePauseRootsObjectSynchronizer);
203 ObjectSynchronizer::oops_do(cl);
204 }
205
206 void ZRootsIterator::do_management(ZRootsIteratorClosure* cl) {
207 ZStatTimer timer(ZSubPhasePauseRootsManagement);
208 Management::oops_do(cl);
215
216 void ZRootsIterator::do_jvmti_weak_export(ZRootsIteratorClosure* cl) {
217 ZStatTimer timer(ZSubPhasePauseRootsJVMTIWeakExport);
218 AlwaysTrueClosure always_alive;
219 JvmtiExport::weak_oops_do(&always_alive, cl);
220 }
221
222 void ZRootsIterator::do_system_dictionary(ZRootsIteratorClosure* cl) {
223 ZStatTimer timer(ZSubPhasePauseRootsSystemDictionary);
224 SystemDictionary::oops_do(cl);
225 }
226
227 void ZRootsIterator::do_threads(ZRootsIteratorClosure* cl) {
228 ZStatTimer timer(ZSubPhasePauseRootsThreads);
229 ResourceMark rm;
230 Threads::possibly_parallel_threads_do(true, cl);
231 }
232
233 void ZRootsIterator::do_code_cache(ZRootsIteratorClosure* cl) {
234 ZStatTimer timer(ZSubPhasePauseRootsCodeCache);
235 ZNMethod::oops_do(cl);
236 }
237
238 void ZRootsIterator::oops_do(ZRootsIteratorClosure* cl, bool visit_jvmti_weak_export) {
239 ZStatTimer timer(ZSubPhasePauseRoots);
240 _universe.oops_do(cl);
241 _object_synchronizer.oops_do(cl);
242 _management.oops_do(cl);
243 _jvmti_export.oops_do(cl);
244 _system_dictionary.oops_do(cl);
245 _threads.oops_do(cl);
246 if (!ClassUnloading) {
247 _code_cache.oops_do(cl);
248 }
249 if (visit_jvmti_weak_export) {
250 _jvmti_weak_export.oops_do(cl);
251 }
252 }
253
254 ZConcurrentRootsIterator::ZConcurrentRootsIterator(bool marking) :
255 _marking(marking),
|