Unsafe.debug("Start end: ");
Unsafe.debug(startPtr);
Unsafe.debug(endPtr);
Unsafe.debug('\n');
final Extent size = endPtr.toWord().sub(startPtr.toWord()).toExtent();
Unsafe.debug("Size : ");
Unsafe.debug(size);
Unsafe.debug('\n');
blockCount = size.toWord().rshl(BLOCK_SIZE_SHIFT);
// Create a lock (4 bytes) and usage bitmap at the front of the memory
// region
final Extent rawBitmapSize = blockCount.rshl(3).toExtent();
// final long rawBitmapSize = blockCount;
final Extent bitmapSize = blockAlign(rawBitmapSize.toWord().add(4), true).toExtent();
if (false) {
Unsafe.debug("startPtr:");
Unsafe.debug(startPtr);
}
lockPtr = startPtr;
if (DBG) {
Unsafe.debug("lockPtr:");
Unsafe.debug(lockPtr);
Unsafe.debug("bitmapSize:");
Unsafe.debug(bitmapSize);
}
bitmapPtr = startPtr.add(4);
// Clear the lock & bitmap size
clear(lockPtr, bitmapSize);
// Now shift the startptr.
startPtr = startPtr.add(bitmapSize);
blockCount = blockCount.sub(bitmapSize.toWord().rshl(BLOCK_SIZE_SHIFT));
allocatedBlocks = Word.zero();
// Mark as initialized
initialized = true;
// Unsafe.debug("BitmapPtr ");