use of org.vmmagic.pragma.Interruptible in project JikesRVM by JikesRVM.
the class JavaHeader method initializeScalarHeader.
/**
* Perform any required initialization of the JAVA portion of the header.
* @param bootImage The bootimage being written
* @param ptr 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 needsIdentityHash needs an identity hash value
* @param identityHashValue the value for the identity hash
* @return the address used for a reference to this object
*/
@Interruptible
public static Address initializeScalarHeader(BootImageInterface bootImage, Address ptr, TIB tib, int size, boolean needsIdentityHash, int identityHashValue) {
Address ref = ptr.plus(OBJECT_REF_OFFSET);
if (needsIdentityHash) {
bootImage.setFullWord(ref.plus(STATUS_OFFSET), HASH_STATE_HASHED_AND_MOVED.toInt());
if (DYNAMIC_HASH_OFFSET) {
// Read the size of this object.
RVMType t = tib.getType();
bootImage.setFullWord(ptr.plus(t.asClass().getInstanceSize()), identityHashValue);
} else {
ref = ref.plus(HASHCODE_BYTES);
bootImage.setFullWord(ref.plus(HASHCODE_OFFSET), (identityHashValue << 1) | ALIGNMENT_MASK);
}
} else {
// As boot image objects can't move there is no benefit in lazily setting them to hashed
bootImage.setFullWord(ref.plus(STATUS_OFFSET), HASH_STATE_HASHED.toInt());
}
return ref;
}
use of org.vmmagic.pragma.Interruptible in project JikesRVM by JikesRVM.
the class JavaHeader method initializeArrayHeader.
/**
* Perform any required initialization of the JAVA portion of the header.
*
* @param bootImage the bootimage being written
* @param ptr 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 numElements the number of elements in the array
* @param needsIdentityHash needs an identity hash value
* @param identityHashValue the value for the identity hash
* @return the address used for a reference to this object
*/
@Interruptible
public static Address initializeArrayHeader(BootImageInterface bootImage, Address ptr, TIB tib, int size, int numElements, boolean needsIdentityHash, int identityHashValue) {
Address ref = ptr.plus(OBJECT_REF_OFFSET);
// (TIB set by BootImageWriter; array length set by ObjectModel)
if (needsIdentityHash) {
bootImage.setFullWord(ref.plus(STATUS_OFFSET), HASH_STATE_HASHED_AND_MOVED.toInt());
if (DYNAMIC_HASH_OFFSET) {
// Read the size of this object.
RVMType t = tib.getType();
bootImage.setFullWord(ptr.plus(t.asArray().getInstanceSize(numElements)), identityHashValue);
} else {
ref = ref.plus(HASHCODE_BYTES);
bootImage.setFullWord(ref.plus(HASHCODE_OFFSET), (identityHashValue << 1) | ALIGNMENT_MASK);
}
} else {
// As boot image objects can't move there is no benefit in lazily setting them to hashed
bootImage.setFullWord(ref.plus(STATUS_OFFSET), HASH_STATE_HASHED.toInt());
}
return ref;
}
use of org.vmmagic.pragma.Interruptible in project JikesRVM by JikesRVM.
the class JavaHeader method installHashCode.
@NoInline
@Interruptible
protected static int installHashCode(Object o) {
Word hashCode;
do {
hashCodeGenerator = hashCodeGenerator.plus(Word.one().lsh(HASH_CODE_SHIFT));
hashCode = hashCodeGenerator.and(HASH_CODE_MASK);
} while (hashCode.isZero());
while (true) {
Word statusWord = Magic.prepareWord(o, STATUS_OFFSET);
if (!(statusWord.and(HASH_CODE_MASK).isZero())) {
// some other thread installed a hashcode
return statusWord.and(HASH_CODE_MASK).rshl(HASH_CODE_SHIFT).toInt();
}
if (Magic.attemptWord(o, STATUS_OFFSET, statusWord, statusWord.or(hashCode))) {
// we installed the hash code
return hashCode.rshl(HASH_CODE_SHIFT).toInt();
}
}
}
use of org.vmmagic.pragma.Interruptible in project JikesRVM by JikesRVM.
the class ObjectModel method allocateCode.
/**
* 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
* @return Address of object in bootimage
*/
@Interruptible
public static Address allocateCode(BootImageInterface bootImage, RVMArray array, int numElements) {
TIB tib = array.getTypeInformationBlock();
int size = array.getInstanceSize(numElements);
int align = getAlignment(array);
int offset = getOffsetForAlignment(array, false);
Address ptr = bootImage.allocateCodeStorage(size, align, offset);
Address ref = JavaHeader.initializeArrayHeader(bootImage, ptr, tib, size, numElements, false, 0);
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.pragma.Interruptible in project JikesRVM by JikesRVM.
the class MemoryManager method newNonMovingWordArray.
/**
* Allocates a non moving word array.
*
* @param size The size of the array
* @return the new non moving word array
*/
@NoInline
@Interruptible
public static WordArray newNonMovingWordArray(int size) {
if (!VM.runningVM) {
return WordArray.create(size);
}
RVMArray arrayType = RVMType.WordArrayType;
int headerSize = ObjectModel.computeArrayHeaderSize(arrayType);
int align = ObjectModel.getAlignment(arrayType);
int offset = ObjectModel.getOffsetForAlignment(arrayType, false);
int width = arrayType.getLogElementSize();
TIB arrayTib = arrayType.getTypeInformationBlock();
return (WordArray) allocateArray(size, width, headerSize, arrayTib, Plan.ALLOC_NON_MOVING, align, offset, Plan.DEFAULT_SITE);
}
Aggregations