mirror of
https://github.com/openjdk/jdk.git
synced 2026-03-02 04:00:16 +00:00
8318015: Lock inflation not needed for OSR or Deopt for new locking modes
Reviewed-by: pchilanomate, dlong
This commit is contained in:
parent
6aa837eee6
commit
d0ea2a5111
@ -66,19 +66,26 @@ void BasicLock::move_to(oop obj, BasicLock* dest) {
|
||||
// is small (given the support for inflated fast-path locking in the fast_lock, etc)
|
||||
// we'll leave that optimization for another time.
|
||||
|
||||
if (displaced_header().is_neutral()) {
|
||||
// The object is locked and the resulting ObjectMonitor* will also be
|
||||
// locked so it can't be async deflated until ownership is dropped.
|
||||
ObjectSynchronizer::inflate_helper(obj);
|
||||
// WARNING: We cannot put a check here, because the inflation
|
||||
// will not update the displaced header. Once BasicLock is inflated,
|
||||
// no one should ever look at its content.
|
||||
} else {
|
||||
// Typically the displaced header will be 0 (recursive stack lock) or
|
||||
// unused_mark. Naively we'd like to assert that the displaced mark
|
||||
// value is either 0, neutral, or 3. But with the advent of the
|
||||
// store-before-CAS avoidance in fast_lock/compiler_lock_object
|
||||
// we can find any flavor mark in the displaced mark.
|
||||
if (LockingMode == LM_LEGACY) {
|
||||
if (displaced_header().is_neutral()) {
|
||||
// The object is locked and the resulting ObjectMonitor* will also be
|
||||
// locked so it can't be async deflated until ownership is dropped.
|
||||
ObjectSynchronizer::inflate_helper(obj);
|
||||
// WARNING: We cannot put a check here, because the inflation
|
||||
// will not update the displaced header. Once BasicLock is inflated,
|
||||
// no one should ever look at its content.
|
||||
} else {
|
||||
// Typically the displaced header will be 0 (recursive stack lock) or
|
||||
// unused_mark. Naively we'd like to assert that the displaced mark
|
||||
// value is either 0, neutral, or 3. But with the advent of the
|
||||
// store-before-CAS avoidance in fast_lock/compiler_lock_object
|
||||
// we can find any flavor mark in the displaced mark.
|
||||
}
|
||||
dest->set_displaced_header(displaced_header());
|
||||
}
|
||||
dest->set_displaced_header(displaced_header());
|
||||
#ifdef ASSERT
|
||||
else {
|
||||
dest->set_displaced_header(markWord(badDispHeaderDeopt));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -3257,16 +3257,24 @@ JRT_LEAF(intptr_t*, SharedRuntime::OSR_migration_begin( JavaThread *current) )
|
||||
kptr2 = fr.next_monitor_in_interpreter_frame(kptr2) ) {
|
||||
if (kptr2->obj() != nullptr) { // Avoid 'holes' in the monitor array
|
||||
BasicLock *lock = kptr2->lock();
|
||||
// Inflate so the object's header no longer refers to the BasicLock.
|
||||
if (lock->displaced_header().is_unlocked()) {
|
||||
// The object is locked and the resulting ObjectMonitor* will also be
|
||||
// locked so it can't be async deflated until ownership is dropped.
|
||||
// See the big comment in basicLock.cpp: BasicLock::move_to().
|
||||
ObjectSynchronizer::inflate_helper(kptr2->obj());
|
||||
if (LockingMode == LM_LEGACY) {
|
||||
// Inflate so the object's header no longer refers to the BasicLock.
|
||||
if (lock->displaced_header().is_unlocked()) {
|
||||
// The object is locked and the resulting ObjectMonitor* will also be
|
||||
// locked so it can't be async deflated until ownership is dropped.
|
||||
// See the big comment in basicLock.cpp: BasicLock::move_to().
|
||||
ObjectSynchronizer::inflate_helper(kptr2->obj());
|
||||
}
|
||||
// Now the displaced header is free to move because the
|
||||
// object's header no longer refers to it.
|
||||
buf[i] = (intptr_t)lock->displaced_header().value();
|
||||
}
|
||||
// Now the displaced header is free to move because the
|
||||
// object's header no longer refers to it.
|
||||
buf[i++] = (intptr_t)lock->displaced_header().value();
|
||||
#ifdef ASSERT
|
||||
else {
|
||||
buf[i] = badDispHeaderOSR;
|
||||
}
|
||||
#endif
|
||||
i++;
|
||||
buf[i++] = cast_from_oop<intptr_t>(kptr2->obj());
|
||||
}
|
||||
}
|
||||
|
||||
@ -1036,7 +1036,8 @@ const juint badHeapWordVal = 0xBAADBABE; // value used to zap
|
||||
const juint badMetaWordVal = 0xBAADFADE; // value used to zap metadata heap after GC
|
||||
const int badCodeHeapNewVal= 0xCC; // value used to zap Code heap at allocation
|
||||
const int badCodeHeapFreeVal = 0xDD; // value used to zap Code heap at deallocation
|
||||
|
||||
const intptr_t badDispHeaderDeopt = 0xDE0BD000; // value to fill unused displaced header during deoptimization
|
||||
const intptr_t badDispHeaderOSR = 0xDEAD05A0; // value to fill unused displaced header during OSR
|
||||
|
||||
// (These must be implemented as #defines because C++ compilers are
|
||||
// not obligated to inline non-integral constants!)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user