< prev index next >

src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.hpp

Print this page
rev 55921 : 8229213: Shenandoah: Allow VM global oop storage to be processed concurrently


  76 };
  77 #endif // INCLUDE_JVMTI
  78 
  79 #if INCLUDE_JFR
  80 class ShenandoahJFRWeakRoot : public ShenandoahWeakSerialRoot {
  81 public:
  82   ShenandoahJFRWeakRoot();
  83 };
  84 #endif // INCLUDE_JFR
  85 
  86 class ShenandoahSerialWeakRoots {
  87 private:
  88   JVMTI_ONLY(ShenandoahJVMTIWeakRoot _jvmti_weak_roots;)
  89   JFR_ONLY(ShenandoahJFRWeakRoot     _jfr_weak_roots;)
  90 public:
  91   void weak_oops_do(BoolObjectClosure* is_alive, OopClosure* keep_alive, uint worker_id);
  92   void weak_oops_do(OopClosure* cl, uint worker_id);
  93 };
  94 
  95 template <bool CONCURRENT>
  96 class ShenandoahWeakRoot {
  97 private:
  98   OopStorage::ParState<CONCURRENT, false /* is_const */> _itr;
  99   const ShenandoahPhaseTimings::GCParPhases _phase;
 100 public:
 101   ShenandoahWeakRoot(OopStorage* storage, ShenandoahPhaseTimings::GCParPhases phase);
 102 
 103   template <typename Closure>
 104   void oops_do(Closure* cl, uint worker_id);
 105 };
 106 






 107 template <>
 108 class ShenandoahWeakRoot<false /*concurrent*/> {
 109 private:
 110   OopStorage::ParState<false /*concurrent*/, false /*is_const*/> _itr;
 111   const ShenandoahPhaseTimings::GCParPhases _phase;
 112 
 113 public:
 114   ShenandoahWeakRoot(OopStorage* storage, ShenandoahPhaseTimings::GCParPhases phase);
 115 
 116   template <typename IsAliveClosure, typename KeepAliveClosure>
 117   void weak_oops_do(IsAliveClosure* is_alive, KeepAliveClosure* keep_alive, uint worker_id);
 118 };
 119 
 120 template <bool CONCURRENT>
 121 class ShenandoahWeakRoots {
 122 private:
 123   ShenandoahWeakRoot<CONCURRENT>  _jni_roots;
 124   ShenandoahWeakRoot<CONCURRENT>  _string_table_roots;
 125   ShenandoahWeakRoot<CONCURRENT>  _resolved_method_table_roots;
 126   ShenandoahWeakRoot<CONCURRENT>  _vm_roots;


 133 };
 134 
 135 template <>
 136 class ShenandoahWeakRoots<false /*concurrent */> {
 137 private:
 138   ShenandoahWeakRoot<false /*concurrent*/>  _jni_roots;
 139   ShenandoahWeakRoot<false /*concurrent*/>  _string_table_roots;
 140   ShenandoahWeakRoot<false /*concurrent*/>  _resolved_method_table_roots;
 141   ShenandoahWeakRoot<false /*concurrent*/>  _vm_roots;
 142 public:
 143   ShenandoahWeakRoots();
 144 
 145   template <typename Closure>
 146   void oops_do(Closure* cl, uint worker_id = 0);
 147 
 148   template <typename IsAliveClosure, typename KeepAliveClosure>
 149   void weak_oops_do(IsAliveClosure* is_alive, KeepAliveClosure* keep_alive, uint worker_id);
 150 };
 151 
 152 template <bool CONCURRENT>
 153 class ShenandoahJNIHandleRoots {
 154 private:
 155   OopStorage::ParState<CONCURRENT, false /*is_const*/> _itr;


 156 public:
 157   ShenandoahJNIHandleRoots();
 158 
 159   template <typename T>
 160   void oops_do(T* cl, uint worker_id = 0);
 161 };
 162 
 163 class ShenandoahThreadRoots {
 164 private:
 165   const bool _is_par;
 166 public:
 167   ShenandoahThreadRoots(bool is_par);
 168   ~ShenandoahThreadRoots();
 169 
 170   void oops_do(OopClosure* oops_cl, CodeBlobClosure* code_cl, uint worker_id);
 171   void threads_do(ThreadClosure* tc, uint worker_id);
 172 };
 173 
 174 class ShenandoahStringDedupRoots {
 175 public:
 176   ShenandoahStringDedupRoots();
 177   ~ShenandoahStringDedupRoots();


 200   void cld_do(CLDClosure* clds, uint worker_id = 0);
 201 };
 202 
 203 class ShenandoahRootProcessor : public StackObj {
 204 private:
 205   ShenandoahHeap* const               _heap;
 206   const ShenandoahPhaseTimings::Phase _phase;
 207 public:
 208   ShenandoahRootProcessor(ShenandoahPhaseTimings::Phase phase);
 209   ~ShenandoahRootProcessor();
 210 
 211   ShenandoahHeap* heap() const { return _heap; }
 212 };
 213 
 214 template <typename ITR>
 215 class ShenandoahRootScanner : public ShenandoahRootProcessor {
 216 private:
 217   ShenandoahSerialRoots                                     _serial_roots;
 218   ShenandoahThreadRoots                                     _thread_roots;
 219   ShenandoahCodeCacheRoots<ITR>                             _code_roots;
 220   ShenandoahJNIHandleRoots<false /*concurrent*/ >           _jni_roots;
 221   ShenandoahClassLoaderDataRoots<false /*concurrent*/, false /*single threaded*/>
 222                                                             _cld_roots;
 223 public:
 224   ShenandoahRootScanner(uint n_workers, ShenandoahPhaseTimings::Phase phase);
 225 
 226   // Apply oops, clds and blobs to all strongly reachable roots in the system,
 227   // during class unloading cycle
 228   void strong_roots_do(uint worker_id, OopClosure* cl);
 229   void strong_roots_do(uint worker_id, OopClosure* oops, CLDClosure* clds, CodeBlobClosure* code, ThreadClosure* tc = NULL);
 230 
 231   // Apply oops, clds and blobs to all strongly reachable roots and weakly reachable
 232   // roots when class unloading is disabled during this cycle
 233   void roots_do(uint worker_id, OopClosure* cl);
 234   void roots_do(uint worker_id, OopClosure* oops, CLDClosure* clds, CodeBlobClosure* code, ThreadClosure* tc = NULL);
 235 };
 236 
 237 typedef ShenandoahRootScanner<ShenandoahAllCodeRootsIterator> ShenandoahAllRootScanner;
 238 typedef ShenandoahRootScanner<ShenandoahCsetCodeRootsIterator> ShenandoahCSetRootScanner;
 239 
 240 // This scanner is only for SH::object_iteration() and only supports single-threaded
 241 // root scanning
 242 class ShenandoahHeapIterationRootScanner : public ShenandoahRootProcessor {
 243 private:
 244   ShenandoahSerialRoots                                    _serial_roots;
 245   ShenandoahThreadRoots                                    _thread_roots;
 246   ShenandoahJNIHandleRoots<false /*concurrent*/>           _jni_roots;
 247   ShenandoahClassLoaderDataRoots<false /*concurrent*/, true /*single threaded*/>
 248                                                            _cld_roots;
 249   ShenandoahCodeCacheRoots<ShenandoahAllCodeRootsIterator> _code_roots;
 250 
 251 public:
 252   ShenandoahHeapIterationRootScanner();
 253 
 254   void roots_do(OopClosure* cl);
 255   void strong_roots_do(OopClosure* cl);
 256 };
 257 
 258 // Evacuate all roots at a safepoint
 259 class ShenandoahRootEvacuator : public ShenandoahRootProcessor {
 260 private:
 261   ShenandoahSerialRoots                                     _serial_roots;
 262   ShenandoahJNIHandleRoots<false /*concurrent*/>            _jni_roots;
 263   ShenandoahClassLoaderDataRoots<false /*concurrent*/, false /*single threaded*/>
 264                                                             _cld_roots;
 265   ShenandoahThreadRoots                                     _thread_roots;
 266   ShenandoahSerialWeakRoots                                 _serial_weak_roots;
 267   ShenandoahWeakRoots<false /*concurrent*/>                 _weak_roots;
 268   ShenandoahStringDedupRoots                                _dedup_roots;
 269   ShenandoahCodeCacheRoots<ShenandoahCsetCodeRootsIterator> _code_roots;
 270   bool                                                      _include_concurrent_roots;
 271 
 272 public:
 273   ShenandoahRootEvacuator(uint n_workers, ShenandoahPhaseTimings::Phase phase, bool include_concurrent_roots);
 274 
 275   void roots_do(uint worker_id, OopClosure* oops);
 276 };
 277 
 278 // Update all roots at a safepoint
 279 class ShenandoahRootUpdater : public ShenandoahRootProcessor {
 280 private:
 281   ShenandoahSerialRoots                                     _serial_roots;
 282   ShenandoahJNIHandleRoots<false /*concurrent*/>            _jni_roots;
 283   ShenandoahClassLoaderDataRoots<false /*concurrent*/, false /*single threaded*/>
 284                                                             _cld_roots;
 285   ShenandoahThreadRoots                                     _thread_roots;
 286   ShenandoahSerialWeakRoots                                 _serial_weak_roots;
 287   ShenandoahWeakRoots<false /*concurrent*/>                 _weak_roots;
 288   ShenandoahStringDedupRoots                                _dedup_roots;
 289   ShenandoahCodeCacheRoots<ShenandoahCsetCodeRootsIterator> _code_roots;
 290   const bool                                                _update_code_cache;
 291 
 292 public:
 293   ShenandoahRootUpdater(uint n_workers, ShenandoahPhaseTimings::Phase phase, bool update_code_cache);
 294 
 295   template<typename IsAlive, typename KeepAlive>
 296   void roots_do(uint worker_id, IsAlive* is_alive, KeepAlive* keep_alive);
 297 };
 298 
 299 // Adjuster all roots at a safepoint during full gc
 300 class ShenandoahRootAdjuster : public ShenandoahRootProcessor {
 301 private:
 302   ShenandoahSerialRoots                                     _serial_roots;
 303   ShenandoahJNIHandleRoots<false /*concurrent*/>            _jni_roots;
 304   ShenandoahClassLoaderDataRoots<false /*concurrent*/, false /*single threaded*/>
 305                                                             _cld_roots;
 306   ShenandoahThreadRoots                                     _thread_roots;
 307   ShenandoahSerialWeakRoots                                 _serial_weak_roots;
 308   ShenandoahWeakRoots<false /*concurrent*/>                 _weak_roots;
 309   ShenandoahStringDedupRoots                                _dedup_roots;
 310   ShenandoahCodeCacheRoots<ShenandoahAllCodeRootsIterator>  _code_roots;
 311 
 312 public:
 313   ShenandoahRootAdjuster(uint n_workers, ShenandoahPhaseTimings::Phase phase);
 314 
 315   void roots_do(uint worker_id, OopClosure* oops);
 316 };
 317 
 318 #endif // SHARE_GC_SHENANDOAH_SHENANDOAHROOTPROCESSOR_HPP


  76 };
  77 #endif // INCLUDE_JVMTI
  78 
  79 #if INCLUDE_JFR
  80 class ShenandoahJFRWeakRoot : public ShenandoahWeakSerialRoot {
  81 public:
  82   ShenandoahJFRWeakRoot();
  83 };
  84 #endif // INCLUDE_JFR
  85 
  86 class ShenandoahSerialWeakRoots {
  87 private:
  88   JVMTI_ONLY(ShenandoahJVMTIWeakRoot _jvmti_weak_roots;)
  89   JFR_ONLY(ShenandoahJFRWeakRoot     _jfr_weak_roots;)
  90 public:
  91   void weak_oops_do(BoolObjectClosure* is_alive, OopClosure* keep_alive, uint worker_id);
  92   void weak_oops_do(OopClosure* cl, uint worker_id);
  93 };
  94 
  95 template <bool CONCURRENT>
  96 class ShenandoahVMRoot {
  97 private:
  98   OopStorage::ParState<CONCURRENT, false /* is_const */> _itr;
  99   const ShenandoahPhaseTimings::GCParPhases _phase;
 100 public:
 101   ShenandoahVMRoot(OopStorage* storage, ShenandoahPhaseTimings::GCParPhases phase);
 102 
 103   template <typename Closure>
 104   void oops_do(Closure* cl, uint worker_id);
 105 };
 106 
 107 template <bool CONCURRENT>
 108 class ShenandoahWeakRoot : public ShenandoahVMRoot<CONCURRENT> {
 109 public:
 110   ShenandoahWeakRoot(OopStorage* storage, ShenandoahPhaseTimings::GCParPhases phase);
 111 };
 112 
 113 template <>
 114 class ShenandoahWeakRoot<false /*concurrent*/> {
 115 private:
 116   OopStorage::ParState<false /*concurrent*/, false /*is_const*/> _itr;
 117   const ShenandoahPhaseTimings::GCParPhases _phase;
 118 
 119 public:
 120   ShenandoahWeakRoot(OopStorage* storage, ShenandoahPhaseTimings::GCParPhases phase);
 121 
 122   template <typename IsAliveClosure, typename KeepAliveClosure>
 123   void weak_oops_do(IsAliveClosure* is_alive, KeepAliveClosure* keep_alive, uint worker_id);
 124 };
 125 
 126 template <bool CONCURRENT>
 127 class ShenandoahWeakRoots {
 128 private:
 129   ShenandoahWeakRoot<CONCURRENT>  _jni_roots;
 130   ShenandoahWeakRoot<CONCURRENT>  _string_table_roots;
 131   ShenandoahWeakRoot<CONCURRENT>  _resolved_method_table_roots;
 132   ShenandoahWeakRoot<CONCURRENT>  _vm_roots;


 139 };
 140 
 141 template <>
 142 class ShenandoahWeakRoots<false /*concurrent */> {
 143 private:
 144   ShenandoahWeakRoot<false /*concurrent*/>  _jni_roots;
 145   ShenandoahWeakRoot<false /*concurrent*/>  _string_table_roots;
 146   ShenandoahWeakRoot<false /*concurrent*/>  _resolved_method_table_roots;
 147   ShenandoahWeakRoot<false /*concurrent*/>  _vm_roots;
 148 public:
 149   ShenandoahWeakRoots();
 150 
 151   template <typename Closure>
 152   void oops_do(Closure* cl, uint worker_id = 0);
 153 
 154   template <typename IsAliveClosure, typename KeepAliveClosure>
 155   void weak_oops_do(IsAliveClosure* is_alive, KeepAliveClosure* keep_alive, uint worker_id);
 156 };
 157 
 158 template <bool CONCURRENT>
 159 class ShenandoahVMRoots {
 160 private:
 161   ShenandoahVMRoot<CONCURRENT>    _jni_handle_roots;
 162   ShenandoahVMRoot<CONCURRENT>    _vm_global_roots;
 163 
 164 public:
 165   ShenandoahVMRoots();
 166 
 167   template <typename T>
 168   void oops_do(T* cl, uint worker_id = 0);
 169 };
 170 
 171 class ShenandoahThreadRoots {
 172 private:
 173   const bool _is_par;
 174 public:
 175   ShenandoahThreadRoots(bool is_par);
 176   ~ShenandoahThreadRoots();
 177 
 178   void oops_do(OopClosure* oops_cl, CodeBlobClosure* code_cl, uint worker_id);
 179   void threads_do(ThreadClosure* tc, uint worker_id);
 180 };
 181 
 182 class ShenandoahStringDedupRoots {
 183 public:
 184   ShenandoahStringDedupRoots();
 185   ~ShenandoahStringDedupRoots();


 208   void cld_do(CLDClosure* clds, uint worker_id = 0);
 209 };
 210 
 211 class ShenandoahRootProcessor : public StackObj {
 212 private:
 213   ShenandoahHeap* const               _heap;
 214   const ShenandoahPhaseTimings::Phase _phase;
 215 public:
 216   ShenandoahRootProcessor(ShenandoahPhaseTimings::Phase phase);
 217   ~ShenandoahRootProcessor();
 218 
 219   ShenandoahHeap* heap() const { return _heap; }
 220 };
 221 
 222 template <typename ITR>
 223 class ShenandoahRootScanner : public ShenandoahRootProcessor {
 224 private:
 225   ShenandoahSerialRoots                                     _serial_roots;
 226   ShenandoahThreadRoots                                     _thread_roots;
 227   ShenandoahCodeCacheRoots<ITR>                             _code_roots;
 228   ShenandoahVMRoots<false /*concurrent*/ >                  _vm_roots;
 229   ShenandoahClassLoaderDataRoots<false /*concurrent*/, false /*single threaded*/>
 230                                                             _cld_roots;
 231 public:
 232   ShenandoahRootScanner(uint n_workers, ShenandoahPhaseTimings::Phase phase);
 233 
 234   // Apply oops, clds and blobs to all strongly reachable roots in the system,
 235   // during class unloading cycle
 236   void strong_roots_do(uint worker_id, OopClosure* cl);
 237   void strong_roots_do(uint worker_id, OopClosure* oops, CLDClosure* clds, CodeBlobClosure* code, ThreadClosure* tc = NULL);
 238 
 239   // Apply oops, clds and blobs to all strongly reachable roots and weakly reachable
 240   // roots when class unloading is disabled during this cycle
 241   void roots_do(uint worker_id, OopClosure* cl);
 242   void roots_do(uint worker_id, OopClosure* oops, CLDClosure* clds, CodeBlobClosure* code, ThreadClosure* tc = NULL);
 243 };
 244 
 245 typedef ShenandoahRootScanner<ShenandoahAllCodeRootsIterator> ShenandoahAllRootScanner;
 246 typedef ShenandoahRootScanner<ShenandoahCsetCodeRootsIterator> ShenandoahCSetRootScanner;
 247 
 248 // This scanner is only for SH::object_iteration() and only supports single-threaded
 249 // root scanning
 250 class ShenandoahHeapIterationRootScanner : public ShenandoahRootProcessor {
 251 private:
 252   ShenandoahSerialRoots                                    _serial_roots;
 253   ShenandoahThreadRoots                                    _thread_roots;
 254   ShenandoahVMRoots<false /*concurrent*/>                  _vm_roots;
 255   ShenandoahClassLoaderDataRoots<false /*concurrent*/, true /*single threaded*/>
 256                                                            _cld_roots;
 257   ShenandoahCodeCacheRoots<ShenandoahAllCodeRootsIterator> _code_roots;
 258 
 259 public:
 260   ShenandoahHeapIterationRootScanner();
 261 
 262   void roots_do(OopClosure* cl);
 263   void strong_roots_do(OopClosure* cl);
 264 };
 265 
 266 // Evacuate all roots at a safepoint
 267 class ShenandoahRootEvacuator : public ShenandoahRootProcessor {
 268 private:
 269   ShenandoahSerialRoots                                     _serial_roots;
 270   ShenandoahVMRoots<false /*concurrent*/>                   _vm_roots;
 271   ShenandoahClassLoaderDataRoots<false /*concurrent*/, false /*single threaded*/>
 272                                                             _cld_roots;
 273   ShenandoahThreadRoots                                     _thread_roots;
 274   ShenandoahSerialWeakRoots                                 _serial_weak_roots;
 275   ShenandoahWeakRoots<false /*concurrent*/>                 _weak_roots;
 276   ShenandoahStringDedupRoots                                _dedup_roots;
 277   ShenandoahCodeCacheRoots<ShenandoahCsetCodeRootsIterator> _code_roots;
 278   bool                                                      _include_concurrent_roots;
 279 
 280 public:
 281   ShenandoahRootEvacuator(uint n_workers, ShenandoahPhaseTimings::Phase phase, bool include_concurrent_roots);
 282 
 283   void roots_do(uint worker_id, OopClosure* oops);
 284 };
 285 
 286 // Update all roots at a safepoint
 287 class ShenandoahRootUpdater : public ShenandoahRootProcessor {
 288 private:
 289   ShenandoahSerialRoots                                     _serial_roots;
 290   ShenandoahVMRoots<false /*concurrent*/>                   _vm_roots;
 291   ShenandoahClassLoaderDataRoots<false /*concurrent*/, false /*single threaded*/>
 292                                                             _cld_roots;
 293   ShenandoahThreadRoots                                     _thread_roots;
 294   ShenandoahSerialWeakRoots                                 _serial_weak_roots;
 295   ShenandoahWeakRoots<false /*concurrent*/>                 _weak_roots;
 296   ShenandoahStringDedupRoots                                _dedup_roots;
 297   ShenandoahCodeCacheRoots<ShenandoahCsetCodeRootsIterator> _code_roots;
 298   const bool                                                _update_code_cache;
 299 
 300 public:
 301   ShenandoahRootUpdater(uint n_workers, ShenandoahPhaseTimings::Phase phase, bool update_code_cache);
 302 
 303   template<typename IsAlive, typename KeepAlive>
 304   void roots_do(uint worker_id, IsAlive* is_alive, KeepAlive* keep_alive);
 305 };
 306 
 307 // Adjuster all roots at a safepoint during full gc
 308 class ShenandoahRootAdjuster : public ShenandoahRootProcessor {
 309 private:
 310   ShenandoahSerialRoots                                     _serial_roots;
 311   ShenandoahVMRoots<false /*concurrent*/>                   _vm_roots;
 312   ShenandoahClassLoaderDataRoots<false /*concurrent*/, false /*single threaded*/>
 313                                                             _cld_roots;
 314   ShenandoahThreadRoots                                     _thread_roots;
 315   ShenandoahSerialWeakRoots                                 _serial_weak_roots;
 316   ShenandoahWeakRoots<false /*concurrent*/>                 _weak_roots;
 317   ShenandoahStringDedupRoots                                _dedup_roots;
 318   ShenandoahCodeCacheRoots<ShenandoahAllCodeRootsIterator>  _code_roots;
 319 
 320 public:
 321   ShenandoahRootAdjuster(uint n_workers, ShenandoahPhaseTimings::Phase phase);
 322 
 323   void roots_do(uint worker_id, OopClosure* oops);
 324 };
 325 
 326 #endif // SHARE_GC_SHENANDOAH_SHENANDOAHROOTPROCESSOR_HPP
< prev index next >