Skip to content

Commit a3fb148

Browse files
committed
8255522: [lworld] References to biased pattern remain in markWord::is_unlocked()
Reviewed-by: fparain, skuksenko
1 parent e9724e5 commit a3fb148

File tree

11 files changed

+148
-14
lines changed

11 files changed

+148
-14
lines changed

src/hotspot/share/memory/heapShared.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ void HeapShared::fixup_mapped_heap_regions() {
118118
}
119119

120120
unsigned HeapShared::oop_hash(oop const& p) {
121-
assert(!p->mark().has_bias_pattern(),
121+
assert(!UseBiasedLocking || !p->mark().has_bias_pattern(),
122122
"this object should never have been locked"); // so identity_hash won't safepoin
123123
unsigned hash = (unsigned)p->identity_hash();
124124
return hash;

src/hotspot/share/oops/klass.inline.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
inline void Klass::set_prototype_header(markWord header) {
3333
assert(!is_inline_klass() || header.is_inline_type(), "Unexpected prototype");
34-
assert(!header.has_bias_pattern() || is_instance_klass(), "biased locking currently only supported for Java instances");
34+
assert(!UseBiasedLocking || !header.has_bias_pattern() || is_instance_klass(), "biased locking currently only supported for Java instances");
3535
_prototype_header = header;
3636
}
3737

src/hotspot/share/oops/markWord.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ void markWord::print_on(outputStream* st, bool print_monitor_info) const {
8888
} else {
8989
st->print(" hash=" INTPTR_FORMAT, hash());
9090
}
91-
} else if (has_bias_pattern()) { // last bits = 101
91+
} else if (UseBiasedLocking && has_bias_pattern()) { // last bits = 101
9292
st->print("is_biased");
9393
JavaThread* jt = biased_locker();
9494
st->print(" biased_locker=" INTPTR_FORMAT " epoch=%d", p2i(jt), bias_epoch());

src/hotspot/share/oops/markWord.hpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,34 +290,41 @@ class markWord {
290290
// fixes up biased locks to be compatible with it when a bias is
291291
// revoked.
292292
bool has_bias_pattern() const {
293+
ShouldNotReachHere(); // Valhalla: unused
293294
return (mask_bits(value(), biased_lock_mask_in_place) == biased_lock_pattern);
294295
}
295296
JavaThread* biased_locker() const {
297+
ShouldNotReachHere(); // Valhalla: unused
296298
assert(has_bias_pattern(), "should not call this otherwise");
297299
return (JavaThread*) mask_bits(value(), ~(biased_lock_mask_in_place | age_mask_in_place | epoch_mask_in_place));
298300
}
299301
// Indicates that the mark has the bias bit set but that it has not
300302
// yet been biased toward a particular thread
301303
bool is_biased_anonymously() const {
304+
ShouldNotReachHere(); // Valhalla: unused
302305
return (has_bias_pattern() && (biased_locker() == NULL));
303306
}
304307
// Indicates epoch in which this bias was acquired. If the epoch
305308
// changes due to too many bias revocations occurring, the biases
306309
// from the previous epochs are all considered invalid.
307310
int bias_epoch() const {
311+
ShouldNotReachHere(); // Valhalla: unused
308312
assert(has_bias_pattern(), "should not call this otherwise");
309313
return (mask_bits(value(), epoch_mask_in_place) >> epoch_shift);
310314
}
311315
markWord set_bias_epoch(int epoch) {
316+
ShouldNotReachHere(); // Valhalla: unused
312317
assert(has_bias_pattern(), "should not call this otherwise");
313318
assert((epoch & (~epoch_mask)) == 0, "epoch overflow");
314319
return markWord(mask_bits(value(), ~epoch_mask_in_place) | (epoch << epoch_shift));
315320
}
316321
markWord incr_bias_epoch() {
322+
ShouldNotReachHere(); // Valhalla: unused
317323
return set_bias_epoch((1 + bias_epoch()) & epoch_mask);
318324
}
319325
// Prototype mark for initialization
320326
static markWord biased_locking_prototype() {
327+
ShouldNotReachHere(); // Valhalla: unused
321328
return markWord( biased_lock_pattern );
322329
}
323330

@@ -326,12 +333,15 @@ class markWord {
326333
return (mask_bits(value(), lock_mask_in_place) != unlocked_value);
327334
}
328335
bool is_unlocked() const {
329-
return (mask_bits(value(), biased_lock_mask_in_place) == unlocked_value);
336+
return (mask_bits(value(), lock_mask_in_place) == unlocked_value);
330337
}
331338
bool is_marked() const {
332339
return (mask_bits(value(), lock_mask_in_place) == marked_value);
333340
}
334-
bool is_neutral() const { return (mask_bits(value(), biased_lock_mask_in_place) == unlocked_value); }
341+
342+
// is unlocked and not an inline type (which cannot be involved in locking, displacement or inflation)
343+
// i.e. test both lock bits and the inline type bit together
344+
bool is_neutral() const { return (mask_bits(value(), inline_type_mask_in_place) == unlocked_value); }
335345

336346
// Special temporary state of the markWord while being inflated.
337347
// Code that looks at mark outside a lock need to take this into account.

src/hotspot/share/oops/markWord.inline.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ inline bool markWord::must_be_preserved_for_promotion_failure(KlassProxy klass)
7171
inline markWord markWord::prototype_for_klass(const Klass* klass) {
7272
markWord prototype_header = klass->prototype_header();
7373
assert(prototype_header == prototype() ||
74-
prototype_header.has_bias_pattern() ||
74+
(UseBiasedLocking && prototype_header.has_bias_pattern()) ||
7575
prototype_header.is_inline_type() ||
7676
prototype_header.is_flat_array() ||
7777
prototype_header.is_nullfree_array(), "corrupt prototype header");

src/hotspot/share/prims/jvmtiEnvBase.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -968,8 +968,10 @@ JvmtiEnvBase::get_object_monitor_usage(JavaThread* calling_thread, jobject objec
968968
uint32_t debug_bits = 0;
969969
// first derive the object's owner and entry_count (if any)
970970
{
971-
// Revoke any biases before querying the mark word
972-
BiasedLocking::revoke_at_safepoint(hobj);
971+
if (UseBiasedLocking) {
972+
// Revoke any biases before querying the mark word
973+
BiasedLocking::revoke_at_safepoint(hobj);
974+
}
973975

974976
address owner = NULL;
975977
{

src/hotspot/share/runtime/biasedLocking.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -732,6 +732,7 @@ void BiasedLocking::walk_stack_and_revoke(oop obj, JavaThread* biased_locker) {
732732
}
733733

734734
void BiasedLocking::revoke_own_lock(Handle obj, TRAPS) {
735+
assert(UseBiasedLocking, "biased locking not enabled");
735736
JavaThread* thread = THREAD->as_Java_thread();
736737

737738
markWord mark = obj->mark();
@@ -755,6 +756,7 @@ void BiasedLocking::revoke_own_lock(Handle obj, TRAPS) {
755756
}
756757

757758
void BiasedLocking::revoke(Handle obj, TRAPS) {
759+
assert(UseBiasedLocking, "biased locking not enabled");
758760
assert(!SafepointSynchronize::is_at_safepoint(), "must not be called while at safepoint");
759761

760762
while (true) {
@@ -858,6 +860,7 @@ void BiasedLocking::revoke(Handle obj, TRAPS) {
858860

859861
// All objects in objs should be locked by biaser
860862
void BiasedLocking::revoke(GrowableArray<Handle>* objs, JavaThread *biaser) {
863+
assert(UseBiasedLocking, "biased locking not enabled");
861864
bool clean_my_cache = false;
862865
for (int i = 0; i < objs->length(); i++) {
863866
oop obj = (objs->at(i))();
@@ -874,6 +877,7 @@ void BiasedLocking::revoke(GrowableArray<Handle>* objs, JavaThread *biaser) {
874877

875878

876879
void BiasedLocking::revoke_at_safepoint(Handle h_obj) {
880+
assert(UseBiasedLocking, "biased locking not enabled");
877881
assert(SafepointSynchronize::is_at_safepoint(), "must only be called while at safepoint");
878882
oop obj = h_obj();
879883
HeuristicsResult heuristics = update_heuristics(obj);

src/hotspot/share/runtime/globals.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -843,7 +843,7 @@ const intx ObjectAlignmentInBytes = 8;
843843
"Restrict @Contended to trusted classes") \
844844
\
845845
product(bool, UseBiasedLocking, false, \
846-
"(Deprecated) Enable biased locking in JVM") \
846+
"(Deprecated) Enable biased locking in JVM (completely disabled by Valhalla)") \
847847
\
848848
product(intx, BiasedLockingStartupDelay, 0, \
849849
"(Deprecated) Number of milliseconds to wait before enabling " \

src/hotspot/share/runtime/synchronizer.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ void ObjectSynchronizer::enter(Handle obj, BasicLock* lock, TRAPS) {
461461
}
462462

463463
markWord mark = obj->mark();
464-
assert(!mark.has_bias_pattern(), "should not see bias pattern here");
464+
assert(!UseBiasedLocking || !mark.has_bias_pattern(), "should not see bias pattern here");
465465

466466
if (mark.is_neutral()) {
467467
// Anticipate successful CAS -- the ST of the displaced mark must
@@ -503,6 +503,7 @@ void ObjectSynchronizer::exit(oop object, BasicLock* lock, TRAPS) {
503503
assert(!EnableValhalla || !object->klass()->is_inline_klass(), "monitor op on inline type");
504504
// We cannot check for Biased Locking if we are racing an inflation.
505505
assert(mark == markWord::INFLATING() ||
506+
!UseBiasedLocking ||
506507
!mark.has_bias_pattern(), "should not see bias pattern here");
507508

508509
markWord dhw = lock->displaced_header();
@@ -631,8 +632,8 @@ void ObjectSynchronizer::jni_exit(oop obj, Thread* THREAD) {
631632
Handle h_obj(THREAD, obj);
632633
BiasedLocking::revoke(h_obj, THREAD);
633634
obj = h_obj();
635+
assert(!obj->mark().has_bias_pattern(), "biases should be revoked by now");
634636
}
635-
assert(!obj->mark().has_bias_pattern(), "biases should be revoked by now");
636637

637638
// The ObjectMonitor* can't be async deflated until ownership is
638639
// dropped inside exit() and the ObjectMonitor* must be !is_busy().
@@ -934,7 +935,7 @@ intptr_t ObjectSynchronizer::FastHashCode(Thread* self, oop obj) {
934935
markWord mark = read_stable_mark(obj);
935936

936937
// object should remain ineligible for biased locking
937-
assert(!mark.has_bias_pattern(), "invariant");
938+
assert(!UseBiasedLocking || !mark.has_bias_pattern(), "invariant");
938939

939940
if (mark.is_neutral()) { // if this is a normal header
940941
hash = mark.hash();
@@ -1302,7 +1303,7 @@ ObjectMonitor* ObjectSynchronizer::inflate(Thread* self, oop object,
13021303

13031304
for (;;) {
13041305
const markWord mark = object->mark();
1305-
assert(!mark.has_bias_pattern(), "invariant");
1306+
assert(!UseBiasedLocking || !mark.has_bias_pattern(), "invariant");
13061307

13071308
// The mark can be in one of the following states:
13081309
// * Inflated - just return

src/hotspot/share/runtime/vframeArray.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ void vframeArrayElement::fill_in(compiledVFrame* vf, bool realloc_failures) {
9595
if (monitor->owner_is_scalar_replaced()) {
9696
dest->set_obj(NULL);
9797
} else {
98-
assert(monitor->owner() == NULL || (!monitor->owner()->is_unlocked() && !monitor->owner()->has_bias_pattern()), "object must be null or locked, and unbiased");
98+
assert(monitor->owner() == NULL || (!monitor->owner()->is_unlocked() && (!UseBiasedLocking || !monitor->owner()->has_bias_pattern())), "object must be null or locked, and unbiased");
9999
dest->set_obj(monitor->owner());
100100
monitor->lock()->move_to(monitor->owner(), dest->lock());
101101
}

0 commit comments

Comments
 (0)