Search in sources :

Example 21 with Inline

use of org.vmmagic.pragma.Inline in project JikesRVM by JikesRVM.

the class Barriers method offsetFieldWrite.

/**
 * Barrier for writes of Offsets into fields of instances (i.e. putfield).
 *
 * @param ref the object which is the subject of the putfield
 * @param value the new value for the field
 * @param offset the offset of the field to be modified
 * @param locationMetadata an int that encodes the source location being modified
 */
@Inline
@Entrypoint
public static void offsetFieldWrite(Object ref, Offset value, Offset offset, int locationMetadata) {
    if (NEEDS_OFFSET_GC_WRITE_BARRIER) {
        ObjectReference src = ObjectReference.fromObject(ref);
        Selected.Mutator.get().offsetWrite(src, src.toAddress().plus(offset), value, offset.toWord(), Word.fromIntZeroExtend(locationMetadata), INSTANCE_FIELD);
    } else if (VM.VerifyAssertions)
        VM._assert(VM.NOT_REACHED);
}
Also used : ObjectReference(org.vmmagic.unboxed.ObjectReference) Entrypoint(org.vmmagic.pragma.Entrypoint) Inline(org.vmmagic.pragma.Inline)

Example 22 with Inline

use of org.vmmagic.pragma.Inline in project JikesRVM by JikesRVM.

the class MemoryManager method allocateArrayInternal.

/**
 * Allocate an array object.
 *
 * @param numElements The number of element bytes
 * @param size size in bytes of array header
 * @param tib type information block for array object
 * @param allocator int that encodes which allocator should be used
 * @param align the alignment requested; must be a power of 2.
 * @param offset the offset at which the alignment is desired.
 * @param site allocation site.
 * @return array object with header installed and all elements set
 *         to zero/{@code null}
 * See also: bytecode 0xbc ("newarray") and 0xbd ("anewarray")
 */
@Inline
private static Object allocateArrayInternal(int numElements, int size, TIB tib, int allocator, int align, int offset, int site) {
    Selected.Mutator mutator = Selected.Mutator.get();
    allocator = mutator.checkAllocator(org.jikesrvm.runtime.Memory.alignUp(size, MIN_ALIGNMENT), align, allocator);
    Address region = allocateSpace(mutator, size, align, offset, allocator, site);
    Object result = ObjectModel.initializeArray(region, tib, numElements, size);
    mutator.postAlloc(ObjectReference.fromObject(result), ObjectReference.fromObject(tib), size, allocator);
    return result;
}
Also used : Address(org.vmmagic.unboxed.Address) Inline(org.vmmagic.pragma.Inline) NoInline(org.vmmagic.pragma.NoInline)

Example 23 with Inline

use of org.vmmagic.pragma.Inline in project JikesRVM by JikesRVM.

the class JavaHeader method moveObject.

/**
 * Copies an object to the given raw storage address.
 *
 * @param toObj the target object. If this is non-{@code null}, the target
 *  address must be {@code Address.zero()}.
 * @param toAddress the target address. If this is not {@code Address.zero()},
 *  the target object must be {@code null}.
 * @param fromObj the object to copy from
 * @param numBytes the number of bytes to copy
 * @return the reference of the object's copy
 */
@Inline
public static Object moveObject(Address toAddress, Object fromObj, Object toObj, int numBytes) {
    if (VM.VerifyAssertions)
        VM._assert(toAddress.isZero() || toObj == null);
    // Default values
    int copyBytes = numBytes;
    int objRefOffset = OBJECT_REF_OFFSET;
    Word statusWord = Word.zero();
    Word hashState = HASH_STATE_UNHASHED;
    if (ADDRESS_BASED_HASHING) {
        // Read the hash state (used below)
        statusWord = Magic.getWordAtOffset(fromObj, STATUS_OFFSET);
        hashState = statusWord.and(HASH_STATE_MASK);
        if (hashState.EQ(HASH_STATE_HASHED)) {
            // We do not copy the hashcode, but we do allocate it
            copyBytes -= HASHCODE_BYTES;
            if (!DYNAMIC_HASH_OFFSET) {
                // The hashcode is the first word, so we copy to object one word higher
                if (toObj == null) {
                    toAddress = toAddress.plus(HASHCODE_BYTES);
                }
            }
        } else if (!DYNAMIC_HASH_OFFSET && hashState.EQ(HASH_STATE_HASHED_AND_MOVED)) {
            // Simple operation (no hash state change), but one word larger header
            objRefOffset += HASHCODE_BYTES;
        }
    }
    if (toObj != null) {
        toAddress = Magic.objectAsAddress(toObj).minus(objRefOffset);
    }
    // Low memory word of source object
    Address fromAddress = Magic.objectAsAddress(fromObj).minus(objRefOffset);
    // Do the copy
    Memory.aligned32Copy(toAddress, fromAddress, copyBytes);
    if (toObj == null) {
        toObj = Magic.addressAsObject(toAddress.plus(objRefOffset));
    } else {
        if (VM.VerifyAssertions)
            VM._assert(toObj == Magic.addressAsObject(toAddress.plus(objRefOffset)));
    }
    // Do we need to copy the hash code?
    if (hashState.EQ(HASH_STATE_HASHED)) {
        int hashCode = Magic.objectAsAddress(fromObj).toWord().rshl(LOG_BYTES_IN_ADDRESS).toInt();
        if (DYNAMIC_HASH_OFFSET) {
            Magic.setIntAtOffset(toObj, Offset.fromIntSignExtend(numBytes - OBJECT_REF_OFFSET - HASHCODE_BYTES), hashCode);
        } else {
            Magic.setIntAtOffset(toObj, HASHCODE_OFFSET, (hashCode << 1) | ALIGNMENT_MASK);
        }
        Magic.setWordAtOffset(toObj, STATUS_OFFSET, statusWord.or(HASH_STATE_HASHED_AND_MOVED));
        if (ObjectModel.HASH_STATS)
            ObjectModel.hashTransition2++;
    }
    return toObj;
}
Also used : Word(org.vmmagic.unboxed.Word) Address(org.vmmagic.unboxed.Address) Inline(org.vmmagic.pragma.Inline) NoInline(org.vmmagic.pragma.NoInline)

Example 24 with Inline

use of org.vmmagic.pragma.Inline in project JikesRVM by JikesRVM.

the class JavaHeader method getReferenceWhenCopiedTo.

@Inline
protected static Object getReferenceWhenCopiedTo(Object obj, Address to) {
    if (ADDRESS_BASED_HASHING && !DYNAMIC_HASH_OFFSET) {
        // Read the hash state (used below)
        Word statusWord = Magic.getWordAtOffset(obj, STATUS_OFFSET);
        Word hashState = statusWord.and(HASH_STATE_MASK);
        if (hashState.NE(HASH_STATE_UNHASHED)) {
            to = to.plus(HASHCODE_BYTES);
        }
    }
    return Magic.addressAsObject(to.plus(OBJECT_REF_OFFSET));
}
Also used : Word(org.vmmagic.unboxed.Word) Inline(org.vmmagic.pragma.Inline) NoInline(org.vmmagic.pragma.NoInline)

Example 25 with Inline

use of org.vmmagic.pragma.Inline in project JikesRVM by JikesRVM.

the class MemoryManager method allocateArray.

/**
 * Allocate an array object. This is the interruptible component, including throwing
 * an OutOfMemoryError for arrays that are too large.
 *
 * @param numElements number of array elements
 * @param logElementSize size in bytes of an array element, log base 2.
 * @param headerSize size in bytes of array header
 * @param tib type information block for array object
 * @param allocator int that encodes which allocator should be used
 * @param align the alignment requested; must be a power of 2.
 * @param offset the offset at which the alignment is desired.
 * @param site allocation site.
 * @return array object with header installed and all elements set
 *         to zero/null
 * See also: bytecode 0xbc ("newarray") and 0xbd ("anewarray")
 */
@Inline
@Unpreemptible
public static Object allocateArray(int numElements, int logElementSize, int headerSize, TIB tib, int allocator, int align, int offset, int site) {
    int elemBytes = numElements << logElementSize;
    if (elemBytes < 0 || (elemBytes >>> logElementSize) != numElements) {
        /* asked to allocate more than Integer.MAX_VALUE bytes */
        throwLargeArrayOutOfMemoryError();
    }
    int size = elemBytes + headerSize;
    return allocateArrayInternal(numElements, size, tib, allocator, align, offset, site);
}
Also used : Entrypoint(org.vmmagic.pragma.Entrypoint) Unpreemptible(org.vmmagic.pragma.Unpreemptible) Inline(org.vmmagic.pragma.Inline) NoInline(org.vmmagic.pragma.NoInline)

Aggregations

Inline (org.vmmagic.pragma.Inline)110 NoInline (org.vmmagic.pragma.NoInline)42 Entrypoint (org.vmmagic.pragma.Entrypoint)40 Offset (org.vmmagic.unboxed.Offset)38 ObjectReference (org.vmmagic.unboxed.ObjectReference)35 Address (org.vmmagic.unboxed.Address)15 Word (org.vmmagic.unboxed.Word)15 TypeReference (org.jikesrvm.classloader.TypeReference)12 Uninterruptible (org.vmmagic.pragma.Uninterruptible)6 RVMType (org.jikesrvm.classloader.RVMType)5 RVMClass (org.jikesrvm.classloader.RVMClass)4 Unpreemptible (org.vmmagic.pragma.Unpreemptible)4 RVMClassLoader (org.jikesrvm.classloader.RVMClassLoader)3 TIB (org.jikesrvm.objectmodel.TIB)3 Extent (org.vmmagic.unboxed.Extent)3 MethodReference (org.jikesrvm.classloader.MethodReference)2 ForwardReference (org.jikesrvm.compilers.common.assembler.ForwardReference)2 RVMThread (org.jikesrvm.scheduler.RVMThread)2 CollectorContext (org.mmtk.plan.CollectorContext)2 NoNullCheck (org.vmmagic.pragma.NoNullCheck)2