< prev index next >

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

Print this page




  23  */
  24 
  25 #ifndef SHARE_GC_SHENANDOAH_SHENANDOAHTHREADLOCALDATA_HPP
  26 #define SHARE_GC_SHENANDOAH_SHENANDOAHTHREADLOCALDATA_HPP
  27 
  28 #include "gc/shared/plab.hpp"
  29 #include "gc/shared/gcThreadLocalData.hpp"
  30 #include "gc/shenandoah/shenandoahBarrierSet.hpp"
  31 #include "gc/shenandoah/shenandoahCodeRoots.hpp"
  32 #include "gc/shenandoah/shenandoahSATBMarkQueueSet.hpp"
  33 #include "runtime/thread.hpp"
  34 #include "utilities/debug.hpp"
  35 #include "utilities/sizes.hpp"
  36 
  37 class ShenandoahThreadLocalData {
  38 public:
  39   static const uint INVALID_WORKER_ID = uint(-1);
  40 
  41 private:
  42   char _gc_state;
  43   // Evacuation OOM state
  44   uint8_t                 _oom_scope_nesting_level;
  45   bool                    _oom_during_evac;
  46   ShenandoahSATBMarkQueue _satb_mark_queue;
  47   PLAB* _gclab;
  48   size_t _gclab_size;
  49   uint  _worker_id;
  50   bool _force_satb_flush;
  51   int  _disarmed_value;
  52 
  53   ShenandoahThreadLocalData() :
  54     _gc_state(0),
  55     _oom_scope_nesting_level(0),
  56     _oom_during_evac(false),
  57     _satb_mark_queue(&ShenandoahBarrierSet::satb_mark_queue_set()),
  58     _gclab(NULL),
  59     _gclab_size(0),
  60     _worker_id(INVALID_WORKER_ID),
  61     _force_satb_flush(false),
  62     _disarmed_value(0) {
  63 
  64     // At least on x86_64, nmethod entry barrier encodes _disarmed_value offset
  65     // in instruction as disp8 immed
  66     assert(in_bytes(disarmed_value_offset()) < 128, "Offset range check");
  67   }
  68 
  69   ~ShenandoahThreadLocalData() {
  70     if (_gclab != NULL) {
  71       delete _gclab;
  72     }
  73   }
  74 
  75   static ShenandoahThreadLocalData* data(Thread* thread) {
  76     assert(UseShenandoahGC, "Sanity");


 124     assert (thread->is_Java_thread() || thread->is_Worker_thread(), "Only Java and GC worker threads are allowed to get GCLABs");
 125     assert(data(thread)->_gclab == NULL, "Only initialize once");
 126     data(thread)->_gclab = new PLAB(PLAB::min_size());
 127     data(thread)->_gclab_size = 0;
 128   }
 129 
 130   static PLAB* gclab(Thread* thread) {
 131     return data(thread)->_gclab;
 132   }
 133 
 134   static size_t gclab_size(Thread* thread) {
 135     return data(thread)->_gclab_size;
 136   }
 137 
 138   static void set_gclab_size(Thread* thread, size_t v) {
 139     data(thread)->_gclab_size = v;
 140   }
 141 
 142   static void set_disarmed_value(Thread* thread, int value) {
 143     data(thread)->_disarmed_value = value;
 144   }
 145 
 146   // Evacuation OOM handling
 147   static bool is_oom_during_evac(Thread* thread) {
 148     return data(thread)->_oom_during_evac;
 149   }
 150 
 151   static void set_oom_during_evac(Thread* thread, bool oom) {
 152     data(thread)->_oom_during_evac = oom;
 153   }
 154 
 155   static uint8_t evac_oom_scope_level(Thread* thread) {
 156     return data(thread)->_oom_scope_nesting_level;
 157   }
 158 
 159   // Push the scope one level deeper, return previous level
 160   static uint8_t push_evac_oom_scope(Thread* thread) {
 161     uint8_t level = evac_oom_scope_level(thread);
 162     assert(level < 254, "Overflow nesting level"); // UINT8_MAX = 255
 163     data(thread)->_oom_scope_nesting_level = level + 1;
 164     return level;
 165   }
 166 
 167   // Pop the scope by one level, return previous level
 168   static uint8_t pop_evac_oom_scope(Thread* thread) {
 169     uint8_t level = evac_oom_scope_level(thread);
 170     assert(level > 0, "Underflow nesting level");
 171     data(thread)->_oom_scope_nesting_level = level - 1;
 172     return level;
 173   }
 174 
 175   static bool is_evac_allowed(Thread* thread) {
 176     return evac_oom_scope_level(thread) > 0;
 177   }
 178 
 179   // Offsets
 180   static ByteSize satb_mark_queue_active_offset() {
 181     return satb_mark_queue_offset() + SATBMarkQueue::byte_offset_of_active();
 182   }
 183 
 184   static ByteSize satb_mark_queue_index_offset() {
 185     return satb_mark_queue_offset() + SATBMarkQueue::byte_offset_of_index();
 186   }
 187 
 188   static ByteSize satb_mark_queue_buffer_offset() {
 189     return satb_mark_queue_offset() + SATBMarkQueue::byte_offset_of_buf();
 190   }
 191 
 192   static ByteSize gc_state_offset() {
 193     return Thread::gc_data_offset() + byte_offset_of(ShenandoahThreadLocalData, _gc_state);
 194   }
 195 
 196   static ByteSize disarmed_value_offset() {


  23  */
  24 
  25 #ifndef SHARE_GC_SHENANDOAH_SHENANDOAHTHREADLOCALDATA_HPP
  26 #define SHARE_GC_SHENANDOAH_SHENANDOAHTHREADLOCALDATA_HPP
  27 
  28 #include "gc/shared/plab.hpp"
  29 #include "gc/shared/gcThreadLocalData.hpp"
  30 #include "gc/shenandoah/shenandoahBarrierSet.hpp"
  31 #include "gc/shenandoah/shenandoahCodeRoots.hpp"
  32 #include "gc/shenandoah/shenandoahSATBMarkQueueSet.hpp"
  33 #include "runtime/thread.hpp"
  34 #include "utilities/debug.hpp"
  35 #include "utilities/sizes.hpp"
  36 
  37 class ShenandoahThreadLocalData {
  38 public:
  39   static const uint INVALID_WORKER_ID = uint(-1);
  40 
  41 private:
  42   char _gc_state;



  43   ShenandoahSATBMarkQueue _satb_mark_queue;
  44   PLAB* _gclab;
  45   size_t _gclab_size;
  46   uint  _worker_id;
  47   bool _force_satb_flush;
  48   int  _disarmed_value;
  49 
  50   ShenandoahThreadLocalData() :
  51     _gc_state(0),


  52     _satb_mark_queue(&ShenandoahBarrierSet::satb_mark_queue_set()),
  53     _gclab(NULL),
  54     _gclab_size(0),
  55     _worker_id(INVALID_WORKER_ID),
  56     _force_satb_flush(false),
  57     _disarmed_value(0) {
  58 
  59     // At least on x86_64, nmethod entry barrier encodes _disarmed_value offset
  60     // in instruction as disp8 immed
  61     assert(in_bytes(disarmed_value_offset()) < 128, "Offset range check");
  62   }
  63 
  64   ~ShenandoahThreadLocalData() {
  65     if (_gclab != NULL) {
  66       delete _gclab;
  67     }
  68   }
  69 
  70   static ShenandoahThreadLocalData* data(Thread* thread) {
  71     assert(UseShenandoahGC, "Sanity");


 119     assert (thread->is_Java_thread() || thread->is_Worker_thread(), "Only Java and GC worker threads are allowed to get GCLABs");
 120     assert(data(thread)->_gclab == NULL, "Only initialize once");
 121     data(thread)->_gclab = new PLAB(PLAB::min_size());
 122     data(thread)->_gclab_size = 0;
 123   }
 124 
 125   static PLAB* gclab(Thread* thread) {
 126     return data(thread)->_gclab;
 127   }
 128 
 129   static size_t gclab_size(Thread* thread) {
 130     return data(thread)->_gclab_size;
 131   }
 132 
 133   static void set_gclab_size(Thread* thread, size_t v) {
 134     data(thread)->_gclab_size = v;
 135   }
 136 
 137   static void set_disarmed_value(Thread* thread, int value) {
 138     data(thread)->_disarmed_value = value;

































 139   }
 140 
 141   // Offsets
 142   static ByteSize satb_mark_queue_active_offset() {
 143     return satb_mark_queue_offset() + SATBMarkQueue::byte_offset_of_active();
 144   }
 145 
 146   static ByteSize satb_mark_queue_index_offset() {
 147     return satb_mark_queue_offset() + SATBMarkQueue::byte_offset_of_index();
 148   }
 149 
 150   static ByteSize satb_mark_queue_buffer_offset() {
 151     return satb_mark_queue_offset() + SATBMarkQueue::byte_offset_of_buf();
 152   }
 153 
 154   static ByteSize gc_state_offset() {
 155     return Thread::gc_data_offset() + byte_offset_of(ShenandoahThreadLocalData, _gc_state);
 156   }
 157 
 158   static ByteSize disarmed_value_offset() {
< prev index next >