< prev index next >

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

Print this page




  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  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 "code/codeCache.hpp"
  28 #include "compiler/oopMap.hpp"
  29 #include "gc/shared/barrierSet.hpp"
  30 #include "gc/shared/barrierSetNMethod.hpp"
  31 #include "gc/shared/oopStorageSet.hpp"
  32 #include "gc/shared/oopStorageParState.inline.hpp"
  33 #include "gc/shared/oopStorageSet.hpp"
  34 #include "gc/shared/suspendibleThreadSet.hpp"
  35 #include "gc/z/zBarrierSetNMethod.hpp"
  36 #include "gc/z/zGlobals.hpp"
  37 #include "gc/z/zNMethod.hpp"
  38 #include "gc/z/zOopClosures.inline.hpp"
  39 #include "gc/z/zRootsIterator.hpp"
  40 #include "gc/z/zStat.hpp"
  41 #include "gc/z/zThreadLocalData.hpp"
  42 #include "memory/iterator.hpp"
  43 #include "memory/resourceArea.hpp"
  44 #include "memory/universe.hpp"
  45 #include "prims/jvmtiExport.hpp"
  46 #include "prims/resolvedMethodTable.hpp"
  47 #include "runtime/atomic.hpp"
  48 #include "runtime/safepoint.hpp"
  49 #include "runtime/synchronizer.hpp"
  50 #include "runtime/thread.hpp"
  51 #include "runtime/vmThread.hpp"
  52 #include "services/management.hpp"
  53 #include "utilities/debug.hpp"
  54 #if INCLUDE_JFR
  55 #include "jfr/jfr.hpp"
  56 #endif
  57 
  58 static const ZStatSubPhase ZSubPhasePauseRootsSetup("Pause Roots Setup");
  59 static const ZStatSubPhase ZSubPhasePauseRoots("Pause Roots");
  60 static const ZStatSubPhase ZSubPhasePauseRootsTeardown("Pause Roots Teardown");
  61 static const ZStatSubPhase ZSubPhasePauseRootsUniverse("Pause Roots Universe");
  62 static const ZStatSubPhase ZSubPhasePauseRootsObjectSynchronizer("Pause Roots ObjectSynchronizer");
  63 static const ZStatSubPhase ZSubPhasePauseRootsManagement("Pause Roots Management");
  64 static const ZStatSubPhase ZSubPhasePauseRootsJVMTIExport("Pause Roots JVMTIExport");
  65 static const ZStatSubPhase ZSubPhasePauseRootsJVMTIWeakExport("Pause Roots JVMTIWeakExport");
  66 static const ZStatSubPhase ZSubPhasePauseRootsVMThread("Pause Roots VM Thread");
  67 static const ZStatSubPhase ZSubPhasePauseRootsJavaThreads("Pause Roots Java Threads");
  68 static const ZStatSubPhase ZSubPhasePauseRootsCodeCache("Pause Roots CodeCache");
  69 
  70 static const ZStatSubPhase ZSubPhaseConcurrentRootsSetup("Concurrent Roots Setup");
  71 static const ZStatSubPhase ZSubPhaseConcurrentRoots("Concurrent Roots");
  72 static const ZStatSubPhase ZSubPhaseConcurrentRootsTeardown("Concurrent Roots Teardown");
  73 static const ZStatSubPhase ZSubPhaseConcurrentRootsJNIHandles("Concurrent Roots JNIHandles");
  74 static const ZStatSubPhase ZSubPhaseConcurrentRootsVMHandles("Concurrent Roots VMHandles");
  75 static const ZStatSubPhase ZSubPhaseConcurrentRootsClassLoaderDataGraph("Concurrent Roots ClassLoaderDataGraph");
  76 
  77 static const ZStatSubPhase ZSubPhasePauseWeakRootsSetup("Pause Weak Roots Setup");
  78 static const ZStatSubPhase ZSubPhasePauseWeakRoots("Pause Weak Roots");
  79 static const ZStatSubPhase ZSubPhasePauseWeakRootsTeardown("Pause Weak Roots Teardown");
  80 static const ZStatSubPhase ZSubPhasePauseWeakRootsJVMTIWeakExport("Pause Weak Roots JVMTIWeakExport");
  81 static const ZStatSubPhase ZSubPhasePauseWeakRootsJFRWeak("Pause Weak Roots JFRWeak");
  82 
  83 static const ZStatSubPhase ZSubPhaseConcurrentWeakRoots("Concurrent Weak Roots");
  84 static const ZStatSubPhase ZSubPhaseConcurrentWeakRootsVMWeakHandles("Concurrent Weak Roots VMWeakHandles");
  85 static const ZStatSubPhase ZSubPhaseConcurrentWeakRootsJNIWeakHandles("Concurrent Weak Roots JNIWeakHandles");
  86 static const ZStatSubPhase ZSubPhaseConcurrentWeakRootsStringTable("Concurrent Weak Roots StringTable");
  87 static const ZStatSubPhase ZSubPhaseConcurrentWeakRootsResolvedMethodTable("Concurrent Weak Roots ResolvedMethodTable");
  88 
  89 template <typename T, void (T::*F)(ZRootsIteratorClosure*)>
  90 ZSerialOopsDo<T, F>::ZSerialOopsDo(T* iter) :
  91     _iter(iter),
  92     _claimed(false) {}
  93 
  94 template <typename T, void (T::*F)(ZRootsIteratorClosure*)>


 269   ZNMethod::oops_do(cl);
 270 }
 271 
 272 void ZRootsIterator::oops_do(ZRootsIteratorClosure* cl) {
 273   ZStatTimer timer(ZSubPhasePauseRoots);
 274   _universe.oops_do(cl);
 275   _object_synchronizer.oops_do(cl);
 276   _management.oops_do(cl);
 277   _jvmti_export.oops_do(cl);
 278   _vm_thread.oops_do(cl);
 279   _java_threads.oops_do(cl);
 280   if (!ClassUnloading) {
 281     _code_cache.oops_do(cl);
 282   }
 283   if (_visit_jvmti_weak_export) {
 284     _jvmti_weak_export.oops_do(cl);
 285   }
 286 }
 287 
 288 ZConcurrentRootsIterator::ZConcurrentRootsIterator(int cld_claim) :
 289     _jni_handles_iter(OopStorageSet::jni_global()),
 290     _vm_handles_iter(OopStorageSet::vm_global()),
 291     _cld_claim(cld_claim),
 292     _jni_handles(this),
 293     _vm_handles(this),
 294     _class_loader_data_graph(this) {
 295   ZStatTimer timer(ZSubPhaseConcurrentRootsSetup);
 296   ClassLoaderDataGraph::clear_claimed_marks(cld_claim);
 297 }
 298 
 299 ZConcurrentRootsIterator::~ZConcurrentRootsIterator() {
 300   ZStatTimer timer(ZSubPhaseConcurrentRootsTeardown);
 301 }
 302 
 303 void ZConcurrentRootsIterator::do_jni_handles(ZRootsIteratorClosure* cl) {
 304   ZStatTimer timer(ZSubPhaseConcurrentRootsJNIHandles);
 305   _jni_handles_iter.oops_do(cl);
 306 }
 307 
 308 void ZConcurrentRootsIterator::do_vm_handles(ZRootsIteratorClosure* cl) {
 309   ZStatTimer timer(ZSubPhaseConcurrentRootsVMHandles);
 310   _vm_handles_iter.oops_do(cl);
 311 }
 312 
 313 void ZConcurrentRootsIterator::do_class_loader_data_graph(ZRootsIteratorClosure* cl) {
 314   ZStatTimer timer(ZSubPhaseConcurrentRootsClassLoaderDataGraph);
 315   CLDToOopClosure cld_cl(cl, _cld_claim);
 316   ClassLoaderDataGraph::always_strong_cld_do(&cld_cl);
 317 }
 318 
 319 void ZConcurrentRootsIterator::oops_do(ZRootsIteratorClosure* cl) {
 320   ZStatTimer timer(ZSubPhaseConcurrentRoots);
 321   _jni_handles.oops_do(cl);
 322   _vm_handles.oops_do(cl),
 323   _class_loader_data_graph.oops_do(cl);
 324 }
 325 
 326 ZWeakRootsIterator::ZWeakRootsIterator() :
 327     _jvmti_weak_export(this),
 328     _jfr_weak(this) {
 329   assert(SafepointSynchronize::is_at_safepoint(), "Should be at safepoint");
 330   ZStatTimer timer(ZSubPhasePauseWeakRootsSetup);
 331 }
 332 
 333 ZWeakRootsIterator::~ZWeakRootsIterator() {
 334   ZStatTimer timer(ZSubPhasePauseWeakRootsTeardown);
 335 }
 336 
 337 void ZWeakRootsIterator::do_jvmti_weak_export(BoolObjectClosure* is_alive, ZRootsIteratorClosure* cl) {
 338   ZStatTimer timer(ZSubPhasePauseWeakRootsJVMTIWeakExport);
 339   JvmtiExport::weak_oops_do(is_alive, cl);
 340 }
 341 
 342 void ZWeakRootsIterator::do_jfr_weak(BoolObjectClosure* is_alive, ZRootsIteratorClosure* cl) {




  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  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 "code/codeCache.hpp"
  28 #include "compiler/oopMap.hpp"
  29 #include "gc/shared/barrierSet.hpp"
  30 #include "gc/shared/barrierSetNMethod.hpp"
  31 #include "gc/shared/oopStorageSet.hpp"
  32 #include "gc/shared/oopStorageParState.inline.hpp"
  33 #include "gc/shared/oopStorageSetParState.inline.hpp"
  34 #include "gc/shared/suspendibleThreadSet.hpp"
  35 #include "gc/z/zBarrierSetNMethod.hpp"
  36 #include "gc/z/zGlobals.hpp"
  37 #include "gc/z/zNMethod.hpp"
  38 #include "gc/z/zOopClosures.inline.hpp"
  39 #include "gc/z/zRootsIterator.hpp"
  40 #include "gc/z/zStat.hpp"
  41 #include "gc/z/zThreadLocalData.hpp"
  42 #include "memory/iterator.hpp"
  43 #include "memory/resourceArea.hpp"
  44 #include "memory/universe.hpp"
  45 #include "prims/jvmtiExport.hpp"
  46 #include "prims/resolvedMethodTable.hpp"
  47 #include "runtime/atomic.hpp"
  48 #include "runtime/safepoint.hpp"
  49 #include "runtime/synchronizer.hpp"
  50 #include "runtime/thread.hpp"
  51 #include "runtime/vmThread.hpp"
  52 #include "services/management.hpp"
  53 #include "utilities/debug.hpp"
  54 #if INCLUDE_JFR
  55 #include "jfr/jfr.hpp"
  56 #endif
  57 
  58 static const ZStatSubPhase ZSubPhasePauseRootsSetup("Pause Roots Setup");
  59 static const ZStatSubPhase ZSubPhasePauseRoots("Pause Roots");
  60 static const ZStatSubPhase ZSubPhasePauseRootsTeardown("Pause Roots Teardown");
  61 static const ZStatSubPhase ZSubPhasePauseRootsUniverse("Pause Roots Universe");
  62 static const ZStatSubPhase ZSubPhasePauseRootsObjectSynchronizer("Pause Roots ObjectSynchronizer");
  63 static const ZStatSubPhase ZSubPhasePauseRootsManagement("Pause Roots Management");
  64 static const ZStatSubPhase ZSubPhasePauseRootsJVMTIExport("Pause Roots JVMTIExport");
  65 static const ZStatSubPhase ZSubPhasePauseRootsJVMTIWeakExport("Pause Roots JVMTIWeakExport");
  66 static const ZStatSubPhase ZSubPhasePauseRootsVMThread("Pause Roots VM Thread");
  67 static const ZStatSubPhase ZSubPhasePauseRootsJavaThreads("Pause Roots Java Threads");
  68 static const ZStatSubPhase ZSubPhasePauseRootsCodeCache("Pause Roots CodeCache");
  69 
  70 static const ZStatSubPhase ZSubPhaseConcurrentRootsSetup("Concurrent Roots Setup");
  71 static const ZStatSubPhase ZSubPhaseConcurrentRoots("Concurrent Roots");
  72 static const ZStatSubPhase ZSubPhaseConcurrentRootsTeardown("Concurrent Roots Teardown");
  73 static const ZStatSubPhase ZSubPhaseConcurrentRootsOopStorageSet("Concurrent Roots OopStorageSet");

  74 static const ZStatSubPhase ZSubPhaseConcurrentRootsClassLoaderDataGraph("Concurrent Roots ClassLoaderDataGraph");
  75 
  76 static const ZStatSubPhase ZSubPhasePauseWeakRootsSetup("Pause Weak Roots Setup");
  77 static const ZStatSubPhase ZSubPhasePauseWeakRoots("Pause Weak Roots");
  78 static const ZStatSubPhase ZSubPhasePauseWeakRootsTeardown("Pause Weak Roots Teardown");
  79 static const ZStatSubPhase ZSubPhasePauseWeakRootsJVMTIWeakExport("Pause Weak Roots JVMTIWeakExport");
  80 static const ZStatSubPhase ZSubPhasePauseWeakRootsJFRWeak("Pause Weak Roots JFRWeak");
  81 
  82 static const ZStatSubPhase ZSubPhaseConcurrentWeakRoots("Concurrent Weak Roots");
  83 static const ZStatSubPhase ZSubPhaseConcurrentWeakRootsVMWeakHandles("Concurrent Weak Roots VMWeakHandles");
  84 static const ZStatSubPhase ZSubPhaseConcurrentWeakRootsJNIWeakHandles("Concurrent Weak Roots JNIWeakHandles");
  85 static const ZStatSubPhase ZSubPhaseConcurrentWeakRootsStringTable("Concurrent Weak Roots StringTable");
  86 static const ZStatSubPhase ZSubPhaseConcurrentWeakRootsResolvedMethodTable("Concurrent Weak Roots ResolvedMethodTable");
  87 
  88 template <typename T, void (T::*F)(ZRootsIteratorClosure*)>
  89 ZSerialOopsDo<T, F>::ZSerialOopsDo(T* iter) :
  90     _iter(iter),
  91     _claimed(false) {}
  92 
  93 template <typename T, void (T::*F)(ZRootsIteratorClosure*)>


 268   ZNMethod::oops_do(cl);
 269 }
 270 
 271 void ZRootsIterator::oops_do(ZRootsIteratorClosure* cl) {
 272   ZStatTimer timer(ZSubPhasePauseRoots);
 273   _universe.oops_do(cl);
 274   _object_synchronizer.oops_do(cl);
 275   _management.oops_do(cl);
 276   _jvmti_export.oops_do(cl);
 277   _vm_thread.oops_do(cl);
 278   _java_threads.oops_do(cl);
 279   if (!ClassUnloading) {
 280     _code_cache.oops_do(cl);
 281   }
 282   if (_visit_jvmti_weak_export) {
 283     _jvmti_weak_export.oops_do(cl);
 284   }
 285 }
 286 
 287 ZConcurrentRootsIterator::ZConcurrentRootsIterator(int cld_claim) :
 288     _oop_storage_set_iter(),

 289     _cld_claim(cld_claim),
 290     _oop_storage_set(this),

 291     _class_loader_data_graph(this) {
 292   ZStatTimer timer(ZSubPhaseConcurrentRootsSetup);
 293   ClassLoaderDataGraph::clear_claimed_marks(cld_claim);
 294 }
 295 
 296 ZConcurrentRootsIterator::~ZConcurrentRootsIterator() {
 297   ZStatTimer timer(ZSubPhaseConcurrentRootsTeardown);
 298 }
 299 
 300 void ZConcurrentRootsIterator::do_oop_storage_set(ZRootsIteratorClosure* cl) {
 301   ZStatTimer timer(ZSubPhaseConcurrentRootsOopStorageSet);
 302   _oop_storage_set_iter.oops_do(cl);





 303 }
 304 
 305 void ZConcurrentRootsIterator::do_class_loader_data_graph(ZRootsIteratorClosure* cl) {
 306   ZStatTimer timer(ZSubPhaseConcurrentRootsClassLoaderDataGraph);
 307   CLDToOopClosure cld_cl(cl, _cld_claim);
 308   ClassLoaderDataGraph::always_strong_cld_do(&cld_cl);
 309 }
 310 
 311 void ZConcurrentRootsIterator::oops_do(ZRootsIteratorClosure* cl) {
 312   ZStatTimer timer(ZSubPhaseConcurrentRoots);
 313   _oop_storage_set.oops_do(cl);

 314   _class_loader_data_graph.oops_do(cl);
 315 }
 316 
 317 ZWeakRootsIterator::ZWeakRootsIterator() :
 318     _jvmti_weak_export(this),
 319     _jfr_weak(this) {
 320   assert(SafepointSynchronize::is_at_safepoint(), "Should be at safepoint");
 321   ZStatTimer timer(ZSubPhasePauseWeakRootsSetup);
 322 }
 323 
 324 ZWeakRootsIterator::~ZWeakRootsIterator() {
 325   ZStatTimer timer(ZSubPhasePauseWeakRootsTeardown);
 326 }
 327 
 328 void ZWeakRootsIterator::do_jvmti_weak_export(BoolObjectClosure* is_alive, ZRootsIteratorClosure* cl) {
 329   ZStatTimer timer(ZSubPhasePauseWeakRootsJVMTIWeakExport);
 330   JvmtiExport::weak_oops_do(is_alive, cl);
 331 }
 332 
 333 void ZWeakRootsIterator::do_jfr_weak(BoolObjectClosure* is_alive, ZRootsIteratorClosure* cl) {


< prev index next >