if (VM.VerifyAssertions) VM.assert(VM_Thread.getCurrentThread().isGCThread);
if (VM.VerifyAssertions) VM._assert(VM_Thread.getCurrentThread().isGCThread);
  private static boolean inflateAndLock (Object o, int lockOffset) {    int old;    int changed;    VM_Lock l = VM_Lock.allocate();    if (l == null) return false; // can't allocate locks during GC    int locked = TL_FAT_LOCK_MASK | (l.index << TL_LOCK_ID_SHIFT);    l.mutex.lock();    do {      old = VM_Magic.prepare(o, lockOffset);      // check to see if another thread has already created a fat lock      if ((old & TL_FAT_LOCK_MASK) != 0) { // already a fat lock in place        VM_Lock.free(l);        l.mutex.unlock();        int index = (old & TL_LOCK_ID_MASK) >>> TL_LOCK_ID_SHIFT;        l = VM_Scheduler.locks[index];        l.mutex.lock();        if (l.lockedObject == o) break;  // l is heavy lock for o        l.mutex.unlock();        return false;      }      changed = locked | (old & TL_UNLOCK_MASK);      if (VM_Magic.attempt(o, lockOffset, old, changed)) {        l.lockedObject = o;        l.ownerId = old & TL_THREAD_ID_MASK;        if (l.ownerId != 0)           l.recursionCount = ((old & TL_LOCK_COUNT_MASK) >> TL_LOCK_COUNT_SHIFT) +1;        break;  // l is heavy lock for o      }       // contention detected, try again    } while (true);    if (l.ownerId == 0) {      l.ownerId = VM_Magic.getThreadId();      l.recursionCount = 1;    } else if (l.ownerId == VM_Magic.getThreadId()) {      l.recursionCount++;    } else if (VM_Processor.getCurrentProcessor().threadSwitchingEnabled()) {      VM_Thread.yield(l.entering, l.mutex); // thread-switching benign      // when this thread next gets scheduled, it will be entitled to the lock,      // but another thread might grab it first.      return false; // caller will try again    } else { // can't yield - must spin and let caller retry      // potential deadlock if user thread is contending for a lock with thread switching disabled      if (VM.VerifyAssertions) VM.assert(VM_Thread.getCurrentThread().isGCThread);      l.mutex.unlock(); // thread-switching benign      return false; // caller will try again    }    l.mutex.unlock(); // thread-switching benign    return true;  }