< prev index next >

src/hotspot/share/oops/markWord.hpp

Print this page

 13  * accompanied this code).
 14  *
 15  * You should have received a copy of the GNU General Public License version
 16  * 2 along with this work; if not, write to the Free Software Foundation,
 17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 18  *
 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  *
 23  */
 24 
 25 #ifndef SHARE_OOPS_MARKWORD_HPP
 26 #define SHARE_OOPS_MARKWORD_HPP
 27 
 28 #include "cppstdlib/type_traits.hpp"
 29 #include "metaprogramming/primitiveConversions.hpp"
 30 #include "oops/compressedKlass.hpp"
 31 #include "oops/oopsHierarchy.hpp"
 32 #include "runtime/globals.hpp"

 33 
 34 // The markWord describes the header of an object.
 35 //
 36 // Bit-format of an object header (most significant first, big endian layout below):
 37 //
 38 //  32 bits:
 39 //  --------
 40 //             hash:25 ------------>| age:4  self-fwd:1  lock:2 (normal object)
 41 //
 42 //  64 bits:
 43 //  --------
 44 //  unused:22 hash:31 -->| unused_gap:4  age:4  self-fwd:1  lock:2 (normal object)
 45 //
 46 //  64 bits (with compact headers):
 47 //  -------------------------------
 48 //  klass:22  hash:31 -->| unused_gap:4  age:4  self-fwd:1  lock:2 (normal object)
 49 //
 50 //  - hash contains the identity hash value: largest value is
 51 //    31 bits, see os::random().  Also, 64-bit vm's require
 52 //    a hash value no bigger than 32 bits because they will not
 53 //    properly generate a mask larger than that: see library_call.cpp
 54 //
 55 //  - the two lock bits are used to describe three states: locked/unlocked and monitor.
 56 //
 57 //    [header          | 00]  locked             locked regular object header (fast-locking in use)
 58 //    [header          | 01]  unlocked           regular object header
 59 //    [ptr             | 10]  monitor            inflated lock (header is swapped out, UseObjectMonitorTable == false)
 60 //    [header          | 10]  monitor            inflated lock (UseObjectMonitorTable == true)
 61 //    [ptr             | 11]  marked             used to mark an object

















 62 
 63 class BasicLock;
 64 class ObjectMonitor;
 65 class JavaThread;
 66 class outputStream;
 67 
 68 class markWord {
 69  private:
 70   uintptr_t _value;
 71 
 72  public:
 73   explicit markWord(uintptr_t value) : _value(value) {}
 74 
 75   markWord() = default;         // Doesn't initialize _value.
 76 
 77   // It is critical for performance that this class be trivially
 78   // destructable, copyable, and assignable.
 79   ~markWord() = default;
 80   markWord(const markWord&) = default;
 81   markWord& operator=(const markWord&) = default;
 82 
 83   static markWord from_pointer(void* ptr) {
 84     return markWord((uintptr_t)ptr);
 85   }
 86   void* to_pointer() const {
 87     return (void*)_value;
 88   }
 89 
 90   bool operator==(const markWord& other) const {
 91     return _value == other._value;
 92   }
 93   bool operator!=(const markWord& other) const {
 94     return !operator==(other);
 95   }
 96 
 97   // Conversion
 98   uintptr_t value() const { return _value; }
 99 
100   // Constants
101   static const int age_bits                       = 4;
102   static const int lock_bits                      = 2;
103   static const int self_fwd_bits                  = 1;
104   static const int max_hash_bits                  = BitsPerWord - age_bits - lock_bits - self_fwd_bits;







105   static const int hash_bits                      = max_hash_bits > 31 ? 31 : max_hash_bits;
106   static const int unused_gap_bits                = LP64_ONLY(4) NOT_LP64(0); // Reserved for Valhalla.
107 
108   static const int lock_shift                     = 0;
109   static const int self_fwd_shift                 = lock_shift + lock_bits;
110   static const int age_shift                      = self_fwd_shift + self_fwd_bits;
111   static const int hash_shift                     = age_shift + age_bits + unused_gap_bits;




112 
113   static const uintptr_t lock_mask                = right_n_bits(lock_bits);
114   static const uintptr_t lock_mask_in_place       = lock_mask << lock_shift;
115   static const uintptr_t self_fwd_mask            = right_n_bits(self_fwd_bits);
116   static const uintptr_t self_fwd_mask_in_place   = self_fwd_mask << self_fwd_shift;




117   static const uintptr_t age_mask                 = right_n_bits(age_bits);
118   static const uintptr_t age_mask_in_place        = age_mask << age_shift;


119   static const uintptr_t hash_mask                = right_n_bits(hash_bits);
120   static const uintptr_t hash_mask_in_place       = hash_mask << hash_shift;
121 
122 #ifdef _LP64
123   // Used only with compact headers:
124   // We store the (narrow) Klass* in the bits 43 to 64.
125 
126   // These are for bit-precise extraction of the narrow Klass* from the 64-bit Markword
127   static constexpr int klass_offset_in_bytes      = 4;
128   static constexpr int klass_shift                = hash_shift + hash_bits;
129   static constexpr int klass_shift_at_offset      = klass_shift - klass_offset_in_bytes * BitsPerByte;
130   static constexpr int klass_bits                 = 22;
131   static constexpr uintptr_t klass_mask           = right_n_bits(klass_bits);
132   static constexpr uintptr_t klass_mask_in_place  = klass_mask << klass_shift;
133 #endif
134 
135 
136   static const uintptr_t locked_value             = 0;
137   static const uintptr_t unlocked_value           = 1;
138   static const uintptr_t monitor_value            = 2;
139   static const uintptr_t marked_value             = 3;
140 


141   static const uintptr_t no_hash                  = 0 ;  // no hash value assigned
142   static const uintptr_t no_hash_in_place         = (uintptr_t)no_hash << hash_shift;
143   static const uintptr_t no_lock_in_place         = unlocked_value;
144 
145   static const uint max_age                       = age_mask;
146 
147   // Creates a markWord with all bits set to zero.
148   static markWord zero() { return markWord(uintptr_t(0)); }
149 








150   // lock accessors (note that these assume lock_shift == 0)
151   bool is_locked()   const {
152     return (mask_bits(value(), lock_mask_in_place) != unlocked_value);
153   }
154   bool is_unlocked() const {
155     return (mask_bits(value(), lock_mask_in_place) == unlocked_value);
156   }
157   bool is_marked()   const {
158     return (mask_bits(value(), lock_mask_in_place) == marked_value);
159   }







160   bool is_forwarded() const {
161     // Returns true for normal forwarded (0b011) and self-forwarded (0b1xx).
162     return mask_bits(value(), lock_mask_in_place | self_fwd_mask_in_place) >= static_cast<intptr_t>(marked_value);
163   }
164   bool is_neutral()  const {  // Not locked, or marked - a "clean" neutral state
165     return (mask_bits(value(), lock_mask_in_place) == unlocked_value);
166   }
167 
168   // Should this header be preserved during GC?
169   bool must_be_preserved() const {
170     return (!is_unlocked() || !has_no_hash());



171   }
172 
173   // WARNING: The following routines are used EXCLUSIVELY by
174   // synchronization functions. They are not really gc safe.
175   // They must get updated if markWord layout get changed.
176   markWord set_unlocked() const {
177     return markWord(value() | unlocked_value);
178   }
179 
180   bool is_fast_locked() const {
181     return (value() & lock_mask_in_place) == locked_value;
182   }
183   markWord set_fast_locked() const {
184     // Clear the lock_mask_in_place bits to set locked_value:
185     return markWord(value() & ~lock_mask_in_place);
186   }
187 
188   bool has_monitor() const {
189     return ((value() & lock_mask_in_place) == monitor_value);
190   }
191   markWord set_has_monitor() const {
192     return markWord((value() & ~lock_mask_in_place) | monitor_value);
193   }
194   ObjectMonitor* monitor() const {
195     assert(has_monitor(), "check");
196     assert(!UseObjectMonitorTable, "Locking with OM table does not use markWord for monitors");
197     // Use xor instead of &~ to provide one extra tag-bit check.
198     return (ObjectMonitor*) (value() ^ monitor_value);
199   }
200 
201   static markWord encode(ObjectMonitor* monitor) {
202     assert(!UseObjectMonitorTable, "Locking with OM table does not use markWord for monitors");
203     uintptr_t tmp = (uintptr_t) monitor;
204     return markWord(tmp | monitor_value);
205   }
206 
207   bool has_displaced_mark_helper() const {
208     intptr_t lockbits = value() & lock_mask_in_place;
209     return !UseObjectMonitorTable && lockbits == monitor_value;
210   }




211   markWord displaced_mark_helper() const;
212   void set_displaced_mark_helper(markWord m) const;
213 
214   // used to encode pointers during GC
215   markWord clear_lock_bits() const { return markWord(value() & ~lock_mask_in_place); }
216 
217   // age operations
218   markWord set_marked()   { return markWord((value() & ~lock_mask_in_place) | marked_value); }
219   markWord set_unmarked() { return markWord((value() & ~lock_mask_in_place) | unlocked_value); }
220 
221   uint     age()           const { return (uint) mask_bits(value() >> age_shift, age_mask); }
222   markWord set_age(uint v) const {
223     assert((v & ~age_mask) == 0, "shouldn't overflow age field");
224     return markWord((value() & ~age_mask_in_place) | ((v & age_mask) << age_shift));
225   }
226   markWord incr_age()      const { return age() == max_age ? markWord(_value) : set_age(age() + 1); }
227 
228   // hash operations
229   intptr_t hash() const {
230     return mask_bits(value() >> hash_shift, hash_mask);
231   }
232 
233   bool has_no_hash() const {
234     return hash() == no_hash;
235   }
236 




















237   markWord copy_set_hash(intptr_t hash) const {
238     uintptr_t tmp = value() & (~hash_mask_in_place);
239     tmp |= ((hash & hash_mask) << hash_shift);
240     return markWord(tmp);
241   }
242 
243   inline Klass* klass() const;
244   inline Klass* klass_or_null() const;
245   inline Klass* klass_without_asserts() const;
246   inline narrowKlass narrow_klass() const;
247   inline markWord set_narrow_klass(narrowKlass narrow_klass) const;
248 
249   // Prototype mark for initialization
250   static markWord prototype() {
251     return markWord( no_hash_in_place | no_lock_in_place );



















252   }
253 
254   // Debugging
255   void print_on(outputStream* st, bool print_monitor_info = true) const;
256 
257   // Prepare address of oop for placement into mark
258   inline static markWord encode_pointer_as_mark(void* p) { return from_pointer(p).set_marked(); }
259 
260   // Recover address of oop from encoded form used in mark
261   inline void* decode_pointer() const { return (void*)clear_lock_bits().value(); }

262 
263   inline bool is_self_forwarded() const {
264     return mask_bits(value(), self_fwd_mask_in_place) != 0;
265   }
266 
267   inline markWord set_self_forwarded() const {
268     return markWord(value() | self_fwd_mask_in_place);
269   }
270 
271   inline markWord unset_self_forwarded() const {
272     return markWord(value() & ~self_fwd_mask_in_place);
273   }
274 
275   inline oop forwardee() const {
276     return cast_to_oop(decode_pointer());
277   }
278 };
279 
280 // Support atomic operations.
281 template<>

 13  * accompanied this code).
 14  *
 15  * You should have received a copy of the GNU General Public License version
 16  * 2 along with this work; if not, write to the Free Software Foundation,
 17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 18  *
 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  *
 23  */
 24 
 25 #ifndef SHARE_OOPS_MARKWORD_HPP
 26 #define SHARE_OOPS_MARKWORD_HPP
 27 
 28 #include "cppstdlib/type_traits.hpp"
 29 #include "metaprogramming/primitiveConversions.hpp"
 30 #include "oops/compressedKlass.hpp"
 31 #include "oops/oopsHierarchy.hpp"
 32 #include "runtime/globals.hpp"
 33 #include "utilities/vmEnums.hpp"
 34 
 35 // The markWord describes the header of an object.
 36 //
 37 // Bit-format of an object header (most significant first, big endian layout below):
 38 //
 39 //  32 bits:
 40 //  --------
 41 //             hash:25 ------------->|  age:4  self-fwd:1  lock:2 (normal object)
 42 //
 43 //  64 bits:
 44 //  --------
 45 //  unused:22  hash:31 -->| valhalla:4  age:4  self-fwd:1  lock:2 (normal object)
 46 //
 47 //  64 bits (with compact headers):
 48 //  -------------------------------
 49 //  klass:22   hash:31 -->| valhalla:4  age:4  self-fwd:1  lock:2 (normal object)
 50 //
 51 //  - hash contains the identity hash value: largest value is
 52 //    31 bits, see os::random().  Also, 64-bit vm's require
 53 //    a hash value no bigger than 32 bits because they will not
 54 //    properly generate a mask larger than that: see library_call.cpp
 55 //
 56 //  - the two lock bits are used to describe three states: locked/unlocked and monitor.
 57 //
 58 //    [header          | 00]  locked             locked regular object header (fast-locking in use)
 59 //    [header          | 01]  unlocked           regular object header
 60 //    [ptr             | 10]  monitor            inflated lock (header is swapped out, UseObjectMonitorTable == false)
 61 //    [header          | 10]  monitor            inflated lock (UseObjectMonitorTable == true)
 62 //    [ptr             | 11]  marked             used to mark an object
 63 //
 64 //  VALHALLA EXTENSIONS:
 65 //
 66 //  N.B.: 32 bit mode is not supported, this section assumes 64 bit systems.
 67 //
 68 //  Project Valhalla uses markWord bits to denote the following oops (listed least to most significant):
 69 //  * inline types: have alternative bytecode behavior, e.g. can not be locked
 70 //  * flat arrays: load/decode of klass layout helper is expensive for aaload
 71 //  * "null free" arrays: load/decode of klass layout helper again for aaload
 72 //  * valhalla reserved:
 73 //
 74 //  Inline types cannot be locked, monitored or inflating.
 75 //
 76 //  Note the position of 'self-fwd' is not by accident. When forwarding an
 77 //  object to a new heap position, HeapWord alignment guarantees the lower
 78 //  bits, including 'self-fwd' are 0. "is_self_forwarded()" will be correctly
 79 //  set to false. Otherwise encode_pointer_as_mark() may have 'self-fwd' set.
 80 
 81 class BasicLock;
 82 class ObjectMonitor;
 83 class JavaThread;
 84 class outputStream;
 85 
 86 class markWord {
 87  private:
 88   uintptr_t _value;
 89 
 90  public:
 91   explicit markWord(uintptr_t value) : _value(value) {}
 92 
 93   markWord() = default;         // Doesn't initialize _value.
 94 
 95   // It is critical for performance that this class be trivially
 96   // destructable, copyable, and assignable.
 97   ~markWord() = default;
 98   markWord(const markWord&) = default;
 99   markWord& operator=(const markWord&) = default;
100 
101   static markWord from_pointer(void* ptr) {
102     return markWord((uintptr_t)ptr);
103   }
104   void* to_pointer() const {
105     return (void*)_value;
106   }
107 
108   bool operator==(const markWord& other) const {
109     return _value == other._value;
110   }
111   bool operator!=(const markWord& other) const {
112     return !operator==(other);
113   }
114 
115   // Conversion
116   uintptr_t value() const { return _value; }
117 
118   // Constants, in least significant bit order

119   static const int lock_bits                      = 2;
120   static const int self_fwd_bits                  = 1;
121   // instance state
122   static const int age_bits                       = 4;
123   // prototype header bits (fast path instead of klass layout_helper)
124   static const int inline_type_bits               = LP64_ONLY(1) NOT_LP64(0);
125   static const int null_free_array_bits           = LP64_ONLY(1) NOT_LP64(0);
126   static const int flat_array_bits                = LP64_ONLY(1) NOT_LP64(0);
127   static const int valhalla_reserved_bits         = LP64_ONLY(1) NOT_LP64(0);
128   static const int max_hash_bits                  = BitsPerWord - age_bits - lock_bits - inline_type_bits - valhalla_reserved_bits - flat_array_bits - null_free_array_bits - self_fwd_bits;
129   static const int hash_bits                      = max_hash_bits > 31 ? 31 : max_hash_bits;

130 
131   static const int lock_shift                     = 0;
132   static const int self_fwd_shift                 = lock_shift + lock_bits;
133   static const int age_shift                      = self_fwd_shift + self_fwd_bits;
134   static const int inline_type_shift              = age_shift + age_bits;
135   static const int null_free_array_shift          = inline_type_shift + inline_type_bits;
136   static const int flat_array_shift               = null_free_array_shift + null_free_array_bits;
137   static const int valhalla_reserved_shift        = flat_array_shift + flat_array_bits;
138   static const int hash_shift                     = valhalla_reserved_shift + valhalla_reserved_bits;
139 
140   static const uintptr_t lock_mask                = right_n_bits(lock_bits);
141   static const uintptr_t lock_mask_in_place       = lock_mask << lock_shift;
142   static const uintptr_t self_fwd_mask            = right_n_bits(self_fwd_bits);
143   static const uintptr_t self_fwd_mask_in_place   = self_fwd_mask << self_fwd_shift;
144   static const uintptr_t inline_type_bit_in_place = right_n_bits(inline_type_bits) << inline_type_shift;
145   static const uintptr_t inline_type_mask_in_place = inline_type_bit_in_place + lock_mask;
146   static const uintptr_t null_free_array_bit_in_place  = (right_n_bits(null_free_array_bits) << null_free_array_shift);
147   static const uintptr_t flat_array_bit_in_place  = right_n_bits(flat_array_bits) << flat_array_shift;
148   static const uintptr_t age_mask                 = right_n_bits(age_bits);
149   static const uintptr_t age_mask_in_place        = age_mask << age_shift;
150   static const uintptr_t valhalla_reserved_mask   = right_n_bits(valhalla_reserved_bits);
151   static const uintptr_t valhalla_reserved_mask_in_place = right_n_bits(valhalla_reserved_mask) << valhalla_reserved_shift;
152   static const uintptr_t hash_mask                = right_n_bits(hash_bits);
153   static const uintptr_t hash_mask_in_place       = hash_mask << hash_shift;
154 
155 #ifdef _LP64
156   // Used only with compact headers:
157   // We store the (narrow) Klass* in the bits 43 to 64.
158 
159   // These are for bit-precise extraction of the narrow Klass* from the 64-bit Markword
160   static constexpr int klass_offset_in_bytes      = 4;
161   static constexpr int klass_shift                = hash_shift + hash_bits;
162   static constexpr int klass_shift_at_offset      = klass_shift - klass_offset_in_bytes * BitsPerByte;
163   static constexpr int klass_bits                 = 22;
164   static constexpr uintptr_t klass_mask           = right_n_bits(klass_bits);
165   static constexpr uintptr_t klass_mask_in_place  = klass_mask << klass_shift;
166 #endif
167 
168 
169   static const uintptr_t locked_value             = 0;
170   static const uintptr_t unlocked_value           = 1;
171   static const uintptr_t monitor_value            = 2;
172   static const uintptr_t marked_value             = 3;
173 
174   static const uintptr_t inline_type_pattern      = inline_type_bit_in_place | unlocked_value;
175 
176   static const uintptr_t no_hash                  = 0 ;  // no hash value assigned
177   static const uintptr_t no_hash_in_place         = (uintptr_t)no_hash << hash_shift;
178   static const uintptr_t no_lock_in_place         = unlocked_value;
179 
180   static const uint max_age                       = age_mask;
181 
182   // Creates a markWord with all bits set to zero.
183   static markWord zero() { return markWord(uintptr_t(0)); }
184 
185   bool is_inline_type() const {
186 #ifdef _LP64 // 64 bit encodings only
187     return (mask_bits(value(), inline_type_mask_in_place) == inline_type_pattern);
188 #else
189     return false;
190 #endif
191   }
192 
193   // lock accessors (note that these assume lock_shift == 0)
194   bool is_locked()   const {
195     return (mask_bits(value(), lock_mask_in_place) != unlocked_value);
196   }
197   bool is_unlocked() const {
198     return (mask_bits(value(), lock_mask_in_place) == unlocked_value);
199   }
200   bool is_marked()   const {
201     return (mask_bits(value(), lock_mask_in_place) == marked_value);
202   }
203 
204   bool is_neutral()  const {  // Not locked, or marked - a "clean" neutral state
205     LP64_ONLY(assert(!is_unlocked() || mask_bits(value(), inline_type_bit_in_place) == 0,
206                      "Inline types should not be used for locking. _value: " PTR_FORMAT, _value));
207     return (mask_bits(value(), lock_mask_in_place) == unlocked_value);
208   }
209 
210   bool is_forwarded() const {
211     // Returns true for normal forwarded (0b011) and self-forwarded (0b1xx).
212     return mask_bits(value(), lock_mask_in_place | self_fwd_mask_in_place) >= static_cast<intptr_t>(marked_value);
213   }



214 
215   // Should this header be preserved during GC?
216   bool must_be_preserved() const {
217     // The reserved bits are only guaranteed to be unset if the mark word is "unlocked"
218     LP64_ONLY(assert(!is_unlocked() || mask_bits(value(),  valhalla_reserved_mask_in_place) == 0,
219                      "Reserved bits should not be used. _value: " PTR_FORMAT, _value));
220     return !is_unlocked() || !has_no_hash();
221   }
222 
223   // WARNING: The following routines are used EXCLUSIVELY by
224   // synchronization functions. They are not really gc safe.
225   // They must get updated if markWord layout get changed.
226   markWord set_unlocked() const {
227     return markWord(value() | unlocked_value);
228   }
229 
230   bool is_fast_locked() const {
231     return (value() & lock_mask_in_place) == locked_value;
232   }
233   markWord set_fast_locked() const {
234     // Clear the lock_mask_in_place bits to set locked_value:
235     return markWord(value() & ~lock_mask_in_place);
236   }
237 
238   bool has_monitor() const {
239     return ((value() & lock_mask_in_place) == monitor_value);
240   }
241   markWord set_has_monitor() const {
242     return markWord((value() & ~lock_mask_in_place) | monitor_value);
243   }
244   ObjectMonitor* monitor() const {
245     assert(has_monitor(), "check");
246     assert(!UseObjectMonitorTable, "Locking with OM table does not use markWord for monitors");
247     // Use xor instead of &~ to provide one extra tag-bit check.
248     return (ObjectMonitor*) (value() ^ monitor_value);
249   }
250 
251   static markWord encode(ObjectMonitor* monitor) {
252     assert(!UseObjectMonitorTable, "Locking with OM table does not use markWord for monitors");
253     uintptr_t tmp = (uintptr_t) monitor;
254     return markWord(tmp | monitor_value);
255   }
256 
257   bool has_monitor_pointer() const {
258     intptr_t lockbits = value() & lock_mask_in_place;
259     return !UseObjectMonitorTable && lockbits == monitor_value;
260   }
261 
262   bool has_displaced_mark_helper() const {
263     return has_monitor_pointer();
264   }
265   markWord displaced_mark_helper() const;
266   void set_displaced_mark_helper(markWord m) const;
267 
268   // used to encode pointers during GC
269   markWord clear_lock_bits() const { return markWord(value() & ~lock_mask_in_place); }
270 
271   // age operations
272   markWord set_marked()   { return markWord((value() & ~lock_mask_in_place) | marked_value); }
273   markWord set_unmarked() { return markWord((value() & ~lock_mask_in_place) | unlocked_value); }
274 
275   uint     age()           const { return (uint) mask_bits(value() >> age_shift, age_mask); }
276   markWord set_age(uint v) const {
277     assert((v & ~age_mask) == 0, "shouldn't overflow age field");
278     return markWord((value() & ~age_mask_in_place) | ((v & age_mask) << age_shift));
279   }
280   markWord incr_age()      const { return age() == max_age ? markWord(_value) : set_age(age() + 1); }
281 
282   // hash operations
283   intptr_t hash() const {
284     return mask_bits(value() >> hash_shift, hash_mask);
285   }
286 
287   bool has_no_hash() const {
288     return hash() == no_hash;
289   }
290 
291   bool is_flat_array() const {
292     assert(!has_monitor_pointer(), "Bits are not valid if replaced by a monitor pointer: " PTR_FORMAT, value());
293     assert(!is_marked(), "Bits might not be valid if marked by the GC: " PTR_FORMAT, value());
294 #ifdef _LP64 // 64 bit encodings only
295     return (mask_bits(value(), flat_array_bit_in_place) != 0);
296 #else
297     return false;
298 #endif
299   }
300 
301   bool is_null_free_array() const {
302     assert(!has_monitor_pointer(), "Bits are not valid if replaced by a monitor pointer: " PTR_FORMAT, value());
303     assert(!is_marked(), "Bits might not be valid if marked by the GC: " PTR_FORMAT, value());
304 #ifdef _LP64 // 64 bit encodings only
305     return (mask_bits(value(), null_free_array_bit_in_place) != 0);
306 #else
307     return false;
308 #endif
309   }
310 
311   markWord copy_set_hash(intptr_t hash) const {
312     uintptr_t tmp = value() & (~hash_mask_in_place);
313     tmp |= ((hash & hash_mask) << hash_shift);
314     return markWord(tmp);
315   }
316 
317   inline Klass* klass() const;
318   inline Klass* klass_or_null() const;
319   inline Klass* klass_without_asserts() const;
320   inline narrowKlass narrow_klass() const;
321   inline markWord set_narrow_klass(narrowKlass narrow_klass) const;
322 
323   // Prototype mark for initialization
324   static markWord prototype() {
325     return markWord(unlocked_value);
326   }
327 
328   static markWord inline_type_prototype() {
329     NOT_LP64(assert(false, "Should not be called in 32 bit mode"));
330     return markWord(unlocked_value | inline_type_bit_in_place);
331   }
332 
333   static markWord flat_array_prototype(bool null_free) {
334     NOT_LP64(assert(false, "Should not be called in 32 bit mode"));
335     if (null_free) {
336       return markWord(unlocked_value | flat_array_bit_in_place | null_free_array_bit_in_place);
337     } else {
338       return markWord(unlocked_value | flat_array_bit_in_place);
339     }
340   }
341 
342   static markWord null_free_array_prototype() {
343     NOT_LP64(assert(false, "Should not be called in 32 bit mode"));
344     return markWord(unlocked_value | null_free_array_bit_in_place);
345   }
346 
347   // Debugging
348   void print_on(outputStream* st, bool print_monitor_info = true) const;
349 
350   // Prepare address of oop for placement into mark
351   inline static markWord encode_pointer_as_mark(void* p) { return from_pointer(p).set_marked(); }
352 
353   inline void* decode_pointer() const {
354     return (void*) (clear_lock_bits().value());
355   }
356 
357   inline bool is_self_forwarded() const {
358     return mask_bits(value(), self_fwd_mask_in_place) != 0;
359   }
360 
361   inline markWord set_self_forwarded() const {
362     return markWord(value() | self_fwd_mask_in_place);
363   }
364 
365   inline markWord unset_self_forwarded() const {
366     return markWord(value() & ~self_fwd_mask_in_place);
367   }
368 
369   inline oop forwardee() const {
370     return cast_to_oop(decode_pointer());
371   }
372 };
373 
374 // Support atomic operations.
375 template<>
< prev index next >