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));
}
}
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;
}
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;
}
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);
}
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);
}
}
Aggregations