< prev index next >

src/hotspot/share/interpreter/interpreterRuntime.cpp

Print this page
*** 722,10 ***
--- 722,11 ---
  // be shared by method invocation and synchronized blocks.
  //%note synchronization_3
  
  //%note monitor_1
  JRT_ENTRY_NO_ASYNC(void, InterpreterRuntime::monitorenter(JavaThread* current, BasicObjectLock* elem))
+   assert(LockingMode != LM_LIGHTWEIGHT, "Should call monitorenter_obj() when using the new lightweight locking");
  #ifdef ASSERT
    current->last_frame().interpreter_frame_verify_monitor(elem);
  #endif
    if (PrintBiasedLockingStatistics) {
      Atomic::inc(BiasedLocking::slow_path_entry_count_addr());

*** 739,10 ***
--- 740,26 ---
  #ifdef ASSERT
    current->last_frame().interpreter_frame_verify_monitor(elem);
  #endif
  JRT_END
  
+ // NOTE: We provide a separate implementation for the new lightweight locking to workaround a limitation
+ // of registers in x86_32. This entry point accepts an oop instead of a BasicObjectLock*.
+ // The problem is that we would need to preserve the register that holds the BasicObjectLock,
+ // but we are using that register to hold the thread. We don't have enough registers to
+ // also keep the BasicObjectLock, but we don't really need it anyway, we only need
+ // the object. See also InterpreterMacroAssembler::lock_object().
+ // As soon as legacy stack-locking goes away we could remove the other monitorenter() entry
+ // point, and only use oop-accepting entries (same for monitorexit() below).
+ JRT_ENTRY_NO_ASYNC(void, InterpreterRuntime::monitorenter_obj(JavaThread* current, oopDesc* obj))
+   assert(LockingMode == LM_LIGHTWEIGHT, "Should call monitorenter() when not using the new lightweight locking");
+   Handle h_obj(current, cast_to_oop(obj));
+   assert(Universe::heap()->is_in_or_null(h_obj()),
+          "must be null or an object");
+   ObjectSynchronizer::enter(h_obj, NULL, current);
+   return;
+ JRT_END
  
  JRT_LEAF(void, InterpreterRuntime::monitorexit(BasicObjectLock* elem))
    oop obj = elem->obj();
    assert(Universe::heap()->is_in(obj), "must be an object");
    // The object could become unlocked through a JNI call, which we have no other checks for.
< prev index next >