@@ -131,61 +131,54 @@ class markWord {
131
131
uintptr_t value () const { return _value; }
132
132
133
133
// Constants
134
- enum { age_bits = 4 ,
135
- lock_bits = 2 ,
136
- biased_lock_bits = 1 ,
137
- max_hash_bits = BitsPerWord - age_bits - lock_bits - biased_lock_bits,
138
- hash_bits = max_hash_bits > 31 ? 31 : max_hash_bits,
139
- cms_bits = LP64_ONLY (1 ) NOT_LP64 (0 ),
140
- epoch_bits = 2
141
- };
134
+ static const int age_bits = 4 ;
135
+ static const int lock_bits = 2 ;
136
+ static const int biased_lock_bits = 1 ;
137
+ static const int max_hash_bits = BitsPerWord - age_bits - lock_bits - biased_lock_bits;
138
+ static const int hash_bits = max_hash_bits > 31 ? 31 : max_hash_bits;
139
+ static const int cms_bits = LP64_ONLY(1 ) NOT_LP64(0 );
140
+ static const int epoch_bits = 2 ;
142
141
143
142
// The biased locking code currently requires that the age bits be
144
143
// contiguous to the lock bits.
145
- enum { lock_shift = 0 ,
146
- biased_lock_shift = lock_bits,
147
- age_shift = lock_bits + biased_lock_bits,
148
- cms_shift = age_shift + age_bits,
149
- hash_shift = cms_shift + cms_bits,
150
- epoch_shift = hash_shift
151
- };
152
-
153
- enum { lock_mask = right_n_bits (lock_bits),
154
- lock_mask_in_place = lock_mask << lock_shift,
155
- biased_lock_mask = right_n_bits (lock_bits + biased_lock_bits),
156
- biased_lock_mask_in_place= biased_lock_mask << lock_shift,
157
- biased_lock_bit_in_place = 1 << biased_lock_shift,
158
- age_mask = right_n_bits (age_bits),
159
- age_mask_in_place = age_mask << age_shift,
160
- epoch_mask = right_n_bits (epoch_bits),
161
- epoch_mask_in_place = epoch_mask << epoch_shift,
162
- cms_mask = right_n_bits (cms_bits),
163
- cms_mask_in_place = cms_mask << cms_shift
164
- };
165
-
166
- const static uintptr_t hash_mask = right_n_bits(hash_bits);
167
- const static uintptr_t hash_mask_in_place = hash_mask << hash_shift;
144
+ static const int lock_shift = 0 ;
145
+ static const int biased_lock_shift = lock_bits;
146
+ static const int age_shift = lock_bits + biased_lock_bits;
147
+ static const int cms_shift = age_shift + age_bits;
148
+ static const int hash_shift = cms_shift + cms_bits;
149
+ static const int epoch_shift = hash_shift;
150
+
151
+ static const uintptr_t lock_mask = right_n_bits(lock_bits);
152
+ static const uintptr_t lock_mask_in_place = lock_mask << lock_shift;
153
+ static const uintptr_t biased_lock_mask = right_n_bits(lock_bits + biased_lock_bits);
154
+ static const uintptr_t biased_lock_mask_in_place= biased_lock_mask << lock_shift;
155
+ static const uintptr_t biased_lock_bit_in_place = 1 << biased_lock_shift;
156
+ static const uintptr_t age_mask = right_n_bits(age_bits);
157
+ static const uintptr_t age_mask_in_place = age_mask << age_shift;
158
+ static const uintptr_t epoch_mask = right_n_bits(epoch_bits);
159
+ static const uintptr_t epoch_mask_in_place = epoch_mask << epoch_shift;
160
+ static const uintptr_t cms_mask = right_n_bits(cms_bits);
161
+ static const uintptr_t cms_mask_in_place = cms_mask << cms_shift;
162
+
163
+ static const uintptr_t hash_mask = right_n_bits(hash_bits);
164
+ static const uintptr_t hash_mask_in_place = hash_mask << hash_shift;
168
165
169
166
// Alignment of JavaThread pointers encoded in object header required by biased locking
170
- enum { biased_lock_alignment = 2 << (epoch_shift + epoch_bits)
171
- };
167
+ static const size_t biased_lock_alignment = 2 << (epoch_shift + epoch_bits);
172
168
173
- enum { locked_value = 0 ,
174
- unlocked_value = 1 ,
175
- monitor_value = 2 ,
176
- marked_value = 3 ,
177
- biased_lock_pattern = 5
178
- };
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
+ static const uintptr_t biased_lock_pattern = 5 ;
179
174
180
- enum { no_hash = 0 }; // no hash value assigned
175
+ static const uintptr_t no_hash = 0 ; // no hash value assigned
176
+ static const uintptr_t no_hash_in_place = (address_word)no_hash << hash_shift;
177
+ static const uintptr_t no_lock_in_place = unlocked_value;
181
178
182
- enum { no_hash_in_place = (address_word)no_hash << hash_shift,
183
- no_lock_in_place = unlocked_value
184
- };
179
+ static const uint max_age = age_mask;
185
180
186
- enum { max_age = age_mask };
187
-
188
- enum { max_bias_epoch = epoch_mask };
181
+ static const int max_bias_epoch = epoch_mask;
189
182
190
183
// Creates a markWord with all bits set to zero.
191
184
static markWord zero () { return markWord (uintptr_t (0 )); }
@@ -201,7 +194,7 @@ class markWord {
201
194
}
202
195
JavaThread* biased_locker () const {
203
196
assert (has_bias_pattern (), " should not call this otherwise" );
204
- return (JavaThread*) (( intptr_t ) ( mask_bits (value (), ~(biased_lock_mask_in_place | age_mask_in_place | epoch_mask_in_place)) ));
197
+ return (JavaThread*) mask_bits (value (), ~(biased_lock_mask_in_place | age_mask_in_place | epoch_mask_in_place));
205
198
}
206
199
// Indicates that the mark has the bias bit set but that it has not
207
200
// yet been biased toward a particular thread
@@ -308,16 +301,16 @@ class markWord {
308
301
}
309
302
markWord displaced_mark_helper () const {
310
303
assert (has_displaced_mark_helper (), " check" );
311
- intptr_t ptr = (value () & ~monitor_value);
304
+ uintptr_t ptr = (value () & ~monitor_value);
312
305
return *(markWord*)ptr;
313
306
}
314
307
void set_displaced_mark_helper (markWord m) const {
315
308
assert (has_displaced_mark_helper (), " check" );
316
- intptr_t ptr = (value () & ~monitor_value);
309
+ uintptr_t ptr = (value () & ~monitor_value);
317
310
((markWord*)ptr)->_value = m._value ;
318
311
}
319
312
markWord copy_set_hash (intptr_t hash) const {
320
- intptr_t tmp = value () & (~hash_mask_in_place);
313
+ uintptr_t tmp = value () & (~hash_mask_in_place);
321
314
tmp |= ((hash & hash_mask) << hash_shift);
322
315
return markWord (tmp);
323
316
}
@@ -332,11 +325,11 @@ class markWord {
332
325
return from_pointer (lock);
333
326
}
334
327
static markWord encode (ObjectMonitor* monitor) {
335
- intptr_t tmp = (intptr_t ) monitor;
328
+ uintptr_t tmp = (uintptr_t ) monitor;
336
329
return markWord (tmp | monitor_value);
337
330
}
338
331
static markWord encode (JavaThread* thread, uint age, int bias_epoch) {
339
- intptr_t tmp = (intptr_t ) thread;
332
+ uintptr_t tmp = (uintptr_t ) thread;
340
333
assert (UseBiasedLocking && ((tmp & (epoch_mask_in_place | age_mask_in_place | biased_lock_mask_in_place)) == 0 ), " misaligned JavaThread pointer" );
341
334
assert (age <= max_age, " age too large" );
342
335
assert (bias_epoch <= max_bias_epoch, " bias epoch too large" );
@@ -353,7 +346,7 @@ class markWord {
353
346
uint age () const { return mask_bits (value () >> age_shift, age_mask); }
354
347
markWord set_age (uint v) const {
355
348
assert ((v & ~age_mask) == 0 , " shouldn't overflow age field" );
356
- return markWord ((value () & ~age_mask_in_place) | ((( uintptr_t ) v & age_mask) << age_shift));
349
+ return markWord ((value () & ~age_mask_in_place) | ((v & age_mask) << age_shift));
357
350
}
358
351
markWord incr_age () const { return age () == max_age ? markWord (_value) : set_age (age () + 1 ); }
359
352
@@ -400,7 +393,7 @@ class markWord {
400
393
401
394
#ifdef _LP64
402
395
static markWord cms_free_prototype () {
403
- return markWord ((( intptr_t ) prototype ().value () & ~cms_mask_in_place) |
396
+ return markWord ((prototype ().value () & ~cms_mask_in_place) |
404
397
((cms_free_chunk_pattern & cms_mask) << cms_shift));
405
398
}
406
399
uintptr_t cms_encoding () const {
@@ -414,8 +407,8 @@ class markWord {
414
407
size_t get_size () const { return (size_t )(value () >> size_shift); }
415
408
static markWord set_size_and_free (size_t size) {
416
409
assert ((size & ~size_mask) == 0 , " shouldn't overflow size field" );
417
- return markWord ((( intptr_t ) cms_free_prototype ().value () & ~size_mask_in_place) |
418
- ((( intptr_t ) size & size_mask) << size_shift));
410
+ return markWord ((cms_free_prototype ().value () & ~size_mask_in_place) |
411
+ ((size & size_mask) << size_shift));
419
412
}
420
413
#endif // _LP64
421
414
};
0 commit comments