/** * 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); }
/** * Promotes a light-weight lock to a heavy-weight lock. Note: the object is 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 the heavy-weight lock on this object */ @Unpreemptible private static Lock inflate(Object o, Offset lockOffset) { Lock l = Lock.allocate(); if (VM.VerifyAssertions) { VM._assert( l != null); // inflate called by wait (or notify) which shouldn't be called during GC } Lock rtn = attemptToInflate(o, lockOffset, l); if (rtn == l) l.mutex.unlock(); return rtn; }