< prev index next >

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

Print this page
rev 54809 : 8223215: Shenandoah: Support verifying subset of roots
rev 54810 : 8223774: Shenandoah: Refactor ShenandoahRootProcessor and family


  19  * or visit www.oracle.com if you need additional information or have any
  20  * questions.
  21  *
  22  */
  23 
  24 #ifndef SHARE_GC_SHENANDOAH_SHENANDOAHROOTPROCESSOR_HPP
  25 #define SHARE_GC_SHENANDOAH_SHENANDOAHROOTPROCESSOR_HPP
  26 
  27 #include "code/codeCache.hpp"
  28 #include "gc/shared/oopStorageParState.hpp"
  29 #include "gc/shenandoah/shenandoahCodeRoots.hpp"
  30 #include "gc/shenandoah/shenandoahHeap.hpp"
  31 #include "gc/shenandoah/shenandoahPhaseTimings.hpp"
  32 #include "gc/shared/strongRootsScope.hpp"
  33 #include "gc/shared/weakProcessor.hpp"
  34 #include "gc/shared/weakProcessorPhaseTimes.hpp"
  35 #include "gc/shared/workgroup.hpp"
  36 #include "memory/allocation.hpp"
  37 #include "memory/iterator.hpp"
  38 
  39 class ParallelCLDRootIterator {
  40 public:
  41   ParallelCLDRootIterator();
  42   void root_cld_do(CLDClosure* strong, CLDClosure* weak);






























































  43 };
  44 
  45 enum Shenandoah_process_roots_tasks {
  46   SHENANDOAH_RP_PS_Universe_oops_do,
  47   SHENANDOAH_RP_PS_JNIHandles_oops_do,
  48   SHENANDOAH_RP_PS_ObjectSynchronizer_oops_do,
  49   SHENANDOAH_RP_PS_Management_oops_do,
  50   SHENANDOAH_RP_PS_SystemDictionary_oops_do,
  51   SHENANDOAH_RP_PS_jvmti_oops_do,
  52   // Leave this one last.
  53   SHENANDOAH_RP_PS_NumElements
  54 };
  55 
  56 class ShenandoahRootProcessor : public StackObj {
  57   SubTasksDone* _process_strong_tasks;
  58   StrongRootsScope _srs;



  59   ShenandoahPhaseTimings::Phase _phase;
  60   ParallelCLDRootIterator _cld_iterator;
  61   ShenandoahAllCodeRootsIterator _coderoots_all_iterator;
  62   CodeBlobClosure* _threads_nmethods_cl;
  63   WeakProcessorPhaseTimes _weak_processor_timings;
  64   WeakProcessor::Task     _weak_processor_task;
  65   bool                    _processed_weak_roots;
  66 
  67   void process_java_roots(OopClosure* scan_non_heap_roots,
  68                           CLDClosure* scan_strong_clds,
  69                           CLDClosure* scan_weak_clds,
  70                           CodeBlobClosure* scan_strong_code,
  71                           ThreadClosure* thread_cl,
  72                           uint worker_i);
  73 
  74   void process_vm_roots(OopClosure* scan_non_heap_roots,
  75                         uint worker_i);
  76 
  77   void weak_processor_timing_to_shenandoah_timing(const WeakProcessorPhases::Phase wpp,
  78                                                   const ShenandoahPhaseTimings::GCParPhases spp,
  79                                                   ShenandoahWorkerTimings* worker_times) const;
  80 
  81 public:
  82   ShenandoahRootProcessor(ShenandoahHeap* heap, uint n_workers,
  83                           ShenandoahPhaseTimings::Phase phase);
  84   ~ShenandoahRootProcessor();
  85 
  86   // Apply oops, clds and blobs to all strongly reachable roots in the system.
  87   // Optionally, apply class loader closure to weak clds, depending on class unloading
  88   // for the particular GC cycles.
  89   void process_strong_roots(OopClosure* oops,
  90                             CLDClosure* clds,
  91                             CodeBlobClosure* blobs,
  92                             ThreadClosure* thread_cl,
  93                             uint worker_id);
  94 
  95   // Apply oops, clds and blobs to strongly reachable roots in the system
  96   void process_all_roots(OopClosure* oops,
  97                          CLDClosure* clds,
  98                          CodeBlobClosure* blobs,
  99                          ThreadClosure* thread_cl,
 100                          uint worker_id);
 101 
 102   // Apply oops, clds and blobs to strongly and weakly reachable roots in the system
 103   template <typename IsAlive>
 104   void update_all_roots(OopClosure* oops,
 105                         CLDClosure* clds,
 106                         CodeBlobClosure* blobs,
 107                         ThreadClosure* thread_cl,
 108                         uint worker_id);
 109 
 110   // Number of worker threads used by the root processor.
 111   uint n_workers() const;
 112 };
 113 

 114 class ShenandoahRootEvacuator : public StackObj {
 115   SubTasksDone* _evacuation_tasks;
 116   StrongRootsScope _srs;





 117   ShenandoahPhaseTimings::Phase _phase;
 118   ShenandoahCsetCodeRootsIterator _coderoots_cset_iterator;
 119   ParallelCLDRootIterator _cld_iterator;
 120   WeakProcessorPhaseTimes _weak_processor_timings;
 121   WeakProcessor::Task     _weak_processor_task;
 122 
 123   enum Shenandoah_evacuate_roots_tasks {
 124     SHENANDOAH_EVAC_Universe_oops_do,
 125     SHENANDOAH_EVAC_ObjectSynchronizer_oops_do,
 126     SHENANDOAH_EVAC_Management_oops_do,
 127     SHENANDOAH_EVAC_SystemDictionary_oops_do,
 128     SHENANDOAH_EVAC_jvmti_oops_do,
 129     SHENANDOAH_EVAC_JNIHandles_oops_do,
 130     // Leave this one last.
 131     SHENANDOAH_EVAC_NumElements
 132   };
 133 public:
 134   ShenandoahRootEvacuator(ShenandoahHeap* heap, uint n_workers,
 135                           ShenandoahPhaseTimings::Phase phase);
 136   ~ShenandoahRootEvacuator();
 137 
 138   void process_evacuate_roots(OopClosure* oops,
 139                               CodeBlobClosure* blobs,
 140                               uint worker_id);











 141 
 142   // Number of worker threads used by the root processor.
 143   uint n_workers() const;




 144 };



















 145 #endif // SHARE_GC_SHENANDOAH_SHENANDOAHROOTPROCESSOR_HPP


  19  * or visit www.oracle.com if you need additional information or have any
  20  * questions.
  21  *
  22  */
  23 
  24 #ifndef SHARE_GC_SHENANDOAH_SHENANDOAHROOTPROCESSOR_HPP
  25 #define SHARE_GC_SHENANDOAH_SHENANDOAHROOTPROCESSOR_HPP
  26 
  27 #include "code/codeCache.hpp"
  28 #include "gc/shared/oopStorageParState.hpp"
  29 #include "gc/shenandoah/shenandoahCodeRoots.hpp"
  30 #include "gc/shenandoah/shenandoahHeap.hpp"
  31 #include "gc/shenandoah/shenandoahPhaseTimings.hpp"
  32 #include "gc/shared/strongRootsScope.hpp"
  33 #include "gc/shared/weakProcessor.hpp"
  34 #include "gc/shared/weakProcessorPhaseTimes.hpp"
  35 #include "gc/shared/workgroup.hpp"
  36 #include "memory/allocation.hpp"
  37 #include "memory/iterator.hpp"
  38 
  39 class ShenandoahSerialRoot {
  40 public:
  41   typedef void (*OopsDo)(OopClosure*);
  42 private:
  43   volatile bool                       _claimed;
  44   OopsDo                              _oops_do;
  45   ShenandoahPhaseTimings::GCParPhases _phase;
  46 
  47 public:
  48   ShenandoahSerialRoot(OopsDo oops_do, ShenandoahPhaseTimings::GCParPhases);
  49   void oops_do(OopClosure* cl, uint worker_id);
  50 };
  51 
  52 class ShenandoahSerialRoots {
  53 private:
  54   ShenandoahSerialRoot  _universe_root;
  55   ShenandoahSerialRoot  _object_synchronizer_root;
  56   ShenandoahSerialRoot  _management_root;
  57   ShenandoahSerialRoot  _system_dictionary_root;
  58   ShenandoahSerialRoot  _jvmti_root;
  59   ShenandoahSerialRoot  _jni_handle_root;
  60 public:
  61   ShenandoahSerialRoots();
  62   void oops_do(OopClosure* cl, uint worker_id);
  63 };
  64 
  65 class ShenandoahThreadRoots {
  66 private:
  67   bool _is_par;
  68 public:
  69   ShenandoahThreadRoots(bool is_par);
  70   ~ShenandoahThreadRoots();
  71 
  72   void oops_do(OopClosure* oops_cl, CodeBlobClosure* code_cl, uint worker_id);
  73   void threads_do(ThreadClosure* tc, uint worker_id);
  74 };
  75 
  76 class ShenandoahWeakRoots {
  77 private:
  78   WeakProcessorPhaseTimes _process_timings;
  79   WeakProcessor::Task     _task;
  80 public:
  81   ShenandoahWeakRoots(uint n_workers);
  82   ~ShenandoahWeakRoots();
  83 
  84   template <typename IsAlive, typename KeepAlive>
  85   void oops_do(IsAlive* is_alive, KeepAlive* keep_alive, uint worker_id);
  86 };
  87 
  88 class ShenandoahStringDedupRoot {
  89 public:
  90   ShenandoahStringDedupRoot();
  91   ~ShenandoahStringDedupRoot();
  92 
  93   void oops_do(BoolObjectClosure* is_alive, OopClosure* keep_alive, uint worker_id);
  94 };
  95 
  96 template <typename ITR>
  97 class ShenandoahCodeCacheRoot {
  98 private:
  99   ITR _coderoots_iterator;
 100 public:
 101   ShenandoahCodeCacheRoot();
 102   ~ShenandoahCodeCacheRoot();
 103 
 104   void code_blobs_do(CodeBlobClosure* blob_cl, uint worker_id);
 105 };
 106 
 107 class ShenandoahClassLoaderDataRoot {
 108 public:
 109   ShenandoahClassLoaderDataRoot();
 110 
 111   void clds_do(CLDClosure* strong_clds, CLDClosure* weak_clds, uint worker_id);




 112 };
 113 
 114 class ShenandoahRootProcessor : public StackObj {
 115 private:
 116   ShenandoahSerialRoots         _serial_roots;
 117   ShenandoahClassLoaderDataRoot _cld_roots;
 118   ShenandoahThreadRoots         _thread_roots;
 119   ShenandoahCodeCacheRoot<ShenandoahAllCodeRootsIterator> _code_roots;
 120   ShenandoahPhaseTimings::Phase _phase;





















 121 public:
 122   ShenandoahRootProcessor(uint n_workers, ShenandoahPhaseTimings::Phase phase);

 123   ~ShenandoahRootProcessor();
 124 
 125   // Apply oops, clds and blobs to all strongly reachable roots in the system,
 126   // during class unloading cycle
 127   void strong_roots_do(uint worker_id, OopClosure* cl);
 128   void strong_roots_do(uint worker_id, OopClosure* oops, CLDClosure* clds, CodeBlobClosure* code, ThreadClosure* tc = NULL);
 129 
 130   // Apply oops, clds and blobs to all strongly reachable roots and weakly reachable
 131   // roots when class unloading is disabled during this cycle
 132   void roots_do(uint worker_id, OopClosure* cl);
 133   void roots_do(uint worker_id, OopClosure* oops, CLDClosure* clds, CodeBlobClosure* code, ThreadClosure* tc = NULL);

















 134 };
 135 
 136 // Evacuate all roots at a safepoint
 137 class ShenandoahRootEvacuator : public StackObj {
 138 private:
 139   ShenandoahSerialRoots         _serial_roots;
 140   ShenandoahClassLoaderDataRoot _cld_roots;
 141   ShenandoahThreadRoots         _thread_roots;
 142   ShenandoahWeakRoots           _weak_roots;
 143   ShenandoahStringDedupRoot     _dedup_roots;
 144   ShenandoahCodeCacheRoot<ShenandoahCsetCodeRootsIterator> _code_roots;
 145   ShenandoahPhaseTimings::Phase _phase;
 146 














 147 public:
 148   ShenandoahRootEvacuator(uint n_workers, ShenandoahPhaseTimings::Phase phase);

 149   ~ShenandoahRootEvacuator();
 150 
 151   void roots_do(uint worker_id, OopClosure* oops);
 152 };
 153 
 154 // Update all roots at a safepoint
 155 class ShenandoahRootUpdater : public StackObj {
 156 private:
 157   ShenandoahSerialRoots         _serial_roots;
 158   ShenandoahClassLoaderDataRoot _cld_roots;
 159   ShenandoahThreadRoots         _thread_roots;
 160   ShenandoahWeakRoots           _weak_roots;
 161   ShenandoahStringDedupRoot     _dedup_roots;
 162   ShenandoahCodeCacheRoot<ShenandoahCsetCodeRootsIterator> _code_roots;
 163   ShenandoahPhaseTimings::Phase _phase;
 164   bool                          _update_code_cache;
 165 
 166 public:
 167   ShenandoahRootUpdater(uint n_workers, ShenandoahPhaseTimings::Phase phase, bool update_code_cache);
 168   ~ShenandoahRootUpdater();
 169 
 170   template<typename IsAlive, typename KeepAlive>
 171   void roots_do(uint worker_id, IsAlive* is_alive, KeepAlive* keep_alive);
 172 };
 173 
 174 // Adjuster all roots at a safepoint during full gc
 175 class ShenandoahRootAdjuster : public StackObj {
 176 private:
 177   ShenandoahSerialRoots         _serial_roots;
 178   ShenandoahClassLoaderDataRoot _cld_roots;
 179   ShenandoahThreadRoots         _thread_roots;
 180   ShenandoahWeakRoots           _weak_roots;
 181   ShenandoahStringDedupRoot     _dedup_roots;
 182   ShenandoahCodeCacheRoot<ShenandoahAllCodeRootsIterator> _code_roots;
 183   ShenandoahPhaseTimings::Phase _phase;
 184 
 185 public:
 186   ShenandoahRootAdjuster(uint n_workers, ShenandoahPhaseTimings::Phase phase);
 187   ~ShenandoahRootAdjuster();
 188 
 189   void roots_do(uint worker_id, OopClosure* oops);
 190 };
 191 
 192 #endif // SHARE_GC_SHENANDOAH_SHENANDOAHROOTPROCESSOR_HPP
< prev index next >