< prev index next >

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

Print this page




  74   ShenandoahRegionIterator(ShenandoahHeap* heap);
  75 
  76   // Reset iterator to default state
  77   void reset();
  78 
  79   // Returns next region, or NULL if there are no more regions.
  80   // This is multi-thread-safe.
  81   inline ShenandoahHeapRegion* next();
  82 
  83   // This is *not* MT safe. However, in the absence of multithreaded access, it
  84   // can be used to determine if there is more work to do.
  85   bool has_next() const;
  86 };
  87 
  88 class ShenandoahHeapRegionClosure : public StackObj {
  89 public:
  90   virtual void heap_region_do(ShenandoahHeapRegion* r) = 0;
  91   virtual bool is_thread_safe() { return false; }
  92 };
  93 













  94 #ifdef ASSERT
  95 class ShenandoahAssertToSpaceClosure : public OopClosure {
  96 private:
  97   template <class T>
  98   void do_oop_work(T* p);
  99 public:
 100   void do_oop(narrowOop* p);
 101   void do_oop(oop* p);
 102 };
 103 #endif
 104 




























 105 
 106 // Shenandoah GC is low-pause concurrent GC that uses Brooks forwarding pointers
 107 // to encode forwarding data. See BrooksPointer for details on forwarding data encoding.
 108 // See ShenandoahControlThread for GC cycle structure.
 109 //
 110 class ShenandoahHeap : public CollectedHeap {
 111   friend class ShenandoahAsserts;
 112   friend class VMStructs;
 113   friend class ShenandoahGCSession;
 114 
 115 // ---------- Locks that guard important data structures in Heap
 116 //
 117 private:
 118   ShenandoahHeapLock _lock;
 119 
 120 public:
 121   ShenandoahHeapLock* lock() {
 122     return &_lock;
 123   }
 124 


 140   void post_initialize();
 141   void initialize_heuristics();
 142 
 143   void initialize_serviceability();
 144 
 145   void print_on(outputStream* st)              const;
 146   void print_extended_on(outputStream *st)     const;
 147   void print_tracing_info()                    const;
 148   void print_gc_threads_on(outputStream* st)   const;
 149   void print_heap_regions_on(outputStream* st) const;
 150 
 151   void stop();
 152 
 153   void prepare_for_verify();
 154   void verify(VerifyOption vo);
 155 
 156 // ---------- Heap counters and metrics
 157 //
 158 private:
 159            size_t _initial_size;
 160            size_t _minimum_size;
 161   DEFINE_PAD_MINUS_SIZE(0, DEFAULT_CACHE_LINE_SIZE, sizeof(volatile size_t));
 162   volatile size_t _used;
 163   volatile size_t _committed;
 164   volatile size_t _bytes_allocated_since_gc_start;
 165   DEFINE_PAD_MINUS_SIZE(1, DEFAULT_CACHE_LINE_SIZE, 0);
 166 
 167 public:
 168   void increase_used(size_t bytes);
 169   void decrease_used(size_t bytes);
 170   void set_used(size_t bytes);
 171 
 172   void increase_committed(size_t bytes);
 173   void decrease_committed(size_t bytes);
 174   void increase_allocated(size_t bytes);
 175 
 176   size_t bytes_allocated_since_gc_start();
 177   void reset_bytes_allocated_since_gc_start();
 178 
 179   size_t min_capacity()     const;
 180   size_t max_capacity()     const;
 181   size_t initial_capacity() const;
 182   size_t capacity()         const;
 183   size_t used()             const;
 184   size_t committed()        const;
 185 
 186 // ---------- Workers handling
 187 //
 188 private:
 189   uint _max_workers;
 190   ShenandoahWorkGang* _workers;
 191   ShenandoahWorkGang* _safepoint_workers;
 192 
 193 public:
 194   uint max_workers();
 195   void assert_gc_workers(uint nworker) NOT_DEBUG_RETURN;
 196 
 197   WorkGang* workers() const;
 198   WorkGang* get_safepoint_workers();
 199 




  74   ShenandoahRegionIterator(ShenandoahHeap* heap);
  75 
  76   // Reset iterator to default state
  77   void reset();
  78 
  79   // Returns next region, or NULL if there are no more regions.
  80   // This is multi-thread-safe.
  81   inline ShenandoahHeapRegion* next();
  82 
  83   // This is *not* MT safe. However, in the absence of multithreaded access, it
  84   // can be used to determine if there is more work to do.
  85   bool has_next() const;
  86 };
  87 
  88 class ShenandoahHeapRegionClosure : public StackObj {
  89 public:
  90   virtual void heap_region_do(ShenandoahHeapRegion* r) = 0;
  91   virtual bool is_thread_safe() { return false; }
  92 };
  93 
  94 class ShenandoahUpdateRefsClosure: public OopClosure {
  95 private:
  96   ShenandoahHeap* _heap;
  97 
  98   template <class T>
  99   inline void do_oop_work(T* p);
 100 
 101 public:
 102   ShenandoahUpdateRefsClosure();
 103   inline void do_oop(oop* p);
 104   inline void do_oop(narrowOop* p);
 105 };
 106 
 107 #ifdef ASSERT
 108 class ShenandoahAssertToSpaceClosure : public OopClosure {
 109 private:
 110   template <class T>
 111   void do_oop_work(T* p);
 112 public:
 113   void do_oop(narrowOop* p);
 114   void do_oop(oop* p);
 115 };
 116 #endif
 117 
 118 class ShenandoahAlwaysTrueClosure : public BoolObjectClosure {
 119 public:
 120   bool do_object_b(oop p) { return true; }
 121 };
 122 
 123 class ShenandoahForwardedIsAliveClosure: public BoolObjectClosure {
 124 private:
 125   ShenandoahMarkingContext* const _mark_context;
 126 public:
 127   ShenandoahForwardedIsAliveClosure();
 128   bool do_object_b(oop obj);
 129 };
 130 
 131 class ShenandoahIsAliveClosure: public BoolObjectClosure {
 132 private:
 133   ShenandoahMarkingContext* const _mark_context;
 134 public:
 135   ShenandoahIsAliveClosure();
 136   bool do_object_b(oop obj);
 137 };
 138 
 139 class ShenandoahIsAliveSelector : public StackObj {
 140 private:
 141   ShenandoahIsAliveClosure _alive_cl;
 142   ShenandoahForwardedIsAliveClosure _fwd_alive_cl;
 143 public:
 144   BoolObjectClosure* is_alive_closure();
 145 };
 146 
 147 // Shenandoah GC is low-pause concurrent GC that uses Brooks forwarding pointers
 148 // to encode forwarding data. See BrooksPointer for details on forwarding data encoding.
 149 // See ShenandoahControlThread for GC cycle structure.
 150 //
 151 class ShenandoahHeap : public CollectedHeap {
 152   friend class ShenandoahAsserts;
 153   friend class VMStructs;
 154   friend class ShenandoahGCSession;
 155 
 156 // ---------- Locks that guard important data structures in Heap
 157 //
 158 private:
 159   ShenandoahHeapLock _lock;
 160 
 161 public:
 162   ShenandoahHeapLock* lock() {
 163     return &_lock;
 164   }
 165 


 181   void post_initialize();
 182   void initialize_heuristics();
 183 
 184   void initialize_serviceability();
 185 
 186   void print_on(outputStream* st)              const;
 187   void print_extended_on(outputStream *st)     const;
 188   void print_tracing_info()                    const;
 189   void print_gc_threads_on(outputStream* st)   const;
 190   void print_heap_regions_on(outputStream* st) const;
 191 
 192   void stop();
 193 
 194   void prepare_for_verify();
 195   void verify(VerifyOption vo);
 196 
 197 // ---------- Heap counters and metrics
 198 //
 199 private:
 200            size_t _initial_size;

 201   DEFINE_PAD_MINUS_SIZE(0, DEFAULT_CACHE_LINE_SIZE, sizeof(volatile size_t));
 202   volatile size_t _used;
 203   volatile size_t _committed;
 204   volatile size_t _bytes_allocated_since_gc_start;
 205   DEFINE_PAD_MINUS_SIZE(1, DEFAULT_CACHE_LINE_SIZE, 0);
 206 
 207 public:
 208   void increase_used(size_t bytes);
 209   void decrease_used(size_t bytes);
 210   void set_used(size_t bytes);
 211 
 212   void increase_committed(size_t bytes);
 213   void decrease_committed(size_t bytes);
 214   void increase_allocated(size_t bytes);
 215 
 216   size_t bytes_allocated_since_gc_start();
 217   void reset_bytes_allocated_since_gc_start();
 218 

 219   size_t max_capacity()     const;
 220   size_t initial_capacity() const;
 221   size_t capacity()         const;
 222   size_t used()             const;
 223   size_t committed()        const;
 224 
 225 // ---------- Workers handling
 226 //
 227 private:
 228   uint _max_workers;
 229   ShenandoahWorkGang* _workers;
 230   ShenandoahWorkGang* _safepoint_workers;
 231 
 232 public:
 233   uint max_workers();
 234   void assert_gc_workers(uint nworker) NOT_DEBUG_RETURN;
 235 
 236   WorkGang* workers() const;
 237   WorkGang* get_safepoint_workers();
 238 


< prev index next >