int changed = old - TL_LOCK_COUNT_UNIT; if (VM_Magic.attemptInt(o, lockOffset, old, changed)) {
VM_Word changed = old.toAddress().sub(TL_LOCK_COUNT_UNIT).toWord(); if (VM_Magic.attemptWord(o, lockOffset, old, changed)) {
  static void unlock(Object o, int lockOffset) throws VM_PragmaNoInline {    VM_Magic.sync(); // prevents stale data from being seen by next owner of the lock    while (true) { // spurious contention detected      int old = VM_Magic.prepareInt(o, lockOffset);      int id  = old & (TL_THREAD_ID_MASK | TL_FAT_LOCK_MASK);      int threadId = VM_Processor.getCurrentProcessor().threadId;      if (id != threadId) { // not normal case        if ((old & TL_FAT_LOCK_MASK) != 0) { // o has a heavy lock          int index = (old & TL_LOCK_ID_MASK) >>> TL_LOCK_ID_SHIFT;          VM_Scheduler.locks[index].unlockHeavy(o);           // note that unlockHeavy has issued a sync          return;        }         VM_Scheduler.trace("VM_Lock", "unlock error: thin lock word = ", old);        VM_Scheduler.trace("VM_Lock", "unlock error: thin lock word = ", VM_Magic.objectAsAddress(o));        // VM_Scheduler.trace("VM_Lock", VM_Thread.getCurrentThread().toString(), 0);        VM_Lock.raiseIllegalMonitorStateException("thin unlocking", o);      }      int countbits = old & TL_LOCK_COUNT_MASK; // get count      if (countbits == 0) { // this is the last lock        int changed = old & TL_UNLOCK_MASK;        if (VM_Magic.attemptInt(o, lockOffset, old, changed)) {          return; // unlock succeeds        }         continue;      }      // more than one lock      // decrement recursion count      int changed = old - TL_LOCK_COUNT_UNIT;       if (VM_Magic.attemptInt(o, lockOffset, old, changed)) {        return; // unlock succeeds      }    }  }