Search in sources :

Example 21 with Entrypoint

use of org.vmmagic.pragma.Entrypoint in project JikesRVM by JikesRVM.

the class MemoryManager method modifyCheck.

/**
 *********************************************************************
 *
 * Write barriers
 */
/**
 * Checks that if a garbage collection is in progress then the given
 * object is not movable.  If it is movable error messages are
 * logged and the system exits.
 *
 * @param object the object to check
 */
@Entrypoint
public static void modifyCheck(Object object) {
    /* Make sure that during GC, we don't update on a possibly moving object.
       Such updates are dangerous because they can be lost.
     */
    if (Plan.gcInProgressProper()) {
        ObjectReference ref = ObjectReference.fromObject(object);
        if (Space.isMovable(ref)) {
            VM.sysWriteln("GC modifying a potentially moving object via Java (i.e. not magic)");
            VM.sysWriteln("  obj = ", ref);
            RVMType t = Magic.getObjectType(object);
            VM.sysWrite(" type = ");
            VM.sysWriteln(t.getDescriptor());
            VM.sysFail("GC modifying a potentially moving object via Java (i.e. not magic)");
        }
    }
}
Also used : ObjectReference(org.vmmagic.unboxed.ObjectReference) RVMType(org.jikesrvm.classloader.RVMType) Entrypoint(org.vmmagic.pragma.Entrypoint)

Example 22 with Entrypoint

use of org.vmmagic.pragma.Entrypoint in project JikesRVM by JikesRVM.

the class JNIEnvironment method entryToJNI.

/**
 * Save data and perform necessary conversions for entry into JNI.
 * NB only used for Intel.
 *
 * @param encodedReferenceOffsets
 *          bit mask marking which elements on the stack hold objects that need
 *          encoding as JNI ref identifiers
 */
@Uninterruptible("Objects on the stack won't be recognized by GC, therefore don't allow GC")
@Entrypoint
public void entryToJNI(int encodedReferenceOffsets) {
    // Save processor
    savedTRreg = Magic.getThreadRegister();
    // Save frame pointer of calling routine, once so that native stack frames
    // are skipped and once for use by GC
    Address callersFP = Magic.getCallerFramePointer(Magic.getFramePointer());
    // NB old value saved on call stack
    basePointerOnEntryToNative = callersFP;
    JNITopJavaFP = callersFP;
    if (VM.traceJNI) {
        RVMMethod m = CompiledMethods.getCompiledMethod(Magic.getCompiledMethodID(callersFP)).getMethod();
        VM.sysWrite("calling JNI from ");
        VM.sysWrite(m.getDeclaringClass().getDescriptor());
        VM.sysWrite(" ");
        VM.sysWrite(m.getName());
        VM.sysWrite(m.getDescriptor());
        VM.sysWriteln();
    }
    // Save current JNI ref stack pointer
    if (JNIRefsTop > 0) {
        uninterruptiblePushJNIRef(Address.fromIntSignExtend(JNIRefsSavedFP), false);
        JNIRefsSavedFP = JNIRefsTop;
    }
    // Convert arguments on stack from objects to JNI references
    Address fp = Magic.getFramePointer();
    Offset argOffset = Offset.fromIntSignExtend(5 * BYTES_IN_ADDRESS);
    fp.store(uninterruptiblePushJNIRef(fp.loadAddress(argOffset), true), argOffset);
    while (encodedReferenceOffsets != 0) {
        argOffset = argOffset.plus(BYTES_IN_ADDRESS);
        if ((encodedReferenceOffsets & 1) != 0) {
            fp.store(uninterruptiblePushJNIRef(fp.loadAddress(argOffset), true), argOffset);
        }
        encodedReferenceOffsets >>>= 1;
    }
    // Transition processor from IN_JAVA to IN_JNI
    RVMThread.enterJNIFromCallIntoNative();
}
Also used : RVMMethod(org.jikesrvm.classloader.RVMMethod) Address(org.vmmagic.unboxed.Address) Offset(org.vmmagic.unboxed.Offset) Uninterruptible(org.vmmagic.pragma.Uninterruptible) Entrypoint(org.vmmagic.pragma.Entrypoint)

Example 23 with Entrypoint

use of org.vmmagic.pragma.Entrypoint in project JikesRVM by JikesRVM.

the class OptSaveVolatile method resolve.

/**
 * Wrapper to save/restore volatile registers when a class needs to be
 * dynamically loaded/resolved/etc.
 */
@Entrypoint
@Interruptible
public static void resolve() throws NoClassDefFoundError {
    VM.disableGC();
    // (1) Get the compiled method & compilerInfo for the (opt)
    // compiled method that called resolve
    Address fp = Magic.getCallerFramePointer(Magic.getFramePointer());
    int cmid = Magic.getCompiledMethodID(fp);
    OptCompiledMethod cm = (OptCompiledMethod) CompiledMethods.getCompiledMethod(cmid);
    // (2) Get the return address
    Address ip = Magic.getReturnAddressUnchecked(Magic.getFramePointer());
    Offset offset = cm.getInstructionOffset(ip);
    VM.enableGC();
    // (3) Call the routine in OptLinker that does all the real work.
    OptLinker.resolveDynamicLink(cm, offset);
}
Also used : Address(org.vmmagic.unboxed.Address) Entrypoint(org.vmmagic.pragma.Entrypoint) Offset(org.vmmagic.unboxed.Offset) Interruptible(org.vmmagic.pragma.Interruptible) Entrypoint(org.vmmagic.pragma.Entrypoint)

Example 24 with Entrypoint

use of org.vmmagic.pragma.Entrypoint in project JikesRVM by JikesRVM.

the class OptSaveVolatile method yieldpointFromEpilogue.

/**
 * Handle timer interrupt taken in method epilogue.
 * This method is identical to the yieldpointFromEpilogue()
 * method used by the baseline compiler, except in the OPT compiler world,
 * we also save the volatile registers.
 */
@Entrypoint
public static void yieldpointFromEpilogue() {
    Address fp = Magic.getFramePointer();
    RVMThread.yieldpoint(RVMThread.EPILOGUE, fp);
}
Also used : Address(org.vmmagic.unboxed.Address) Entrypoint(org.vmmagic.pragma.Entrypoint)

Example 25 with Entrypoint

use of org.vmmagic.pragma.Entrypoint in project JikesRVM by JikesRVM.

the class OptSaveVolatile method yieldpointFromPrologue.

/**
 * Handle timer interrupt taken in method prologue.
 * This method is identical to the yieldpointFromPrologue()
 * method used by the baseline compiler, except in the OPT compiler world,
 * we also save the volatile registers.
 */
@Entrypoint
public static void yieldpointFromPrologue() {
    Address fp = Magic.getFramePointer();
    RVMThread.yieldpoint(RVMThread.PROLOGUE, fp);
}
Also used : Address(org.vmmagic.unboxed.Address) Entrypoint(org.vmmagic.pragma.Entrypoint)

Aggregations

Entrypoint (org.vmmagic.pragma.Entrypoint)69 Inline (org.vmmagic.pragma.Inline)35 ObjectReference (org.vmmagic.unboxed.ObjectReference)33 Offset (org.vmmagic.unboxed.Offset)22 Address (org.vmmagic.unboxed.Address)12 TypeReference (org.jikesrvm.classloader.TypeReference)7 NoInline (org.vmmagic.pragma.NoInline)7 RVMType (org.jikesrvm.classloader.RVMType)6 Unpreemptible (org.vmmagic.pragma.Unpreemptible)6 RVMMethod (org.jikesrvm.classloader.RVMMethod)5 RVMArray (org.jikesrvm.classloader.RVMArray)3 RVMClass (org.jikesrvm.classloader.RVMClass)3 RVMThread (org.jikesrvm.scheduler.RVMThread)3 BaselineSaveLSRegisters (org.vmmagic.pragma.BaselineSaveLSRegisters)3 NoOptCompile (org.vmmagic.pragma.NoOptCompile)3 AbstractRegisters (org.jikesrvm.architecture.AbstractRegisters)2 CompiledMethod (org.jikesrvm.compilers.common.CompiledMethod)2 ForwardReference (org.jikesrvm.compilers.common.assembler.ForwardReference)2 ITable (org.jikesrvm.objectmodel.ITable)2 TIB (org.jikesrvm.objectmodel.TIB)2