Skip to content

Commit c1603d8

Browse files
committed
Follow JEP450 MarkWord specification.
1 parent c600049 commit c1603d8

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

src/hotspot/share/oops/markWord.hpp

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,9 @@
111111
// --------
112112
// hash:24 ------------>| larval:1 age:4 inline_type:1 lock:2
113113
//
114-
// 64 bits:
114+
// 64 bits (follows ocmpact object header):
115115
// --------
116-
// unused:1 | <-- hash:31 -->| unused:22 larval:1 age:4 flat_array:1 null_free_array:1 inline_type:1 lock:2
117-
// klass:22 hash:31 -->| larval:1 age:4 flat_array:1 null_free_array:1 inline_type:1 self-fwd:1 lock:2 (normal object)
116+
// klass:22 hash:31 -->| larval:1 flat_array:1 null_free_array:1 inline_type:1 age:4 self-fwd:1 lock:2 (normal object)
118117
//
119118
// The "fast" static type bits (flat_array, null_free_array, and inline_type)
120119
// are placed lowest next to lock bits to more easily decode forwarding pointers.
@@ -183,44 +182,43 @@ class markWord {
183182
// Constants, in least significant bit order
184183
static const int lock_bits = 2;
185184
static const int self_fwd_bits = 1;
185+
// instance state
186+
static const int age_bits = 4;
186187
// EnableValhalla: static prototype header bits (fast path instead of klass layout_helper)
187188
static const int inline_type_bits = 1;
188189
static const int null_free_array_bits = LP64_ONLY(1) NOT_LP64(0);
189190
static const int flat_array_bits = LP64_ONLY(1) NOT_LP64(0);
190-
// instance state
191-
static const int age_bits = 4;
192191
static const int larval_bits = 1;
193192
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;
194193
static const int hash_bits = max_hash_bits > 31 ? 31 : max_hash_bits;
195194

196195
static const int lock_shift = 0;
197-
static const int self_fwd_shift = lock_bits ;
198-
static const int inline_type_shift = self_fwd_shift + self_fwd_bits;
196+
static const int self_fwd_shift = lock_shift + lock_bits;
197+
static const int age_shift = self_fwd_shift + self_fwd_bits;
198+
static const int inline_type_shift = age_shift + age_bits;
199199
static const int null_free_array_shift = inline_type_shift + inline_type_bits;
200200
static const int flat_array_shift = null_free_array_shift + null_free_array_bits;
201-
static const int age_shift = flat_array_shift + flat_array_bits;
202-
static const int larval_shift = age_shift + age_bits;
201+
static const int larval_shift = flat_array_shift + flat_array_bits;
203202
static const int hash_shift = larval_shift + larval_bits;
204203

205204
static const uintptr_t lock_mask = right_n_bits(lock_bits);
206205
static const uintptr_t lock_mask_in_place = lock_mask << lock_shift;
207206
static const uintptr_t self_fwd_mask = right_n_bits(self_fwd_bits);
208207
static const uintptr_t self_fwd_mask_in_place = self_fwd_mask << self_fwd_shift;
209-
static const uintptr_t inline_type_bit_in_place = 1 << inline_type_shift;
210-
static const uintptr_t inline_type_mask = inline_type_bit_in_place + lock_mask;
211-
static const uintptr_t inline_type_mask_in_place = inline_type_mask << lock_shift;
208+
static const uintptr_t inline_type_bit_in_place = right_n_bits(inline_type_bits) << inline_type_shift;
209+
static const uintptr_t inline_type_mask_in_place = inline_type_bit_in_place + lock_mask;
212210
static const uintptr_t null_free_array_mask = right_n_bits(null_free_array_bits);
213211
static const uintptr_t null_free_array_mask_in_place = (null_free_array_mask << null_free_array_shift) | lock_mask_in_place;
214-
static const uintptr_t null_free_array_bit_in_place = (1 << null_free_array_shift);
212+
static const uintptr_t null_free_array_bit_in_place = (right_n_bits(null_free_array_bits) << null_free_array_shift);
215213
static const uintptr_t flat_array_mask = right_n_bits(flat_array_bits);
216214
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;
217-
static const uintptr_t flat_array_bit_in_place = (1 << flat_array_shift);
215+
static const uintptr_t flat_array_bit_in_place = right_n_bits(flat_array_bits) << flat_array_shift;
218216
static const uintptr_t age_mask = right_n_bits(age_bits);
219217
static const uintptr_t age_mask_in_place = age_mask << age_shift;
220218

221219
static const uintptr_t larval_mask = right_n_bits(larval_bits);
222220
static const uintptr_t larval_mask_in_place = (larval_mask << larval_shift) | inline_type_mask_in_place;
223-
static const uintptr_t larval_bit_in_place = (1 << larval_shift);
221+
static const uintptr_t larval_bit_in_place = right_n_bits(larval_bits) << larval_shift;
224222

225223
static const uintptr_t hash_mask = right_n_bits(hash_bits);
226224
static const uintptr_t hash_mask_in_place = hash_mask << hash_shift;

0 commit comments

Comments
 (0)