Search in sources :

Example 1 with Interruptible

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();
    }
}
Also used : RVMMethod(org.jikesrvm.classloader.RVMMethod) TypeReference(org.jikesrvm.classloader.TypeReference) Atom(org.jikesrvm.classloader.Atom) RVMClass(org.jikesrvm.classloader.RVMClass) Interruptible(org.vmmagic.pragma.Interruptible)

Example 2 with Interruptible

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();
}
Also used : BootRecord(org.jikesrvm.runtime.BootRecord) Interruptible(org.vmmagic.pragma.Interruptible)

Example 3 with Interruptible

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;
}
Also used : RVMArray(org.jikesrvm.classloader.RVMArray) TIB(org.jikesrvm.objectmodel.TIB) Entrypoint(org.vmmagic.pragma.Entrypoint) Interruptible(org.vmmagic.pragma.Interruptible) NoInline(org.vmmagic.pragma.NoInline)

Example 4 with Interruptible

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;
}
Also used : Address(org.vmmagic.unboxed.Address) Entrypoint(org.vmmagic.pragma.Entrypoint) Interruptible(org.vmmagic.pragma.Interruptible)

Example 5 with Interruptible

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;
}
Also used : Address(org.vmmagic.unboxed.Address) Entrypoint(org.vmmagic.pragma.Entrypoint) Interruptible(org.vmmagic.pragma.Interruptible)

Aggregations

Interruptible (org.vmmagic.pragma.Interruptible)44 Entrypoint (org.vmmagic.pragma.Entrypoint)22 Address (org.vmmagic.unboxed.Address)11 NoInline (org.vmmagic.pragma.NoInline)9 TIB (org.jikesrvm.objectmodel.TIB)8 RVMArray (org.jikesrvm.classloader.RVMArray)7 RVMType (org.jikesrvm.classloader.RVMType)6 RVMMethod (org.jikesrvm.classloader.RVMMethod)3 Offset (org.vmmagic.unboxed.Offset)3 NormalMethod (org.jikesrvm.classloader.NormalMethod)2 RVMClass (org.jikesrvm.classloader.RVMClass)2 CodeArray (org.jikesrvm.compilers.common.CodeArray)2 CallSiteTreeNode (org.jikesrvm.compilers.opt.inlining.CallSiteTreeNode)2 CollectorThread (org.jikesrvm.mm.mminterface.CollectorThread)2 Extent (org.vmmagic.unboxed.Extent)2 EventAttribute (com.ibm.tuningfork.tracegen.types.EventAttribute)1 Atom (org.jikesrvm.classloader.Atom)1 TypeReference (org.jikesrvm.classloader.TypeReference)1 BaselineCompiledMethod (org.jikesrvm.compilers.baseline.BaselineCompiledMethod)1 CompiledMethod (org.jikesrvm.compilers.common.CompiledMethod)1