int latestContenderOffset = VM_Entrypoints.latestContenderField.getOffset();
Offset latestContenderOffset = VM_Entrypoints.latestContenderField.getOffset();
  public void lock () {    if (VM.BuildForSingleVirtualProcessor) return;    VM_Processor i = VM_Processor.getCurrentProcessor();    if (VM.VerifyAssertions) i.lockCount += 1;    VM_Processor p;    int attempts = 0;    int retries = 0;    int latestContenderOffset = VM_Entrypoints.latestContenderField.getOffset();    do {      p = VM_Magic.objectAsProcessor(VM_Magic.addressAsObject(VM_Magic.prepareAddress(this, latestContenderOffset)));      if (p == null) { // nobody owns the lock        if (VM_Magic.attemptAddress(this, latestContenderOffset, Address.zero(), VM_Magic.objectAsAddress(i))) {          VM_Magic.isync(); // so subsequent instructions wont see stale values          return;         } else {          continue; // don't handle contention        }      } else if (MCS_Locking && VM_Magic.objectAsAddress(p).NE(IN_FLUX)) { // lock is owned, but not being changed        if (VM_Magic.attemptAddress(this, latestContenderOffset, VM_Magic.objectAsAddress(p), IN_FLUX)) {          VM_Magic.isync(); // so subsequent instructions wont see stale values          break;         }      }      handleMicrocontention(attempts++);    } while (true);    // i owns the lock    if (VM.VerifyAssertions && !MCS_Locking) VM._assert(VM.NOT_REACHED);    i.awaitingProcessorLock = this;    if (p.awaitingProcessorLock != this) { // make i first (and only) waiter on the contender chain      i.contenderLink = i;    } else {                               // make i last waiter on the contender chain      i.contenderLink = p.contenderLink;      p.contenderLink = i;    }    VM_Magic.sync(); // so other contender will see updated contender chain    VM_Magic.setObjectAtOffset(this, latestContenderOffset, i);  // other processors can get at the lock    do { // spin, waiting for the lock      VM_Magic.isync(); // to make new value visible as soon as possible    } while (i.awaitingProcessorLock == this);  }