8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
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 "metaprogramming/primitiveConversions.hpp"
29 #include "oops/compressedKlass.hpp"
30 #include "oops/oopsHierarchy.hpp"
31 #include "runtime/globals.hpp"
32
33 #include <type_traits>
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 -->| unused_gap:4 age:4 self-fwd:1 lock:2 (normal object)
46 //
47 // 64 bits (with compact headers):
48 // -------------------------------
49 // klass:22 hash:31 -->| unused_gap: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 // [ptr | 00] locked ptr points to real header on stack (stack-locking in use)
59 // [header | 00] locked locked regular object header (fast-locking in use)
60 // [header | 01] unlocked regular object header
61 // [ptr | 10] monitor inflated lock (header is swapped out, UseObjectMonitorTable == false)
62 // [header | 10] monitor inflated lock (UseObjectMonitorTable == true)
63 // [ptr | 11] marked used to mark an object
64 // [0 ............ 0| 00] inflating inflation in progress (stack-locking in use)
65 //
66 // We assume that stack/thread pointers have the lowest two bits cleared.
67 //
68 // - INFLATING() is a distinguished markword value of all zeros that is
69 // used when inflating an existing stack-lock into an ObjectMonitor.
70 // See below for is_being_inflated() and INFLATING().
71
72 class BasicLock;
73 class ObjectMonitor;
74 class JavaThread;
75 class outputStream;
76
77 class markWord {
78 private:
79 uintptr_t _value;
80
81 public:
82 explicit markWord(uintptr_t value) : _value(value) {}
83
84 markWord() = default; // Doesn't initialize _value.
85
86 // It is critical for performance that this class be trivially
87 // destructable, copyable, and assignable.
88 ~markWord() = default;
89 markWord(const markWord&) = default;
90 markWord& operator=(const markWord&) = default;
91
92 static markWord from_pointer(void* ptr) {
93 return markWord((uintptr_t)ptr);
94 }
95 void* to_pointer() const {
96 return (void*)_value;
97 }
98
99 bool operator==(const markWord& other) const {
100 return _value == other._value;
101 }
102 bool operator!=(const markWord& other) const {
103 return !operator==(other);
104 }
105
106 // Conversion
107 uintptr_t value() const { return _value; }
108
109 // Constants
110 static const int age_bits = 4;
111 static const int lock_bits = 2;
112 static const int self_fwd_bits = 1;
113 static const int max_hash_bits = BitsPerWord - age_bits - lock_bits - self_fwd_bits;
114 static const int hash_bits = max_hash_bits > 31 ? 31 : max_hash_bits;
115 static const int unused_gap_bits = LP64_ONLY(4) NOT_LP64(0); // Reserved for Valhalla.
116
117 static const int lock_shift = 0;
118 static const int self_fwd_shift = lock_shift + lock_bits;
119 static const int age_shift = self_fwd_shift + self_fwd_bits;
120 static const int hash_shift = age_shift + age_bits + unused_gap_bits;
121
122 static const uintptr_t lock_mask = right_n_bits(lock_bits);
123 static const uintptr_t lock_mask_in_place = lock_mask << lock_shift;
124 static const uintptr_t self_fwd_mask = right_n_bits(self_fwd_bits);
125 static const uintptr_t self_fwd_mask_in_place = self_fwd_mask << self_fwd_shift;
126 static const uintptr_t age_mask = right_n_bits(age_bits);
127 static const uintptr_t age_mask_in_place = age_mask << age_shift;
128 static const uintptr_t hash_mask = right_n_bits(hash_bits);
129 static const uintptr_t hash_mask_in_place = hash_mask << hash_shift;
130
131 #ifdef _LP64
132 // Used only with compact headers:
133 // We store the (narrow) Klass* in the bits 43 to 64.
134
135 // These are for bit-precise extraction of the narrow Klass* from the 64-bit Markword
136 static constexpr int klass_offset_in_bytes = 4;
137 static constexpr int klass_shift = hash_shift + hash_bits;
138 static constexpr int klass_shift_at_offset = klass_shift - klass_offset_in_bytes * BitsPerByte;
139 static constexpr int klass_bits = 22;
140 static constexpr uintptr_t klass_mask = right_n_bits(klass_bits);
141 static constexpr uintptr_t klass_mask_in_place = klass_mask << klass_shift;
142 #endif
143
144
145 static const uintptr_t locked_value = 0;
146 static const uintptr_t unlocked_value = 1;
147 static const uintptr_t monitor_value = 2;
148 static const uintptr_t marked_value = 3;
149
150 static const uintptr_t no_hash = 0 ; // no hash value assigned
151 static const uintptr_t no_hash_in_place = (uintptr_t)no_hash << hash_shift;
152 static const uintptr_t no_lock_in_place = unlocked_value;
153
154 static const uint max_age = age_mask;
155
156 // Creates a markWord with all bits set to zero.
157 static markWord zero() { return markWord(uintptr_t(0)); }
158
159 // lock accessors (note that these assume lock_shift == 0)
160 bool is_locked() const {
161 return (mask_bits(value(), lock_mask_in_place) != unlocked_value);
162 }
163 bool is_unlocked() const {
164 return (mask_bits(value(), lock_mask_in_place) == unlocked_value);
165 }
166 bool is_marked() const {
167 return (mask_bits(value(), lock_mask_in_place) == marked_value);
168 }
169 bool is_forwarded() const {
170 // Returns true for normal forwarded (0b011) and self-forwarded (0b1xx).
171 return mask_bits(value(), lock_mask_in_place | self_fwd_mask_in_place) >= static_cast<intptr_t>(marked_value);
172 }
173 bool is_neutral() const { // Not locked, or marked - a "clean" neutral state
174 return (mask_bits(value(), lock_mask_in_place) == unlocked_value);
175 }
176
177 // Special temporary state of the markWord while being inflated.
178 // Code that looks at mark outside a lock need to take this into account.
179 bool is_being_inflated() const { return (value() == 0); }
180
181 // Distinguished markword value - used when inflating over
182 // an existing stack-lock. 0 indicates the markword is "BUSY".
183 // Lockword mutators that use a LD...CAS idiom should always
184 // check for and avoid overwriting a 0 value installed by some
185 // other thread. (They should spin or block instead. The 0 value
186 // is transient and *should* be short-lived).
187 // Fast-locking does not use INFLATING.
188 static markWord INFLATING() { return zero(); } // inflate-in-progress
189
190 // Should this header be preserved during GC?
191 bool must_be_preserved() const {
192 return (!is_unlocked() || !has_no_hash());
193 }
194
195 // WARNING: The following routines are used EXCLUSIVELY by
196 // synchronization functions. They are not really gc safe.
197 // They must get updated if markWord layout get changed.
198 markWord set_unlocked() const {
199 return markWord(value() | unlocked_value);
200 }
201
202 bool is_fast_locked() const {
203 return (value() & lock_mask_in_place) == locked_value;
204 }
205 markWord set_fast_locked() const {
206 // Clear the lock_mask_in_place bits to set locked_value:
207 return markWord(value() & ~lock_mask_in_place);
208 }
209
210 bool has_monitor() const {
211 return ((value() & lock_mask_in_place) == monitor_value);
212 }
253 // age operations
254 markWord set_marked() { return markWord((value() & ~lock_mask_in_place) | marked_value); }
255 markWord set_unmarked() { return markWord((value() & ~lock_mask_in_place) | unlocked_value); }
256
257 uint age() const { return (uint) mask_bits(value() >> age_shift, age_mask); }
258 markWord set_age(uint v) const {
259 assert((v & ~age_mask) == 0, "shouldn't overflow age field");
260 return markWord((value() & ~age_mask_in_place) | ((v & age_mask) << age_shift));
261 }
262 markWord incr_age() const { return age() == max_age ? markWord(_value) : set_age(age() + 1); }
263
264 // hash operations
265 intptr_t hash() const {
266 return mask_bits(value() >> hash_shift, hash_mask);
267 }
268
269 bool has_no_hash() const {
270 return hash() == no_hash;
271 }
272
273 inline Klass* klass() const;
274 inline Klass* klass_or_null() const;
275 inline Klass* klass_without_asserts() const;
276 inline narrowKlass narrow_klass() const;
277 inline markWord set_narrow_klass(narrowKlass narrow_klass) const;
278
279 // Prototype mark for initialization
280 static markWord prototype() {
281 return markWord( no_hash_in_place | no_lock_in_place );
282 }
283
284 // Debugging
285 void print_on(outputStream* st, bool print_monitor_info = true) const;
286
287 // Prepare address of oop for placement into mark
288 inline static markWord encode_pointer_as_mark(void* p) { return from_pointer(p).set_marked(); }
289
290 // Recover address of oop from encoded form used in mark
291 inline void* decode_pointer() const { return (void*)clear_lock_bits().value(); }
292
293 inline bool is_self_forwarded() const {
294 return mask_bits(value(), self_fwd_mask_in_place) != 0;
295 }
296
297 inline markWord set_self_forwarded() const {
298 return markWord(value() | self_fwd_mask_in_place);
299 }
300
301 inline markWord unset_self_forwarded() const {
302 return markWord(value() & ~self_fwd_mask_in_place);
303 }
304
305 inline oop forwardee() const {
306 return cast_to_oop(decode_pointer());
307 }
308 };
309
310 // Support atomic operations.
311 template<>
|
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
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 "layoutKind.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 #include <type_traits>
36
37 // The markWord describes the header of an object.
38 //
39 // Bit-format of an object header (most significant first, big endian layout below):
40 //
41 // 32 bits:
42 // --------
43 // hash:25 ------------>| age:4 self-fwd:1 lock:2 (normal object)
44 //
45 // 64 bits:
46 // --------
47 // unused:22 hash:31 -->| valhalla:4 age:4 self-fwd:1 lock:2 (normal object)
48 //
49 // 64 bits (with compact headers):
50 // -------------------------------
51 // klass:22 hash:31 -->| valhalla:4 age:4 self-fwd:1 lock:2 (normal object)
52 //
53 // - hash contains the identity hash value: largest value is
54 // 31 bits, see os::random(). Also, 64-bit vm's require
55 // a hash value no bigger than 32 bits because they will not
56 // properly generate a mask larger than that: see library_call.cpp
57 //
58 // - the two lock bits are used to describe three states: locked/unlocked and monitor.
59 //
60 // [ptr | 00] locked ptr points to real header on stack (stack-locking in use)
61 // [header | 00] locked locked regular object header (fast-locking in use)
62 // [header | 01] unlocked regular object header
63 // [ptr | 10] monitor inflated lock (header is swapped out, UseObjectMonitorTable == false)
64 // [header | 10] monitor inflated lock (UseObjectMonitorTable == true)
65 // [ptr | 11] marked used to mark an object
66 // [0 ............ 0| 00] inflating inflation in progress (stack-locking in use)
67 //
68 // We assume that stack/thread pointers have the lowest two bits cleared.
69 //
70 //
71 // - INFLATING() is a distinguished markword value of all zeros that is
72 // used when inflating an existing stack-lock into an ObjectMonitor.
73 // See below for is_being_inflated() and INFLATING().
74 //
75 // VALHALLA EXTENSIONS:
76 //
77 // N.B.: 32 bit mode is not supported, this section assumes 64 bit systems.
78 //
79 // Project Valhalla uses markWord bits to denote the following oops (listed least to most significant):
80 // * inline types: have alternative bytecode behavior, e.g. can not be locked
81 // * flat arrays: load/decode of klass layout helper is expensive for aaload
82 // * "null free" arrays: load/decode of klass layout helper again for aaload
83 // * inline type: "larval state": mutable state, but only during object init, observable
84 // by only by a single thread (generally do not mutate markWord)
85 //
86 // Inline types cannot be locked, monitored or inflating.
87 //
88 // Note the position of 'self-fwd' is not by accident. When forwarding an
89 // object to a new heap position, HeapWord alignment guarantees the lower
90 // bits, including 'self-fwd' are 0. "is_self_forwarded()" will be correctly
91 // set to false. Otherwise encode_pointer_as_mark() may have 'self-fwd' set.
92
93 class BasicLock;
94 class ObjectMonitor;
95 class JavaThread;
96 class outputStream;
97
98 class markWord {
99 private:
100 uintptr_t _value;
101
102 public:
103 explicit markWord(uintptr_t value) : _value(value) {}
104
105 markWord() = default; // Doesn't initialize _value.
106
107 // It is critical for performance that this class be trivially
108 // destructable, copyable, and assignable.
109 ~markWord() = default;
110 markWord(const markWord&) = default;
111 markWord& operator=(const markWord&) = default;
112
113 static markWord from_pointer(void* ptr) {
114 return markWord((uintptr_t)ptr);
115 }
116 void* to_pointer() const {
117 return (void*)_value;
118 }
119
120 bool operator==(const markWord& other) const {
121 return _value == other._value;
122 }
123 bool operator!=(const markWord& other) const {
124 return !operator==(other);
125 }
126
127 // Conversion
128 uintptr_t value() const { return _value; }
129
130 // Constants, in least significant bit order
131 static const int lock_bits = 2;
132 static const int self_fwd_bits = 1;
133 // instance state
134 static const int age_bits = 4;
135 // EnableValhalla: static prototype header bits (fast path instead of klass layout_helper)
136 static const int inline_type_bits = 1;
137 static const int null_free_array_bits = LP64_ONLY(1) NOT_LP64(0);
138 static const int flat_array_bits = LP64_ONLY(1) NOT_LP64(0);
139 static const int larval_bits = 1;
140 static const int max_hash_bits = BitsPerWord - age_bits - lock_bits - inline_type_bits - larval_bits - flat_array_bits - null_free_array_bits - self_fwd_bits;
141 static const int hash_bits = max_hash_bits > 31 ? 31 : max_hash_bits;
142
143 static const int lock_shift = 0;
144 static const int self_fwd_shift = lock_shift + lock_bits;
145 static const int age_shift = self_fwd_shift + self_fwd_bits;
146 static const int inline_type_shift = age_shift + age_bits;
147 static const int null_free_array_shift = inline_type_shift + inline_type_bits;
148 static const int flat_array_shift = null_free_array_shift + null_free_array_bits;
149 static const int larval_shift = flat_array_shift + flat_array_bits;
150 static const int hash_shift = larval_shift + larval_bits;
151
152 static const uintptr_t lock_mask = right_n_bits(lock_bits);
153 static const uintptr_t lock_mask_in_place = lock_mask << lock_shift;
154 static const uintptr_t self_fwd_mask = right_n_bits(self_fwd_bits);
155 static const uintptr_t self_fwd_mask_in_place = self_fwd_mask << self_fwd_shift;
156 static const uintptr_t inline_type_bit_in_place = right_n_bits(inline_type_bits) << inline_type_shift;
157 static const uintptr_t inline_type_mask_in_place = inline_type_bit_in_place + lock_mask;
158 static const uintptr_t null_free_array_mask = right_n_bits(null_free_array_bits);
159 static const uintptr_t null_free_array_mask_in_place = (null_free_array_mask << null_free_array_shift) | lock_mask_in_place;
160 static const uintptr_t null_free_array_bit_in_place = (right_n_bits(null_free_array_bits) << null_free_array_shift);
161 static const uintptr_t flat_array_mask = right_n_bits(flat_array_bits);
162 static const uintptr_t flat_array_mask_in_place = (flat_array_mask << flat_array_shift) | null_free_array_mask_in_place | lock_mask_in_place;
163 static const uintptr_t flat_array_bit_in_place = right_n_bits(flat_array_bits) << flat_array_shift;
164 static const uintptr_t age_mask = right_n_bits(age_bits);
165 static const uintptr_t age_mask_in_place = age_mask << age_shift;
166
167 static const uintptr_t larval_mask = right_n_bits(larval_bits);
168 static const uintptr_t larval_mask_in_place = (larval_mask << larval_shift) | inline_type_mask_in_place;
169 static const uintptr_t larval_bit_in_place = right_n_bits(larval_bits) << larval_shift;
170
171 static const uintptr_t hash_mask = right_n_bits(hash_bits);
172 static const uintptr_t hash_mask_in_place = hash_mask << hash_shift;
173
174 #ifdef _LP64
175 // Used only with compact headers:
176 // We store the (narrow) Klass* in the bits 43 to 64.
177
178 // These are for bit-precise extraction of the narrow Klass* from the 64-bit Markword
179 static constexpr int klass_offset_in_bytes = 4;
180 static constexpr int klass_shift = hash_shift + hash_bits;
181 static constexpr int klass_shift_at_offset = klass_shift - klass_offset_in_bytes * BitsPerByte;
182 static constexpr int klass_bits = 22;
183 static constexpr uintptr_t klass_mask = right_n_bits(klass_bits);
184 static constexpr uintptr_t klass_mask_in_place = klass_mask << klass_shift;
185 #endif
186
187
188 static const uintptr_t locked_value = 0;
189 static const uintptr_t unlocked_value = 1;
190 static const uintptr_t monitor_value = 2;
191 static const uintptr_t marked_value = 3;
192
193 static const uintptr_t inline_type_pattern = inline_type_bit_in_place | unlocked_value;
194 static const uintptr_t null_free_array_pattern = null_free_array_bit_in_place | unlocked_value;
195 static const uintptr_t null_free_flat_array_pattern = flat_array_bit_in_place | null_free_array_pattern;
196 static const uintptr_t nullable_flat_array_pattern = flat_array_bit_in_place | unlocked_value;
197
198 static const uintptr_t larval_pattern = larval_bit_in_place | inline_type_pattern;
199
200 static const uintptr_t no_hash = 0 ; // no hash value assigned
201 static const uintptr_t no_hash_in_place = (uintptr_t)no_hash << hash_shift;
202 static const uintptr_t no_lock_in_place = unlocked_value;
203
204 static const uint max_age = age_mask;
205
206 // Creates a markWord with all bits set to zero.
207 static markWord zero() { return markWord(uintptr_t(0)); }
208
209 bool is_inline_type() const {
210 return (mask_bits(value(), inline_type_mask_in_place) == inline_type_pattern);
211 }
212
213 // lock accessors (note that these assume lock_shift == 0)
214 bool is_locked() const {
215 return (mask_bits(value(), lock_mask_in_place) != unlocked_value);
216 }
217 bool is_unlocked() const {
218 return (mask_bits(value(), lock_mask_in_place) == unlocked_value);
219 }
220 bool is_marked() const {
221 return (mask_bits(value(), lock_mask_in_place) == marked_value);
222 }
223
224 // is unlocked and not an inline type (which cannot be involved in locking, displacement or inflation)
225 // i.e. test both lock bits and the inline type bit together
226 bool is_neutral() const { // Not locked, or marked - a "clean" neutral state
227 return (mask_bits(value(), inline_type_mask_in_place) == unlocked_value);
228 }
229
230 bool is_forwarded() const {
231 // Returns true for normal forwarded (0b011) and self-forwarded (0b1xx).
232 return mask_bits(value(), lock_mask_in_place | self_fwd_mask_in_place) >= static_cast<intptr_t>(marked_value);
233 }
234
235 // Special temporary state of the markWord while being inflated.
236 // Code that looks at mark outside a lock need to take this into account.
237 bool is_being_inflated() const { return (value() == 0); }
238
239 // Distinguished markword value - used when inflating over
240 // an existing stack-lock. 0 indicates the markword is "BUSY".
241 // Lockword mutators that use a LD...CAS idiom should always
242 // check for and avoid overwriting a 0 value installed by some
243 // other thread. (They should spin or block instead. The 0 value
244 // is transient and *should* be short-lived).
245 // Fast-locking does not use INFLATING.
246 static markWord INFLATING() { return zero(); } // inflate-in-progress
247
248 // Should this header be preserved during GC?
249 bool must_be_preserved() const {
250 return (!is_unlocked() || !has_no_hash() ||
251 (EnableValhalla && (is_larval_state() || is_inline_type() || is_flat_array() || is_null_free_array())));
252 }
253
254 // WARNING: The following routines are used EXCLUSIVELY by
255 // synchronization functions. They are not really gc safe.
256 // They must get updated if markWord layout get changed.
257 markWord set_unlocked() const {
258 return markWord(value() | unlocked_value);
259 }
260
261 bool is_fast_locked() const {
262 return (value() & lock_mask_in_place) == locked_value;
263 }
264 markWord set_fast_locked() const {
265 // Clear the lock_mask_in_place bits to set locked_value:
266 return markWord(value() & ~lock_mask_in_place);
267 }
268
269 bool has_monitor() const {
270 return ((value() & lock_mask_in_place) == monitor_value);
271 }
312 // age operations
313 markWord set_marked() { return markWord((value() & ~lock_mask_in_place) | marked_value); }
314 markWord set_unmarked() { return markWord((value() & ~lock_mask_in_place) | unlocked_value); }
315
316 uint age() const { return (uint) mask_bits(value() >> age_shift, age_mask); }
317 markWord set_age(uint v) const {
318 assert((v & ~age_mask) == 0, "shouldn't overflow age field");
319 return markWord((value() & ~age_mask_in_place) | ((v & age_mask) << age_shift));
320 }
321 markWord incr_age() const { return age() == max_age ? markWord(_value) : set_age(age() + 1); }
322
323 // hash operations
324 intptr_t hash() const {
325 return mask_bits(value() >> hash_shift, hash_mask);
326 }
327
328 bool has_no_hash() const {
329 return hash() == no_hash;
330 }
331
332 // private buffered value operations
333 markWord enter_larval_state() const {
334 return markWord(value() | larval_bit_in_place);
335 }
336 markWord exit_larval_state() const {
337 return markWord(value() & ~larval_bit_in_place);
338 }
339 bool is_larval_state() const {
340 return (mask_bits(value(), larval_mask_in_place) == larval_pattern);
341 }
342
343 bool is_flat_array() const {
344 #ifdef _LP64 // 64 bit encodings only
345 return (mask_bits(value(), flat_array_mask_in_place) == null_free_flat_array_pattern)
346 || (mask_bits(value(), flat_array_mask_in_place) == nullable_flat_array_pattern);
347 #else
348 return false;
349 #endif
350 }
351
352 bool is_null_free_array() const {
353 #ifdef _LP64 // 64 bit encodings only
354 return (mask_bits(value(), null_free_array_mask_in_place) == null_free_array_pattern);
355 #else
356 return false;
357 #endif
358 }
359
360 inline Klass* klass() const;
361 inline Klass* klass_or_null() const;
362 inline Klass* klass_without_asserts() const;
363 inline narrowKlass narrow_klass() const;
364 inline markWord set_narrow_klass(narrowKlass narrow_klass) const;
365
366 // Prototype mark for initialization
367 static markWord prototype() {
368 return markWord( no_hash_in_place | no_lock_in_place );
369 }
370
371 static markWord inline_type_prototype() {
372 return markWord(inline_type_pattern);
373 }
374
375 #ifdef _LP64 // 64 bit encodings only
376 static markWord flat_array_prototype(LayoutKind lk);
377
378 static markWord null_free_array_prototype() {
379 return markWord(null_free_array_pattern);
380 }
381 #endif
382
383 // Debugging
384 void print_on(outputStream* st, bool print_monitor_info = true) const;
385
386 // Prepare address of oop for placement into mark
387 inline static markWord encode_pointer_as_mark(void* p) { return from_pointer(p).set_marked(); }
388
389 inline void* decode_pointer() const {
390 return (void*) (clear_lock_bits().value());
391 }
392
393 inline bool is_self_forwarded() const {
394 return mask_bits(value(), self_fwd_mask_in_place) != 0;
395 }
396
397 inline markWord set_self_forwarded() const {
398 return markWord(value() | self_fwd_mask_in_place);
399 }
400
401 inline markWord unset_self_forwarded() const {
402 return markWord(value() & ~self_fwd_mask_in_place);
403 }
404
405 inline oop forwardee() const {
406 return cast_to_oop(decode_pointer());
407 }
408 };
409
410 // Support atomic operations.
411 template<>
|