Search in sources :

Example 31 with Address

use of org.vmmagic.unboxed.Address in project JikesRVM by JikesRVM.

the class MiscHeader method initializeHeader.

/**
 * Perform any required initialization of the MISC portion of the header.
 * @param obj the object ref to the storage to be initialized
 * @param tib the TIB of the instance being created
 * @param size the number of bytes allocated by the GC system for this object.
 * @param isScalar are we initializing a scalar (true) or array (false) object?
 */
@Uninterruptible
public static void initializeHeader(Object obj, TIB tib, int size, boolean isScalar) {
    /* Only perform initialization when it is required */
    if (GENERATE_GC_TRACE) {
        Address ref = Magic.objectAsAddress(obj);
        ref.store(oid, OBJECT_OID_OFFSET);
        ref.store(time, OBJECT_DEATH_OFFSET);
        oid = oid.plus(Word.fromIntSignExtend((size - GC_TRACING_HEADER_BYTES) >> LOG_BYTES_IN_ADDRESS));
    }
}
Also used : Address(org.vmmagic.unboxed.Address) Uninterruptible(org.vmmagic.pragma.Uninterruptible)

Example 32 with Address

use of org.vmmagic.unboxed.Address in project JikesRVM by JikesRVM.

the class ObjectModel method allocateScalar.

/**
 * Allocate and initialize space in the bootimage (at bootimage writing time)
 * to be an uninitialized instance of the (scalar) type specified by klass.
 * NOTE: TIB is set by BootImageWriter2
 *
 * @param bootImage the bootimage to put the object in
 * @param klass the RVMClass object of the instance to create.
 * @param needsIdentityHash needs an identity hash value
 * @param identityHashValue the value for the identity hash
 * @return the offset of object in bootimage (in bytes)
 */
@Interruptible
public static Address allocateScalar(BootImageInterface bootImage, RVMClass klass, boolean needsIdentityHash, int identityHashValue) {
    TIB tib = klass.getTypeInformationBlock();
    int size = klass.getInstanceSize();
    if (needsIdentityHash) {
        if (ADDRESS_BASED_HASHING) {
            size += HASHCODE_BYTES;
        } else {
            // that don't support an extra word for the hash code
            throw new Error("Unsupported allocation");
        }
    }
    int align = getAlignment(klass);
    int offset = getOffsetForAlignment(klass, needsIdentityHash);
    Address ptr = bootImage.allocateDataStorage(size, align, offset);
    Address ref = JavaHeader.initializeScalarHeader(bootImage, ptr, tib, size, needsIdentityHash, identityHashValue);
    MemoryManager.initializeHeader(bootImage, ref, tib, size, true);
    MiscHeader.initializeHeader(bootImage, ref, tib, size, true);
    return ref;
}
Also used : Address(org.vmmagic.unboxed.Address) Entrypoint(org.vmmagic.pragma.Entrypoint) Interruptible(org.vmmagic.pragma.Interruptible)

Example 33 with Address

use of org.vmmagic.unboxed.Address in project JikesRVM by JikesRVM.

the class ObjectModel method allocateArray.

/**
 * Allocate and initialize space in the bootimage (at bootimage writing time)
 * to be an uninitialized instance of the (array) type specified by array.
 * NOTE: TIB is set by BootimageWriter2
 *
 * @param bootImage the bootimage to put the object in
 * @param array RVMArray object of array being allocated.
 * @param numElements number of elements
 * @param needsIdentityHash needs an identity hash value
 * @param identityHashValue the value for the identity hash
 * @param align special alignment value
 * @param alignCode the alignment-encoded value
 * @return Address of object in bootimage (in bytes)
 */
@Interruptible
public static Address allocateArray(BootImageInterface bootImage, RVMArray array, int numElements, boolean needsIdentityHash, int identityHashValue, int align, int alignCode) {
    TIB tib = array.getTypeInformationBlock();
    int size = array.getInstanceSize(numElements);
    if (needsIdentityHash) {
        if (ADDRESS_BASED_HASHING) {
            size += HASHCODE_BYTES;
        } else {
            // that don't support an extra word for the hash code
            throw new Error("Unsupported allocation");
        }
    }
    int offset = getOffsetForAlignment(array, needsIdentityHash);
    int padding = AlignmentEncoding.padding(alignCode);
    Address ptr = bootImage.allocateDataStorage(size + padding, align, offset);
    ptr = AlignmentEncoding.adjustRegion(alignCode, ptr);
    Address ref = JavaHeader.initializeArrayHeader(bootImage, ptr, tib, size, numElements, needsIdentityHash, identityHashValue);
    bootImage.setFullWord(ref.plus(getArrayLengthOffset()), numElements);
    MemoryManager.initializeHeader(bootImage, ref, tib, size, false);
    MiscHeader.initializeHeader(bootImage, ref, tib, size, false);
    return ref;
}
Also used : Address(org.vmmagic.unboxed.Address) Entrypoint(org.vmmagic.pragma.Entrypoint) Interruptible(org.vmmagic.pragma.Interruptible)

Example 34 with Address

use of org.vmmagic.unboxed.Address in project JikesRVM by JikesRVM.

the class TIB method isInternalLazyCompilationTrampoline.

/**
 * @param virtualMethodIndex the index of the virtual method
 * @return whether a virtual method is the internal lazy compilation trampoline
 */
@NoInline
public boolean isInternalLazyCompilationTrampoline(int virtualMethodIndex) {
    int index = TIB_FIRST_VIRTUAL_METHOD_INDEX + virtualMethodIndex;
    Address tibAddress = Magic.objectAsAddress(this);
    Address callAddress = tibAddress.loadAddress(Offset.fromIntZeroExtend(index << LOG_BYTES_IN_ADDRESS));
    Address maxAddress = tibAddress.plus(Offset.fromIntZeroExtend(length() << LOG_BYTES_IN_ADDRESS));
    return callAddress.GE(tibAddress) && callAddress.LT(maxAddress);
}
Also used : Address(org.vmmagic.unboxed.Address) NoInline(org.vmmagic.pragma.NoInline)

Example 35 with Address

use of org.vmmagic.unboxed.Address in project JikesRVM by JikesRVM.

the class TIB method setVirtualMethod.

/**
 * Set a virtual method in this TIB.
 *
 * When running the VM, we must translate requests to use the internal
 * lazy compilation trampoline.
 *
 * @param virtualMethodIndex the index of the virtual metho
 * @param code the code for the virtual method
 */
@NoInline
public void setVirtualMethod(int virtualMethodIndex, CodeArray code) {
    if (VM.VerifyAssertions)
        VM._assert(virtualMethodIndex >= 0);
    if (VM.runningVM && code == LazyCompilationTrampoline.getInstructions()) {
        Address tibAddress = Magic.objectAsAddress(this);
        Address callAddress = tibAddress.plus(Offset.fromIntZeroExtend(lazyMethodInvokerTrampolineIndex() << LOG_BYTES_IN_ADDRESS));
        set(TIB_FIRST_VIRTUAL_METHOD_INDEX + virtualMethodIndex, callAddress);
    } else {
        set(TIB_FIRST_VIRTUAL_METHOD_INDEX + virtualMethodIndex, code);
    }
}
Also used : Address(org.vmmagic.unboxed.Address) NoInline(org.vmmagic.pragma.NoInline)

Aggregations

Address (org.vmmagic.unboxed.Address)281 Offset (org.vmmagic.unboxed.Offset)48 CompiledMethod (org.jikesrvm.compilers.common.CompiledMethod)30 NoInline (org.vmmagic.pragma.NoInline)30 Test (org.junit.Test)24 Entrypoint (org.vmmagic.pragma.Entrypoint)22 TypeReference (org.jikesrvm.classloader.TypeReference)21 OptCompiledMethod (org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod)17 RVMType (org.jikesrvm.classloader.RVMType)16 Inline (org.vmmagic.pragma.Inline)15 Uninterruptible (org.vmmagic.pragma.Uninterruptible)14 Word (org.vmmagic.unboxed.Word)14 BaseMMTkTest (org.mmtk.harness.tests.BaseMMTkTest)13 Unpreemptible (org.vmmagic.pragma.Unpreemptible)12 ObjectReference (org.vmmagic.unboxed.ObjectReference)12 Interruptible (org.vmmagic.pragma.Interruptible)11 Extent (org.vmmagic.unboxed.Extent)11 RVMClass (org.jikesrvm.classloader.RVMClass)9 AddressConstantOperand (org.jikesrvm.compilers.opt.ir.operand.AddressConstantOperand)8 IntConstantOperand (org.jikesrvm.compilers.opt.ir.operand.IntConstantOperand)8