if (!memoryResource.acquire(Conversions.bytesToBlocks(bytes))) { LOSunlock();
if (!memoryResource.acquire(Conversions.bytesToBlocks(bytes)))
  protected VM_Address alloc (boolean isScalar, int size) {    if (VM.VerifyAssertions) VM._assert(allocated != null);    // Cycle through twice to make sure we covered everything    // This is  bit wasteful...    //    for (int count=0; count < 2 ; count++) {      LOSlock();      int num_pages = (size + (pageSize - 1)) / pageSize;    // Number of pages needed      int bytes = num_pages * pageSize;      if (!memoryResource.acquire(Conversions.bytesToBlocks(bytes))) {	LOSunlock();	return VM_Address.zero();      }      int last_possible = totalPages - num_pages;      while (allocated[lastAllocated] != 0) 	lastAllocated += allocated[lastAllocated];      int first_free = lastAllocated;      while (first_free <= last_possible) {	// Now find contiguous pages for this object	// first find the first available page	// i points to an available page: remember it	int i;	for (i = first_free + 1; i < first_free + num_pages ; i++) {	  if (allocated[i] != 0) break;	}	if (i == (first_free + num_pages )) {  	  // successful: found num_pages contiguous pages	  // mark the newly allocated pages	  // mark the beginning of the range with num_pages	  // mark the end of the range with -num_pages	  // so that when marking (ref is input) will know which extreme 	  // of the range the ref identifies, and then can find the other	  	  VM_Address result = start.add(pageSize * first_free);	  VM_Address resultEnd = result.add(size);	  if (resultEnd.GT(cursor)) {	    int neededBytes = resultEnd.diff(cursor).toInt();	    int blocks = Conversions.bytesToBlocks(neededBytes);	    VM_Address newArea = acquire(blocks);	    if (newArea.isZero()) {	      LOSunlock();	      return VM_Address.zero();	    }	  }	  if (VM.VerifyAssertions) VM._assert(resultEnd.LE(cursor));	  allocated[first_free + num_pages - 1] = (short)(-num_pages);	  allocated[first_free] = (short)(num_pages);	  pagesAllocated += num_pages;	  LOSunlock();	  Memory.zero(result, resultEnd);	  return result;	} else {  	  // free area did not contain enough contig. pages	  first_free = i + allocated[i]; 	  while (allocated[first_free] != 0) 	    first_free += allocated[first_free];	}      }      LOSunlock();    } // for     VM_Interface.getPlan().poll(true);    return VM_Address.zero();  }