Search in sources :

Example 21 with Extent

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);
}
Also used : Address(org.vmmagic.unboxed.Address) Extent(org.vmmagic.unboxed.Extent)

Aggregations

Extent (org.vmmagic.unboxed.Extent)21 Address (org.vmmagic.unboxed.Address)11 Inline (org.vmmagic.pragma.Inline)3 Offset (org.vmmagic.unboxed.Offset)3 Test (org.junit.Test)2 BaseMMTkTest (org.mmtk.harness.tests.BaseMMTkTest)2 RawMemoryFreeList (org.mmtk.utility.RawMemoryFreeList)2 Interruptible (org.vmmagic.pragma.Interruptible)2 Word (org.vmmagic.unboxed.Word)2 Field (java.lang.reflect.Field)1 RVMField (org.jikesrvm.classloader.RVMField)1 RVMType (org.jikesrvm.classloader.RVMType)1 TypeReference (org.jikesrvm.classloader.TypeReference)1 AddressConstantOperand (org.jikesrvm.compilers.opt.ir.operand.AddressConstantOperand)1 DoubleConstantOperand (org.jikesrvm.compilers.opt.ir.operand.DoubleConstantOperand)1 FloatConstantOperand (org.jikesrvm.compilers.opt.ir.operand.FloatConstantOperand)1 IntConstantOperand (org.jikesrvm.compilers.opt.ir.operand.IntConstantOperand)1 LongConstantOperand (org.jikesrvm.compilers.opt.ir.operand.LongConstantOperand)1 NullConstantOperand (org.jikesrvm.compilers.opt.ir.operand.NullConstantOperand)1 ObjectConstantOperand (org.jikesrvm.compilers.opt.ir.operand.ObjectConstantOperand)1