< prev index next >

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

Print this page




   9  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  11  * version 2 for more details (a copy is included in the LICENSE file that
  12  * accompanied this code).
  13  *
  14  * You should have received a copy of the GNU General Public License version
  15  * 2 along with this work; if not, write to the Free Software Foundation,
  16  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  17  *
  18  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  19  * or visit www.oracle.com if you need additional information or have any
  20  * questions.
  21  *
  22  */
  23 
  24 #ifndef SHARE_GC_SHENANDOAH_SHENANDOAHTHREADLOCALDATA_HPP
  25 #define SHARE_GC_SHENANDOAH_SHENANDOAHTHREADLOCALDATA_HPP
  26 
  27 #include "gc/shared/plab.hpp"
  28 #include "gc/shenandoah/shenandoahBarrierSet.hpp"

  29 #include "gc/shenandoah/shenandoahSATBMarkQueueSet.hpp"
  30 #include "runtime/thread.hpp"
  31 #include "utilities/debug.hpp"
  32 #include "utilities/sizes.hpp"
  33 
  34 class ShenandoahThreadLocalData {
  35 public:
  36   static const uint INVALID_WORKER_ID = uint(-1);
  37 
  38 private:
  39   char _gc_state;
  40   char _oom_during_evac;
  41   ShenandoahSATBMarkQueue _satb_mark_queue;
  42   PLAB* _gclab;
  43   size_t _gclab_size;
  44   uint  _worker_id;
  45   bool _force_satb_flush;

  46 
  47   ShenandoahThreadLocalData() :
  48     _gc_state(0),
  49     _oom_during_evac(0),
  50     _satb_mark_queue(&ShenandoahBarrierSet::satb_mark_queue_set()),
  51     _gclab(NULL),
  52     _gclab_size(0),
  53     _worker_id(INVALID_WORKER_ID),
  54     _force_satb_flush(false) {
  55   }
  56 
  57   ~ShenandoahThreadLocalData() {
  58     if (_gclab != NULL) {
  59       delete _gclab;
  60     }
  61   }
  62 
  63   static ShenandoahThreadLocalData* data(Thread* thread) {
  64     assert(UseShenandoahGC, "Sanity");
  65     return thread->gc_data<ShenandoahThreadLocalData>();


 108   }
 109 
 110   static uint worker_id(Thread* thread) {
 111     assert(thread->is_Worker_thread(), "Must be a worker thread");
 112     return data(thread)->_worker_id;
 113   }
 114 
 115   static void set_force_satb_flush(Thread* thread, bool v) {
 116     data(thread)->_force_satb_flush = v;
 117   }
 118 
 119   static bool is_force_satb_flush(Thread* thread) {
 120     return data(thread)->_force_satb_flush;
 121   }
 122 
 123   static void initialize_gclab(Thread* thread) {
 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 #ifdef ASSERT
 143   static void set_evac_allowed(Thread* thread, bool evac_allowed) {
 144     if (evac_allowed) {
 145       data(thread)->_oom_during_evac |= 2;
 146     } else {
 147       data(thread)->_oom_during_evac &= ~2;
 148     }
 149   }
 150 
 151   static bool is_evac_allowed(Thread* thread) {
 152     return (data(thread)->_oom_during_evac & 2) == 2;
 153   }
 154 #endif
 155 
 156   // Offsets
 157   static ByteSize satb_mark_queue_active_offset() {
 158     return satb_mark_queue_offset() + SATBMarkQueue::byte_offset_of_active();
 159   }
 160 
 161   static ByteSize satb_mark_queue_index_offset() {
 162     return satb_mark_queue_offset() + SATBMarkQueue::byte_offset_of_index();
 163   }
 164 
 165   static ByteSize satb_mark_queue_buffer_offset() {
 166     return satb_mark_queue_offset() + SATBMarkQueue::byte_offset_of_buf();
 167   }
 168 
 169   static ByteSize gc_state_offset() {
 170     return Thread::gc_data_offset() + byte_offset_of(ShenandoahThreadLocalData, _gc_state);
 171   }
 172 



 173 };
 174 
 175 #endif // SHARE_GC_SHENANDOAH_SHENANDOAHTHREADLOCALDATA_HPP


   9  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  11  * version 2 for more details (a copy is included in the LICENSE file that
  12  * accompanied this code).
  13  *
  14  * You should have received a copy of the GNU General Public License version
  15  * 2 along with this work; if not, write to the Free Software Foundation,
  16  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  17  *
  18  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  19  * or visit www.oracle.com if you need additional information or have any
  20  * questions.
  21  *
  22  */
  23 
  24 #ifndef SHARE_GC_SHENANDOAH_SHENANDOAHTHREADLOCALDATA_HPP
  25 #define SHARE_GC_SHENANDOAH_SHENANDOAHTHREADLOCALDATA_HPP
  26 
  27 #include "gc/shared/plab.hpp"
  28 #include "gc/shenandoah/shenandoahBarrierSet.hpp"
  29 #include "gc/shenandoah/shenandoahCodeRoots.hpp"
  30 #include "gc/shenandoah/shenandoahSATBMarkQueueSet.hpp"
  31 #include "runtime/thread.hpp"
  32 #include "utilities/debug.hpp"
  33 #include "utilities/sizes.hpp"
  34 
  35 class ShenandoahThreadLocalData {
  36 public:
  37   static const uint INVALID_WORKER_ID = uint(-1);
  38 
  39 private:
  40   char _gc_state;
  41   char _oom_during_evac;
  42   ShenandoahSATBMarkQueue _satb_mark_queue;
  43   PLAB* _gclab;
  44   size_t _gclab_size;
  45   uint  _worker_id;
  46   bool _force_satb_flush;
  47   int  _disarmed_value;
  48 
  49   ShenandoahThreadLocalData() :
  50     _gc_state(0),
  51     _oom_during_evac(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   }
  58 
  59   ~ShenandoahThreadLocalData() {
  60     if (_gclab != NULL) {
  61       delete _gclab;
  62     }
  63   }
  64 
  65   static ShenandoahThreadLocalData* data(Thread* thread) {
  66     assert(UseShenandoahGC, "Sanity");
  67     return thread->gc_data<ShenandoahThreadLocalData>();


 110   }
 111 
 112   static uint worker_id(Thread* thread) {
 113     assert(thread->is_Worker_thread(), "Must be a worker thread");
 114     return data(thread)->_worker_id;
 115   }
 116 
 117   static void set_force_satb_flush(Thread* thread, bool v) {
 118     data(thread)->_force_satb_flush = v;
 119   }
 120 
 121   static bool is_force_satb_flush(Thread* thread) {
 122     return data(thread)->_force_satb_flush;
 123   }
 124 
 125   static void initialize_gclab(Thread* thread) {
 126     assert (thread->is_Java_thread() || thread->is_Worker_thread(), "Only Java and GC worker threads are allowed to get GCLABs");
 127     assert(data(thread)->_gclab == NULL, "Only initialize once");
 128     data(thread)->_gclab = new PLAB(PLAB::min_size());
 129     data(thread)->_gclab_size = 0;
 130     data(thread)->_disarmed_value = ShenandoahCodeRoots::disarmed_value();
 131   }
 132 
 133   static PLAB* gclab(Thread* thread) {
 134     return data(thread)->_gclab;
 135   }
 136 
 137   static size_t gclab_size(Thread* thread) {
 138     return data(thread)->_gclab_size;
 139   }
 140 
 141   static void set_gclab_size(Thread* thread, size_t v) {
 142     data(thread)->_gclab_size = v;
 143   }
 144 
 145   static void set_disarmed_value(Thread* thread, int value) {
 146     data(thread)->_disarmed_value = value;
 147   }
 148 
 149 #ifdef ASSERT
 150   static void set_evac_allowed(Thread* thread, bool evac_allowed) {
 151     if (evac_allowed) {
 152       data(thread)->_oom_during_evac |= 2;
 153     } else {
 154       data(thread)->_oom_during_evac &= ~2;
 155     }
 156   }
 157 
 158   static bool is_evac_allowed(Thread* thread) {
 159     return (data(thread)->_oom_during_evac & 2) == 2;
 160   }
 161 #endif
 162 
 163   // Offsets
 164   static ByteSize satb_mark_queue_active_offset() {
 165     return satb_mark_queue_offset() + SATBMarkQueue::byte_offset_of_active();
 166   }
 167 
 168   static ByteSize satb_mark_queue_index_offset() {
 169     return satb_mark_queue_offset() + SATBMarkQueue::byte_offset_of_index();
 170   }
 171 
 172   static ByteSize satb_mark_queue_buffer_offset() {
 173     return satb_mark_queue_offset() + SATBMarkQueue::byte_offset_of_buf();
 174   }
 175 
 176   static ByteSize gc_state_offset() {
 177     return Thread::gc_data_offset() + byte_offset_of(ShenandoahThreadLocalData, _gc_state);
 178   }
 179 
 180   static ByteSize disarmed_value_offset() {
 181     return Thread::gc_data_offset() + byte_offset_of(ShenandoahThreadLocalData, _disarmed_value);
 182   }
 183 };
 184 
 185 #endif // SHARE_GC_SHENANDOAH_SHENANDOAHTHREADLOCALDATA_HPP
< prev index next >