use of org.vmmagic.pragma.Interruptible in project JikesRVM by JikesRVM.
the class VM method runClassInitializer.
/**
* Run {@code <clinit>} method of specified class, if that class appears
* in bootimage and actually has a clinit method (we are flexible to
* allow one list of classes to work with different bootimages and
* different version of classpath (eg 0.05 vs. cvs head).
* <p>
* This method is called only while the VM boots.
*
* @param className class whose initializer needs to be run
*/
@Interruptible
static void runClassInitializer(String className) {
if (verboseBoot >= 2) {
sysWrite("running class initializer for ");
sysWriteln(className);
}
Atom classDescriptor = Atom.findOrCreateAsciiAtom(className.replace('.', '/')).descriptorFromClassName();
TypeReference tRef = TypeReference.findOrCreate(BootstrapClassLoader.getBootstrapClassLoader(), classDescriptor);
RVMClass cls = (RVMClass) tRef.peekType();
if (null == cls) {
sysWrite("Failed to run class initializer for ");
sysWrite(className);
sysWriteln(" as the class does not exist.");
} else if (!cls.isInBootImage()) {
sysWrite("Failed to run class initializer for ");
sysWrite(className);
sysWriteln(" as the class is not in the boot image.");
} else {
RVMMethod clinit = cls.getClassInitializerMethod();
if (clinit != null) {
clinit.compile();
if (verboseBoot >= 10)
VM.sysWriteln("invoking method " + clinit);
try {
Magic.invokeClassInitializer(clinit.getCurrentEntryCodeArray());
} catch (Error e) {
throw e;
} catch (Throwable t) {
ExceptionInInitializerError eieio = new ExceptionInInitializerError(t);
throw eieio;
}
// <clinit> is no longer needed: reclaim space by removing references to it
clinit.invalidateCompiledMethod(clinit.getCurrentCompiledMethod());
} else {
if (verboseBoot >= 10)
VM.sysWriteln("has no clinit method ");
}
cls.setAllFinalStaticJTOCEntries();
}
}
use of org.vmmagic.pragma.Interruptible in project JikesRVM by JikesRVM.
the class VM method init.
// ----------------//
// implementation //
// ----------------//
/**
* Create class instances needed for boot image or initialize classes
* needed by tools.
* @param bootstrapClasspath places where VM implementation class reside
* @param bootCompilerArgs command line arguments to pass along to the
* boot compiler's init routine.
*/
@Interruptible
private static void init(String bootstrapClasspath, String[] bootCompilerArgs) {
if (VM.VerifyAssertions)
VM._assert(!VM.runningVM);
// create dummy boot record
//
BootRecord.the_boot_record = new BootRecord();
// initialize type subsystem and classloader
RVMClassLoader.init(bootstrapClasspath);
//
if (writingBootImage) {
// initialize compiler that builds boot image
BootImageCompiler.init(bootCompilerArgs);
}
RuntimeEntrypoints.init();
RVMThread.init();
}
use of org.vmmagic.pragma.Interruptible in project JikesRVM by JikesRVM.
the class MemoryManager method newRuntimeTable.
/**
* Allocates a new runtime table (at runtime).
*
* @param size The size of the table
* @param type the type for the table
* @return the newly allocated table
*/
@NoInline
@Interruptible
public static Object newRuntimeTable(int size, RVMType type) {
if (VM.VerifyAssertions)
VM._assert(VM.runningVM);
TIB realTib = type.getTypeInformationBlock();
RVMArray fakeType = RVMType.WordArrayType;
TIB fakeTib = fakeType.getTypeInformationBlock();
int headerSize = ObjectModel.computeArrayHeaderSize(fakeType);
int align = ObjectModel.getAlignment(fakeType);
int offset = ObjectModel.getOffsetForAlignment(fakeType, false);
int width = fakeType.getLogElementSize();
/* Allocate a word array */
Object array = allocateArray(size, width, headerSize, fakeTib, type.getMMAllocator(), align, offset, Plan.DEFAULT_SITE);
/* Now we replace the TIB */
ObjectModel.setTIB(array, realTib);
return array;
}
use of org.vmmagic.pragma.Interruptible 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.pragma.Interruptible 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;
}
Aggregations