use of org.vmmagic.unboxed.Extent in project JikesRVM by JikesRVM.
the class BumpPointer method allocSlowOnce.
/**
* External allocation slow path (called by superclass when slow path is
* actually taken. This is necessary (rather than a direct call
* from the fast path) because of the possibility of a thread switch
* and corresponding re-association of bump pointers to kernel
* threads.
*
* @param bytes The number of bytes allocated
* @param offset The offset from the alignment
* @param align The requested alignment
* @return The address of the first byte of the allocated region or
* zero on failure
*/
@Override
protected final Address allocSlowOnce(int bytes, int align, int offset) {
/* Check we have been bound to a space */
if (space == null) {
VM.assertions.fail("Allocation on unbound bump pointer.");
}
/* Check if we already have a block to use */
if (allowScanning && !region.isZero()) {
Address nextRegion = getNextRegion(region);
if (!nextRegion.isZero()) {
return consumeNextRegion(nextRegion, bytes, align, offset);
}
}
/* Acquire space, block aligned, that can accommodate the request */
Extent blockSize = Word.fromIntZeroExtend(bytes).plus(BLOCK_MASK).and(BLOCK_MASK.not()).toExtent();
Address start = space.acquire(Conversions.bytesToPages(blockSize));
// failed allocation
if (start.isZero())
return start;
if (!allowScanning) {
// discontiguous
if (start.NE(limit))
cursor = start;
updateLimit(start.plus(blockSize), start, bytes);
} else
// scannable allocator
updateMetaData(start, blockSize, bytes);
return alloc(bytes, align, offset);
}
Aggregations