Search in sources :

Example 56 with Inline

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

the class VM method disableGC.

/**
 * disableGC: Disable GC if it hasn't already been disabled.  This
 * enforces a stack discipline; we need it for the JNI Get*Critical and
 * Release*Critical functions.  Should be matched with a subsequent call to
 * enableGC().
 *
 * @param recursiveOK whether recursion is allowed.
 */
@Inline
@Unpreemptible("We may boost the size of the stack with GC disabled and may get preempted doing this")
public static void disableGC(boolean recursiveOK) {
    // current (non-GC) thread is going to be holding raw addresses, therefore we must:
    // 
    // 1. make sure we have enough stack space to run until GC is re-enabled
    // (otherwise we might trigger a stack reallocation)
    // (We can't resize the stack if there's a native frame, so don't
    // do it and hope for the best)
    // 
    // 2. force all other threads that need GC to wait until this thread
    // is done with the raw addresses
    // 
    // 3. ensure that this thread doesn't try to allocate any objects
    // (because an allocation attempt might trigger a collection that
    // would invalidate the addresses we're holding)
    // 
    RVMThread myThread = RVMThread.getCurrentThread();
    // 0. Sanity Check; recursion
    int gcDepth = myThread.getDisableGCDepth();
    if (VM.VerifyAssertions)
        VM._assert(gcDepth >= 0);
    gcDepth++;
    myThread.setDisableGCDepth(gcDepth);
    if (gcDepth > 1) {
        // We've already disabled it.
        return;
    }
    // 
    if (Magic.getFramePointer().minus(StackFrameLayout.getStackSizeGCDisabled()).LT(myThread.stackLimit) && !myThread.hasNativeStackFrame()) {
        RVMThread.resizeCurrentStack(myThread.getStackLength() + StackFrameLayout.getStackSizeGCDisabled(), null);
    }
    // 2.
    // 
    myThread.disableYieldpoints();
    // 
    if (VM.VerifyAssertions) {
        if (!recursiveOK) {
            // recursion not allowed
            VM._assert(!myThread.getDisallowAllocationsByThisThread());
        }
        myThread.setDisallowAllocationsByThisThread();
    }
}
Also used : RVMThread(org.jikesrvm.scheduler.RVMThread) Entrypoint(org.vmmagic.pragma.Entrypoint) Unpreemptible(org.vmmagic.pragma.Unpreemptible) Inline(org.vmmagic.pragma.Inline) NoInline(org.vmmagic.pragma.NoInline)

Example 57 with Inline

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

the class BaselineCompilerImpl method genBoundsCheck.

/**
 * Generate an array bounds check trapping if the array bound check fails,
 * otherwise falling through.
 * @param asm the assembler to generate into
 * @param indexReg the register containing the index
 * @param arrayRefReg the register containing the array reference
 */
@Inline(value = Inline.When.ArgumentsAreConstant, arguments = { 1, 2 })
static void genBoundsCheck(Assembler asm, GPR indexReg, GPR arrayRefReg) {
    // compare index to array length
    if (ARRAY_LENGTH_BYTES == 4) {
        asm.emitCMP_RegDisp_Reg(arrayRefReg, ObjectModel.getArrayLengthOffset(), indexReg);
    } else {
        asm.emitCMP_RegDisp_Reg_Quad(arrayRefReg, ObjectModel.getArrayLengthOffset(), indexReg);
    }
    // Jmp around trap if index is OK
    asm.emitBranchLikelyNextInstruction();
    ForwardReference fr = asm.forwardJcc(LGT);
    // "pass" index param to C trap handler
    asm.emitMOV_RegDisp_Reg(THREAD_REGISTER, ArchEntrypoints.arrayIndexTrapParamField.getOffset(), indexReg);
    // trap
    asm.emitINT_Imm(RuntimeEntrypoints.TRAP_ARRAY_BOUNDS + RVM_TRAP_BASE);
    fr.resolve(asm);
}
Also used : ForwardReference(org.jikesrvm.compilers.common.assembler.ForwardReference) Inline(org.vmmagic.pragma.Inline)

Example 58 with Inline

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

the class RCHeader method remainRC.

/**
 * Retain the reference count of an object.  Return either
 * <code>INC_OLD</code> if the object is not new,
 * <code>INC_NEW</code> if the object is new.
 *
 * @param object The object whose RC is to be retained.
 * @return <code>INC_OLD</code> if the object is not new,
 * <code>INC_NEW</code> if the object is new.
 */
@Inline
public static int remainRC(ObjectReference object) {
    Word oldValue, newValue;
    int rtn;
    if (VM.VERIFY_ASSERTIONS)
        VM.assertions._assert(RCBase.isRCObject(object));
    do {
        oldValue = VM.objectModel.prepareAvailableBits(object);
        newValue = oldValue;
        if (RCBase.BUILD_FOR_GENRC) {
            return INC_OLD;
        } else {
            if (isHeaderNew(oldValue)) {
                newValue = newValue.or(NEW_BIT_MASK);
                rtn = INC_NEW;
            } else {
                return INC_OLD;
            }
        }
    } while (!VM.objectModel.attemptAvailableBits(object, oldValue, newValue));
    return rtn;
}
Also used : Word(org.vmmagic.unboxed.Word) Inline(org.vmmagic.pragma.Inline)

Example 59 with Inline

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

the class RCHeader method clearMarked.

/**
 * Clears the mark status for the given object.
 * @param object the object whose status will be cleared
 */
@Inline
public static void clearMarked(ObjectReference object) {
    Word oldValue, newValue;
    do {
        oldValue = VM.objectModel.prepareAvailableBits(object);
        if (VM.VERIFY_ASSERTIONS)
            VM.assertions._assert(isHeaderMarked(oldValue));
        newValue = oldValue.and(MARK_BIT_MASK.not());
    } while (!VM.objectModel.attemptAvailableBits(object, oldValue, newValue));
}
Also used : Word(org.vmmagic.unboxed.Word) Inline(org.vmmagic.pragma.Inline)

Example 60 with Inline

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

the class RCHeader method incRC.

/**
 * Increment the reference count of an object.  Return either
 * <code>INC_OLD</code> if the object is not new,
 * <code>INC_NEW</code> if the object is new.
 *
 * @param object The object whose RC is to be incremented.
 * @return <code>INC_OLD</code> if the object is not new,
 * <code>INC_NEW</code> if the object is new.
 */
@Inline
public static int incRC(ObjectReference object) {
    Word oldValue, newValue;
    int rtn;
    if (VM.VERIFY_ASSERTIONS)
        VM.assertions._assert(RCBase.isRCObject(object));
    do {
        oldValue = VM.objectModel.prepareAvailableBits(object);
        if (isStuck(oldValue))
            return INC_OLD;
        if (RCBase.BUILD_FOR_GENRC) {
            newValue = oldValue.plus(INCREMENT);
            rtn = INC_OLD;
        } else {
            if (isHeaderNew(oldValue)) {
                newValue = oldValue.plus(DOUBLE_INCREMENT);
                newValue = newValue.or(NEW_BIT_MASK);
                rtn = INC_NEW;
            } else {
                newValue = oldValue.plus(INCREMENT);
                rtn = INC_OLD;
            }
        }
    } while (!VM.objectModel.attemptAvailableBits(object, oldValue, newValue));
    return rtn;
}
Also used : Word(org.vmmagic.unboxed.Word) Inline(org.vmmagic.pragma.Inline)

Aggregations

Inline (org.vmmagic.pragma.Inline)110 NoInline (org.vmmagic.pragma.NoInline)42 Entrypoint (org.vmmagic.pragma.Entrypoint)40 Offset (org.vmmagic.unboxed.Offset)38 ObjectReference (org.vmmagic.unboxed.ObjectReference)35 Address (org.vmmagic.unboxed.Address)15 Word (org.vmmagic.unboxed.Word)15 TypeReference (org.jikesrvm.classloader.TypeReference)12 Uninterruptible (org.vmmagic.pragma.Uninterruptible)6 RVMType (org.jikesrvm.classloader.RVMType)5 RVMClass (org.jikesrvm.classloader.RVMClass)4 Unpreemptible (org.vmmagic.pragma.Unpreemptible)4 RVMClassLoader (org.jikesrvm.classloader.RVMClassLoader)3 TIB (org.jikesrvm.objectmodel.TIB)3 Extent (org.vmmagic.unboxed.Extent)3 MethodReference (org.jikesrvm.classloader.MethodReference)2 ForwardReference (org.jikesrvm.compilers.common.assembler.ForwardReference)2 RVMThread (org.jikesrvm.scheduler.RVMThread)2 CollectorContext (org.mmtk.plan.CollectorContext)2 NoNullCheck (org.vmmagic.pragma.NoNullCheck)2