< prev index next >

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

Print this page




 137     pow_bits     = 5,
 138     oop_bits     = sizeof(uintptr_t)*8 - chunk_bits - pow_bits
 139   };
 140   enum {
 141     oop_shift    = 0,
 142     pow_shift    = oop_shift + oop_bits,
 143     chunk_shift  = pow_shift + pow_bits
 144   };
 145 
 146 public:
 147   ObjArrayChunkedTask(oop o = NULL) {
 148     assert(decode_oop(encode_oop(o)) ==  o, "oop can be encoded: " PTR_FORMAT, p2i(o));
 149     _obj = encode_oop(o);
 150   }
 151   ObjArrayChunkedTask(oop o, int chunk, int pow) {
 152     assert(decode_oop(encode_oop(o)) == o, "oop can be encoded: " PTR_FORMAT, p2i(o));
 153     assert(decode_chunk(encode_chunk(chunk)) == chunk, "chunk can be encoded: %d", chunk);
 154     assert(decode_pow(encode_pow(pow)) == pow, "pow can be encoded: %d", pow);
 155     _obj = encode_oop(o) | encode_chunk(chunk) | encode_pow(pow);
 156   }
 157   ObjArrayChunkedTask(const ObjArrayChunkedTask& t): _obj(t._obj) { }
 158 
 159   ObjArrayChunkedTask& operator =(const ObjArrayChunkedTask& t) {
 160     _obj = t._obj;
 161     return *this;
 162   }
 163   volatile ObjArrayChunkedTask&
 164   operator =(const volatile ObjArrayChunkedTask& t) volatile {
 165     (void)const_cast<uintptr_t&>(_obj = t._obj);
 166     return *this;
 167   }
 168 
 169   inline oop decode_oop(uintptr_t val) const {
 170     return (oop) reinterpret_cast<void*>((val >> oop_shift) & right_n_bits(oop_bits));
 171   }
 172 
 173   inline int decode_chunk(uintptr_t val) const {
 174     return (int) ((val >> chunk_shift) & right_n_bits(chunk_bits));
 175   }
 176 
 177   inline int decode_pow(uintptr_t val) const {
 178     return (int) ((val >> pow_shift) & right_n_bits(pow_bits));
 179   }
 180 
 181   inline uintptr_t encode_oop(oop obj) const {
 182     return ((uintptr_t)(void*) obj) << oop_shift;
 183   }
 184 
 185   inline uintptr_t encode_chunk(int chunk) const {
 186     return ((uintptr_t) chunk) << chunk_shift;
 187   }


 206   }
 207 
 208 private:
 209   uintptr_t _obj;
 210 };
 211 #else
 212 class ObjArrayChunkedTask
 213 {
 214 public:
 215   enum {
 216     chunk_bits  = 10,
 217     pow_bits    = 5,
 218   };
 219 public:
 220   ObjArrayChunkedTask(oop o = NULL, int chunk = 0, int pow = 0): _obj(o) {
 221     assert(0 <= chunk && chunk < nth_bit(chunk_bits), "chunk is sane: %d", chunk);
 222     assert(0 <= pow && pow < nth_bit(pow_bits), "pow is sane: %d", pow);
 223     _chunk = chunk;
 224     _pow = pow;
 225   }
 226   ObjArrayChunkedTask(const ObjArrayChunkedTask& t): _obj(t._obj), _chunk(t._chunk), _pow(t._pow) { }
 227 
 228   ObjArrayChunkedTask& operator =(const ObjArrayChunkedTask& t) {
 229     _obj = t._obj;
 230     _chunk = t._chunk;
 231     _pow = t._pow;
 232     return *this;
 233   }
 234   volatile ObjArrayChunkedTask&
 235   operator =(const volatile ObjArrayChunkedTask& t) volatile {
 236     (void)const_cast<oop&>(_obj = t._obj);
 237     _chunk = t._chunk;
 238     _pow = t._pow;
 239     return *this;
 240   }
 241 
 242   inline oop obj()   const { return _obj; }
 243   inline int chunk() const { return _chunk; }
 244   inline int pow()  const { return _pow; }
 245 
 246   inline bool is_not_chunked() const { return _chunk == 0; }
 247 
 248   DEBUG_ONLY(bool is_valid() const); // Tasks to be pushed/popped must be valid.
 249 
 250   static size_t max_addressable() {
 251     return sizeof(oop);
 252   }
 253 
 254   static int chunk_size() {
 255     return nth_bit(chunk_bits);
 256   }
 257 
 258 private:
 259   oop _obj;
 260   int _chunk;




 137     pow_bits     = 5,
 138     oop_bits     = sizeof(uintptr_t)*8 - chunk_bits - pow_bits
 139   };
 140   enum {
 141     oop_shift    = 0,
 142     pow_shift    = oop_shift + oop_bits,
 143     chunk_shift  = pow_shift + pow_bits
 144   };
 145 
 146 public:
 147   ObjArrayChunkedTask(oop o = NULL) {
 148     assert(decode_oop(encode_oop(o)) ==  o, "oop can be encoded: " PTR_FORMAT, p2i(o));
 149     _obj = encode_oop(o);
 150   }
 151   ObjArrayChunkedTask(oop o, int chunk, int pow) {
 152     assert(decode_oop(encode_oop(o)) == o, "oop can be encoded: " PTR_FORMAT, p2i(o));
 153     assert(decode_chunk(encode_chunk(chunk)) == chunk, "chunk can be encoded: %d", chunk);
 154     assert(decode_pow(encode_pow(pow)) == pow, "pow can be encoded: %d", pow);
 155     _obj = encode_oop(o) | encode_chunk(chunk) | encode_pow(pow);
 156   }

 157 
 158   // Trivially copyable.








 159 
 160   inline oop decode_oop(uintptr_t val) const {
 161     return (oop) reinterpret_cast<void*>((val >> oop_shift) & right_n_bits(oop_bits));
 162   }
 163 
 164   inline int decode_chunk(uintptr_t val) const {
 165     return (int) ((val >> chunk_shift) & right_n_bits(chunk_bits));
 166   }
 167 
 168   inline int decode_pow(uintptr_t val) const {
 169     return (int) ((val >> pow_shift) & right_n_bits(pow_bits));
 170   }
 171 
 172   inline uintptr_t encode_oop(oop obj) const {
 173     return ((uintptr_t)(void*) obj) << oop_shift;
 174   }
 175 
 176   inline uintptr_t encode_chunk(int chunk) const {
 177     return ((uintptr_t) chunk) << chunk_shift;
 178   }


 197   }
 198 
 199 private:
 200   uintptr_t _obj;
 201 };
 202 #else
 203 class ObjArrayChunkedTask
 204 {
 205 public:
 206   enum {
 207     chunk_bits  = 10,
 208     pow_bits    = 5,
 209   };
 210 public:
 211   ObjArrayChunkedTask(oop o = NULL, int chunk = 0, int pow = 0): _obj(o) {
 212     assert(0 <= chunk && chunk < nth_bit(chunk_bits), "chunk is sane: %d", chunk);
 213     assert(0 <= pow && pow < nth_bit(pow_bits), "pow is sane: %d", pow);
 214     _chunk = chunk;
 215     _pow = pow;
 216   }

 217 
 218   // Trivially copyable.












 219 
 220   inline oop obj()   const { return _obj; }
 221   inline int chunk() const { return _chunk; }
 222   inline int pow()  const { return _pow; }
 223 
 224   inline bool is_not_chunked() const { return _chunk == 0; }
 225 
 226   DEBUG_ONLY(bool is_valid() const); // Tasks to be pushed/popped must be valid.
 227 
 228   static size_t max_addressable() {
 229     return sizeof(oop);
 230   }
 231 
 232   static int chunk_size() {
 233     return nth_bit(chunk_bits);
 234   }
 235 
 236 private:
 237   oop _obj;
 238   int _chunk;


< prev index next >