74 75 static const ZStatSubPhase ZSubPhasePauseWeakRootsSetup("Pause Weak Roots Setup"); 76 static const ZStatSubPhase ZSubPhasePauseWeakRoots("Pause Weak Roots"); 77 static const ZStatSubPhase ZSubPhasePauseWeakRootsTeardown("Pause Weak Roots Teardown"); 78 static const ZStatSubPhase ZSubPhasePauseWeakRootsJVMTIWeakExport("Pause Weak Roots JVMTIWeakExport"); 79 static const ZStatSubPhase ZSubPhasePauseWeakRootsJFRWeak("Pause Weak Roots JFRWeak"); 80 81 static const ZStatSubPhase ZSubPhaseConcurrentWeakRoots("Concurrent Weak Roots"); 82 static const ZStatSubPhase ZSubPhaseConcurrentWeakRootsVMWeakHandles("Concurrent Weak Roots VMWeakHandles"); 83 static const ZStatSubPhase ZSubPhaseConcurrentWeakRootsJNIWeakHandles("Concurrent Weak Roots JNIWeakHandles"); 84 static const ZStatSubPhase ZSubPhaseConcurrentWeakRootsStringTable("Concurrent Weak Roots StringTable"); 85 static const ZStatSubPhase ZSubPhaseConcurrentWeakRootsResolvedMethodTable("Concurrent Weak Roots ResolvedMethodTable"); 86 87 template <typename T, void (T::*F)(ZRootsIteratorClosure*)> 88 ZSerialOopsDo<T, F>::ZSerialOopsDo(T* iter) : 89 _iter(iter), 90 _claimed(false) {} 91 92 template <typename T, void (T::*F)(ZRootsIteratorClosure*)> 93 void ZSerialOopsDo<T, F>::oops_do(ZRootsIteratorClosure* cl) { 94 if (!_claimed && Atomic::cmpxchg(true, &_claimed, false) == false) { 95 (_iter->*F)(cl); 96 } 97 } 98 99 template <typename T, void (T::*F)(ZRootsIteratorClosure*)> 100 ZParallelOopsDo<T, F>::ZParallelOopsDo(T* iter) : 101 _iter(iter), 102 _completed(false) {} 103 104 template <typename T, void (T::*F)(ZRootsIteratorClosure*)> 105 void ZParallelOopsDo<T, F>::oops_do(ZRootsIteratorClosure* cl) { 106 if (!_completed) { 107 (_iter->*F)(cl); 108 if (!_completed) { 109 _completed = true; 110 } 111 } 112 } 113 114 template <typename T, void (T::*F)(BoolObjectClosure*, ZRootsIteratorClosure*)> 115 ZSerialWeakOopsDo<T, F>::ZSerialWeakOopsDo(T* iter) : 116 _iter(iter), 117 _claimed(false) {} 118 119 template <typename T, void (T::*F)(BoolObjectClosure*, ZRootsIteratorClosure*)> 120 void ZSerialWeakOopsDo<T, F>::weak_oops_do(BoolObjectClosure* is_alive, ZRootsIteratorClosure* cl) { 121 if (!_claimed && Atomic::cmpxchg(true, &_claimed, false) == false) { 122 (_iter->*F)(is_alive, cl); 123 } 124 } 125 126 template <typename T, void (T::*F)(BoolObjectClosure*, ZRootsIteratorClosure*)> 127 ZParallelWeakOopsDo<T, F>::ZParallelWeakOopsDo(T* iter) : 128 _iter(iter), 129 _completed(false) {} 130 131 template <typename T, void (T::*F)(BoolObjectClosure*, ZRootsIteratorClosure*)> 132 void ZParallelWeakOopsDo<T, F>::weak_oops_do(BoolObjectClosure* is_alive, ZRootsIteratorClosure* cl) { 133 if (!_completed) { 134 (_iter->*F)(is_alive, cl); 135 if (!_completed) { 136 _completed = true; 137 } 138 } 139 } 140 141 class ZRootsIteratorCodeBlobClosure : public CodeBlobToOopClosure { | 74 75 static const ZStatSubPhase ZSubPhasePauseWeakRootsSetup("Pause Weak Roots Setup"); 76 static const ZStatSubPhase ZSubPhasePauseWeakRoots("Pause Weak Roots"); 77 static const ZStatSubPhase ZSubPhasePauseWeakRootsTeardown("Pause Weak Roots Teardown"); 78 static const ZStatSubPhase ZSubPhasePauseWeakRootsJVMTIWeakExport("Pause Weak Roots JVMTIWeakExport"); 79 static const ZStatSubPhase ZSubPhasePauseWeakRootsJFRWeak("Pause Weak Roots JFRWeak"); 80 81 static const ZStatSubPhase ZSubPhaseConcurrentWeakRoots("Concurrent Weak Roots"); 82 static const ZStatSubPhase ZSubPhaseConcurrentWeakRootsVMWeakHandles("Concurrent Weak Roots VMWeakHandles"); 83 static const ZStatSubPhase ZSubPhaseConcurrentWeakRootsJNIWeakHandles("Concurrent Weak Roots JNIWeakHandles"); 84 static const ZStatSubPhase ZSubPhaseConcurrentWeakRootsStringTable("Concurrent Weak Roots StringTable"); 85 static const ZStatSubPhase ZSubPhaseConcurrentWeakRootsResolvedMethodTable("Concurrent Weak Roots ResolvedMethodTable"); 86 87 template <typename T, void (T::*F)(ZRootsIteratorClosure*)> 88 ZSerialOopsDo<T, F>::ZSerialOopsDo(T* iter) : 89 _iter(iter), 90 _claimed(false) {} 91 92 template <typename T, void (T::*F)(ZRootsIteratorClosure*)> 93 void ZSerialOopsDo<T, F>::oops_do(ZRootsIteratorClosure* cl) { 94 if (!_claimed && Atomic::cmpxchg(&_claimed, false, true) == false) { 95 (_iter->*F)(cl); 96 } 97 } 98 99 template <typename T, void (T::*F)(ZRootsIteratorClosure*)> 100 ZParallelOopsDo<T, F>::ZParallelOopsDo(T* iter) : 101 _iter(iter), 102 _completed(false) {} 103 104 template <typename T, void (T::*F)(ZRootsIteratorClosure*)> 105 void ZParallelOopsDo<T, F>::oops_do(ZRootsIteratorClosure* cl) { 106 if (!_completed) { 107 (_iter->*F)(cl); 108 if (!_completed) { 109 _completed = true; 110 } 111 } 112 } 113 114 template <typename T, void (T::*F)(BoolObjectClosure*, ZRootsIteratorClosure*)> 115 ZSerialWeakOopsDo<T, F>::ZSerialWeakOopsDo(T* iter) : 116 _iter(iter), 117 _claimed(false) {} 118 119 template <typename T, void (T::*F)(BoolObjectClosure*, ZRootsIteratorClosure*)> 120 void ZSerialWeakOopsDo<T, F>::weak_oops_do(BoolObjectClosure* is_alive, ZRootsIteratorClosure* cl) { 121 if (!_claimed && Atomic::cmpxchg(&_claimed, false, true) == false) { 122 (_iter->*F)(is_alive, cl); 123 } 124 } 125 126 template <typename T, void (T::*F)(BoolObjectClosure*, ZRootsIteratorClosure*)> 127 ZParallelWeakOopsDo<T, F>::ZParallelWeakOopsDo(T* iter) : 128 _iter(iter), 129 _completed(false) {} 130 131 template <typename T, void (T::*F)(BoolObjectClosure*, ZRootsIteratorClosure*)> 132 void ZParallelWeakOopsDo<T, F>::weak_oops_do(BoolObjectClosure* is_alive, ZRootsIteratorClosure* cl) { 133 if (!_completed) { 134 (_iter->*F)(is_alive, cl); 135 if (!_completed) { 136 _completed = true; 137 } 138 } 139 } 140 141 class ZRootsIteratorCodeBlobClosure : public CodeBlobToOopClosure { |