< prev index next >

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

Print this page

 28 #include "gc/shared/plab.hpp"
 29 #include "gc/shared/gcThreadLocalData.hpp"
 30 #include "gc/shared/gc_globals.hpp"
 31 #include "gc/shenandoah/shenandoahBarrierSet.hpp"
 32 #include "gc/shenandoah/shenandoahCodeRoots.hpp"
 33 #include "gc/shenandoah/shenandoahSATBMarkQueueSet.hpp"
 34 #include "runtime/thread.hpp"
 35 #include "utilities/debug.hpp"
 36 #include "utilities/sizes.hpp"
 37 
 38 class ShenandoahThreadLocalData {
 39 public:
 40   static const uint INVALID_WORKER_ID = uint(-1);
 41 
 42 private:
 43   char _gc_state;
 44   // Evacuation OOM state
 45   uint8_t                 _oom_scope_nesting_level;
 46   bool                    _oom_during_evac;
 47   SATBMarkQueue           _satb_mark_queue;



 48   PLAB* _gclab;
 49   size_t _gclab_size;








 50   uint  _worker_id;
 51   int  _disarmed_value;
 52   double _paced_time;
 53 
 54   ShenandoahThreadLocalData() :
 55     _gc_state(0),
 56     _oom_scope_nesting_level(0),
 57     _oom_during_evac(false),
 58     _satb_mark_queue(&ShenandoahBarrierSet::satb_mark_queue_set()),
 59     _gclab(NULL),
 60     _gclab_size(0),


 61     _worker_id(INVALID_WORKER_ID),
 62     _disarmed_value(0),
 63     _paced_time(0) {
 64 
 65     // At least on x86_64, nmethod entry barrier encodes _disarmed_value offset
 66     // in instruction as disp8 immed
 67     assert(in_bytes(disarmed_value_offset()) < 128, "Offset range check");
 68   }
 69 
 70   ~ShenandoahThreadLocalData() {
 71     if (_gclab != NULL) {
 72       delete _gclab;
 73     }



 74   }
 75 
 76   static ShenandoahThreadLocalData* data(Thread* thread) {
 77     assert(UseShenandoahGC, "Sanity");
 78     return thread->gc_data<ShenandoahThreadLocalData>();
 79   }
 80 
 81   static ByteSize satb_mark_queue_offset() {
 82     return Thread::gc_data_offset() + byte_offset_of(ShenandoahThreadLocalData, _satb_mark_queue);
 83   }
 84 
 85 public:
 86   static void create(Thread* thread) {
 87     new (data(thread)) ShenandoahThreadLocalData();
 88   }
 89 
 90   static void destroy(Thread* thread) {
 91     data(thread)->~ShenandoahThreadLocalData();
 92   }
 93 

101 
102   static char gc_state(Thread* thread) {
103     return data(thread)->_gc_state;
104   }
105 
106   static void set_worker_id(Thread* thread, uint id) {
107     assert(thread->is_Worker_thread(), "Must be a worker thread");
108     data(thread)->_worker_id = id;
109   }
110 
111   static uint worker_id(Thread* thread) {
112     assert(thread->is_Worker_thread(), "Must be a worker thread");
113     return data(thread)->_worker_id;
114   }
115 
116   static void initialize_gclab(Thread* thread) {
117     assert (thread->is_Java_thread() || thread->is_Worker_thread(), "Only Java and GC worker threads are allowed to get GCLABs");
118     assert(data(thread)->_gclab == NULL, "Only initialize once");
119     data(thread)->_gclab = new PLAB(PLAB::min_size());
120     data(thread)->_gclab_size = 0;


121   }
122 
123   static PLAB* gclab(Thread* thread) {
124     return data(thread)->_gclab;
125   }
126 
127   static size_t gclab_size(Thread* thread) {
128     return data(thread)->_gclab_size;
129   }
130 
131   static void set_gclab_size(Thread* thread, size_t v) {
132     data(thread)->_gclab_size = v;
133   }
134 












135   static void add_paced_time(Thread* thread, double v) {
136     data(thread)->_paced_time += v;
137   }
138 
139   static double paced_time(Thread* thread) {
140     return data(thread)->_paced_time;
141   }
142 
143   static void reset_paced_time(Thread* thread) {
144     data(thread)->_paced_time = 0;
145   }
146 
147   static void set_disarmed_value(Thread* thread, int value) {
148     data(thread)->_disarmed_value = value;
149   }
150 
151   // Evacuation OOM handling
152   static bool is_oom_during_evac(Thread* thread) {
153     return data(thread)->_oom_during_evac;
154   }

 28 #include "gc/shared/plab.hpp"
 29 #include "gc/shared/gcThreadLocalData.hpp"
 30 #include "gc/shared/gc_globals.hpp"
 31 #include "gc/shenandoah/shenandoahBarrierSet.hpp"
 32 #include "gc/shenandoah/shenandoahCodeRoots.hpp"
 33 #include "gc/shenandoah/shenandoahSATBMarkQueueSet.hpp"
 34 #include "runtime/thread.hpp"
 35 #include "utilities/debug.hpp"
 36 #include "utilities/sizes.hpp"
 37 
 38 class ShenandoahThreadLocalData {
 39 public:
 40   static const uint INVALID_WORKER_ID = uint(-1);
 41 
 42 private:
 43   char _gc_state;
 44   // Evacuation OOM state
 45   uint8_t                 _oom_scope_nesting_level;
 46   bool                    _oom_during_evac;
 47   SATBMarkQueue           _satb_mark_queue;
 48 
 49   // Thread-local allocation buffer for object evacuations.
 50   // In generational mode, it is exclusive to the young generation.
 51   PLAB* _gclab;
 52   size_t _gclab_size;
 53 
 54   // Thread-local allocation buffer only used in generational mode.
 55   // Used both by mutator threads and by GC worker threads
 56   // for evacuations within the old generation and
 57   // for promotions from the young generation into the old generation.
 58   PLAB* _plab;
 59   size_t _plab_size;
 60 
 61   uint  _worker_id;
 62   int  _disarmed_value;
 63   double _paced_time;
 64 
 65   ShenandoahThreadLocalData() :
 66     _gc_state(0),
 67     _oom_scope_nesting_level(0),
 68     _oom_during_evac(false),
 69     _satb_mark_queue(&ShenandoahBarrierSet::satb_mark_queue_set()),
 70     _gclab(NULL),
 71     _gclab_size(0),
 72     _plab(NULL),
 73     _plab_size(0),
 74     _worker_id(INVALID_WORKER_ID),
 75     _disarmed_value(0),
 76     _paced_time(0) {
 77 
 78     // At least on x86_64, nmethod entry barrier encodes _disarmed_value offset
 79     // in instruction as disp8 immed
 80     assert(in_bytes(disarmed_value_offset()) < 128, "Offset range check");
 81   }
 82 
 83   ~ShenandoahThreadLocalData() {
 84     if (_gclab != NULL) {
 85       delete _gclab;
 86     }
 87     if (_plab != NULL) {
 88       delete _plab;
 89     }
 90   }
 91 
 92   static ShenandoahThreadLocalData* data(Thread* thread) {
 93     assert(UseShenandoahGC, "Sanity");
 94     return thread->gc_data<ShenandoahThreadLocalData>();
 95   }
 96 
 97   static ByteSize satb_mark_queue_offset() {
 98     return Thread::gc_data_offset() + byte_offset_of(ShenandoahThreadLocalData, _satb_mark_queue);
 99   }
100 
101 public:
102   static void create(Thread* thread) {
103     new (data(thread)) ShenandoahThreadLocalData();
104   }
105 
106   static void destroy(Thread* thread) {
107     data(thread)->~ShenandoahThreadLocalData();
108   }
109 

117 
118   static char gc_state(Thread* thread) {
119     return data(thread)->_gc_state;
120   }
121 
122   static void set_worker_id(Thread* thread, uint id) {
123     assert(thread->is_Worker_thread(), "Must be a worker thread");
124     data(thread)->_worker_id = id;
125   }
126 
127   static uint worker_id(Thread* thread) {
128     assert(thread->is_Worker_thread(), "Must be a worker thread");
129     return data(thread)->_worker_id;
130   }
131 
132   static void initialize_gclab(Thread* thread) {
133     assert (thread->is_Java_thread() || thread->is_Worker_thread(), "Only Java and GC worker threads are allowed to get GCLABs");
134     assert(data(thread)->_gclab == NULL, "Only initialize once");
135     data(thread)->_gclab = new PLAB(PLAB::min_size());
136     data(thread)->_gclab_size = 0;
137     data(thread)->_plab = new PLAB(PLAB::min_size());
138     data(thread)->_plab_size = 0;
139   }
140 
141   static PLAB* gclab(Thread* thread) {
142     return data(thread)->_gclab;
143   }
144 
145   static size_t gclab_size(Thread* thread) {
146     return data(thread)->_gclab_size;
147   }
148 
149   static void set_gclab_size(Thread* thread, size_t v) {
150     data(thread)->_gclab_size = v;
151   }
152 
153   static PLAB* plab(Thread* thread) {
154     return data(thread)->_plab;
155   }
156 
157   static size_t plab_size(Thread* thread) {
158     return data(thread)->_plab_size;
159   }
160 
161   static void set_plab_size(Thread* thread, size_t v) {
162     data(thread)->_plab_size = v;
163   }
164 
165   static void add_paced_time(Thread* thread, double v) {
166     data(thread)->_paced_time += v;
167   }
168 
169   static double paced_time(Thread* thread) {
170     return data(thread)->_paced_time;
171   }
172 
173   static void reset_paced_time(Thread* thread) {
174     data(thread)->_paced_time = 0;
175   }
176 
177   static void set_disarmed_value(Thread* thread, int value) {
178     data(thread)->_disarmed_value = value;
179   }
180 
181   // Evacuation OOM handling
182   static bool is_oom_during_evac(Thread* thread) {
183     return data(thread)->_oom_during_evac;
184   }
< prev index next >