Beispiel #1
0
 /**
  * Promotes a light-weight lock to a heavy-weight lock and locks it. Note: the object in question
  * will normally be locked by another thread, or it may be unlocked. If there is already a
  * heavy-weight lock on this object, that lock is returned.
  *
  * @param o the object to get a heavy-weight lock
  * @param lockOffset the offset of the thin lock word in the object.
  * @return whether the object was successfully locked
  */
 @Unpreemptible
 private static boolean inflateAndLock(Object o, Offset lockOffset) {
   Lock l = Lock.allocate();
   if (l == null) return false; // can't allocate locks during GC
   Lock rtn = attemptToInflate(o, lockOffset, l);
   if (l != rtn) {
     l = rtn;
     l.mutex.lock();
   }
   return l.lockHeavyLocked(o);
 }