diff --git a/src/hotspot/share/runtime/basicLock.cpp b/src/hotspot/share/runtime/basicLock.cpp index 40ba712bf6c..b6cb4b075be 100644 --- a/src/hotspot/share/runtime/basicLock.cpp +++ b/src/hotspot/share/runtime/basicLock.cpp @@ -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 } diff --git a/src/hotspot/share/runtime/sharedRuntime.cpp b/src/hotspot/share/runtime/sharedRuntime.cpp index 0920190d679..31a38443672 100644 --- a/src/hotspot/share/runtime/sharedRuntime.cpp +++ b/src/hotspot/share/runtime/sharedRuntime.cpp @@ -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(kptr2->obj()); } } diff --git a/src/hotspot/share/utilities/globalDefinitions.hpp b/src/hotspot/share/utilities/globalDefinitions.hpp index 2bdde4ef375..64d12de094c 100644 --- a/src/hotspot/share/utilities/globalDefinitions.hpp +++ b/src/hotspot/share/utilities/globalDefinitions.hpp @@ -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!)