< prev index next >

src/hotspot/share/runtime/deoptimization.cpp

Print this page
*** 72,10 ***
--- 72,12 ---
  #include "runtime/handles.inline.hpp"
  #include "runtime/interfaceSupport.inline.hpp"
  #include "runtime/javaThread.hpp"
  #include "runtime/jniHandles.inline.hpp"
  #include "runtime/keepStackGCProcessed.hpp"
+ #include "runtime/lightweightSynchronizer.hpp"
+ #include "runtime/lockStack.inline.hpp"
  #include "runtime/objectMonitor.inline.hpp"
  #include "runtime/osThread.hpp"
  #include "runtime/safepointVerifiers.hpp"
  #include "runtime/sharedRuntime.hpp"
  #include "runtime/signature.hpp"

*** 1653,20 ***
                JvmtiDeferredUpdates::inc_relock_count_after_wait(deoptee_thread);
                continue;
              }
            }
          }
          if (LockingMode == LM_LIGHTWEIGHT) {
            // We have lost information about the correct state of the lock stack.
!           // Inflate the locks instead. Enter then inflate to avoid races with
!           // deflation.
!           ObjectSynchronizer::enter_for(obj, nullptr, deoptee_thread);
            assert(mon_info->owner()->is_locked(), "object must be locked now");
!           ObjectMonitor* mon = ObjectSynchronizer::inflate_for(deoptee_thread, obj(), ObjectSynchronizer::inflate_cause_vm_internal);
!           assert(mon->owner() == deoptee_thread, "must be");
          } else {
-           BasicLock* lock = mon_info->lock();
            ObjectSynchronizer::enter_for(obj, lock, deoptee_thread);
            assert(mon_info->owner()->is_locked(), "object must be locked now");
          }
        }
      }
--- 1655,25 ---
                JvmtiDeferredUpdates::inc_relock_count_after_wait(deoptee_thread);
                continue;
              }
            }
          }
+         BasicLock* lock = mon_info->lock();
          if (LockingMode == LM_LIGHTWEIGHT) {
            // We have lost information about the correct state of the lock stack.
!           // Entering may create an invalid lock stack. Inflate the lock if it
!           // was fast_locked to restore the valid lock stack.
!           ObjectSynchronizer::enter_for(obj, lock, deoptee_thread);
+           if (deoptee_thread->lock_stack().contains(obj())) {
+             LightweightSynchronizer::inflate_fast_locked_object(obj(), deoptee_thread, thread,
+                                                                 ObjectSynchronizer::InflateCause::inflate_cause_vm_internal);
+           }
            assert(mon_info->owner()->is_locked(), "object must be locked now");
!           assert(obj->mark().has_monitor(), "must be");
!           assert(!deoptee_thread->lock_stack().contains(obj()), "must be");
+           assert(LightweightSynchronizer::read_monitor(thread, obj())->owner() == deoptee_thread, "must be");
          } else {
            ObjectSynchronizer::enter_for(obj, lock, deoptee_thread);
            assert(mon_info->owner()->is_locked(), "object must be locked now");
          }
        }
      }
< prev index next >