Search in sources :

Example 81 with Address

use of org.vmmagic.unboxed.Address in project JikesRVM by JikesRVM.

the class DynamicLinkerHelper method getReceiverObject.

/**
 * Reach up two stack frames into a frame that is compiled
 * with the DynamicBridge register protocol and grap
 * the receiver object of the invoke (ie the first param).
 * NOTE: assumes that caller has disabled GC.
 */
@NoInline
public static Object getReceiverObject() {
    // reach into register save area and fetch "this" parameter
    Address callingFrame = Magic.getCallerFramePointer(Magic.getFramePointer());
    callingFrame = Magic.getCallerFramePointer(callingFrame);
    callingFrame = Magic.getCallerFramePointer(callingFrame);
    Address location = callingFrame.minus((LAST_NONVOLATILE_FPR.value() - FIRST_VOLATILE_FPR.value() + 1) * BYTES_IN_DOUBLE + (LAST_NONVOLATILE_GPR.value() - FIRST_VOLATILE_GPR.value() + 1) * BYTES_IN_ADDRESS);
    return Magic.addressAsObject(location.loadAddress());
}
Also used : Address(org.vmmagic.unboxed.Address) NoInline(org.vmmagic.pragma.NoInline)

Example 82 with Address

use of org.vmmagic.unboxed.Address in project JikesRVM by JikesRVM.

the class MultianewarrayHelper method newArrayArray.

/**
 * Allocate something like {@code new Foo[cnt0][cnt1]...[cntN-1]},
 *                      or {@code new int[cnt0][cnt1]...[cntN-1]}.
 * @param methodId      id of caller
 * @param numDimensions number of array dimensions
 * @param typeId        {@link TypeReference} id of type of array
 * @param argOffset     position of word *above* `cnt0' argument within caller's frame
 *                      This is used to access the number of elements to
 *                      be allocated for each dimension.
 * See also: bytecode 0xc5 ("multianewarray") in Compiler
 * @return the new array
 */
@Entrypoint
static Object newArrayArray(int methodId, int numDimensions, int typeId, int argOffset) throws NoClassDefFoundError, NegativeArraySizeException, OutOfMemoryError {
    if (numDimensions == 2) {
        int dim0, dim1;
        // fetch number of elements to be allocated for each array dimension
        VM.disableGC();
        Address argp = Magic.getFramePointer().loadAddress().plus(argOffset);
        int offset = (BYTES_IN_STACKSLOT * 0) + BYTES_IN_INT;
        dim0 = argp.minus(offset).loadInt();
        offset = (BYTES_IN_STACKSLOT * 1) + BYTES_IN_INT;
        dim1 = argp.minus(offset).loadInt();
        VM.enableGC();
        // validate arguments
        if ((dim0 < 0) || (dim1 < 0))
            throw new NegativeArraySizeException();
        // create array
        TypeReference tRef = TypeReference.getTypeRef(typeId);
        RVMArray array = tRef.resolve().asArray();
        return RuntimeEntrypoints.buildTwoDimensionalArray(methodId, dim0, dim1, array);
    } else {
        // fetch number of elements to be allocated for each array dimension
        int[] numElements = new int[numDimensions];
        VM.disableGC();
        Address argp = Magic.getFramePointer().loadAddress().plus(argOffset);
        for (int i = 0; i < numDimensions; ++i) {
            int offset = (BYTES_IN_STACKSLOT * i) + BYTES_IN_INT;
            numElements[i] = argp.minus(offset).loadInt();
        }
        VM.enableGC();
        // validate arguments
        for (int elements : numElements) {
            if (elements < 0)
                throw new NegativeArraySizeException();
        }
        // create array
        TypeReference tRef = TypeReference.getTypeRef(typeId);
        RVMArray array = tRef.resolve().asArray();
        return RuntimeEntrypoints.buildMultiDimensionalArray(methodId, numElements, array);
    }
}
Also used : Address(org.vmmagic.unboxed.Address) RVMArray(org.jikesrvm.classloader.RVMArray) TypeReference(org.jikesrvm.classloader.TypeReference) Entrypoint(org.vmmagic.pragma.Entrypoint) Entrypoint(org.vmmagic.pragma.Entrypoint)

Example 83 with Address

use of org.vmmagic.unboxed.Address in project JikesRVM by JikesRVM.

the class RVMThread method dumpStack.

/**
 * Dump state of a (stopped) thread's stack.
 *
 * @param fp address of starting frame. first frame output is the calling
 * frame of passed frame
 */
public static void dumpStack(Address fp) {
    if (VM.VerifyAssertions) {
        VM._assert(VM.runningVM);
    }
    Address ip = Magic.getReturnAddress(fp);
    fp = Magic.getCallerFramePointer(fp);
    dumpStack(ip, fp);
}
Also used : Address(org.vmmagic.unboxed.Address)

Example 84 with Address

use of org.vmmagic.unboxed.Address in project JikesRVM by JikesRVM.

the class RVMThread method yieldpointFromEpilogue.

/**
 * Yieldpoint taken in epilogue.
 */
@BaselineSaveLSRegisters
// Save all non-volatile registers in prologue
@NoOptCompile
@NoInline
// TODO fix this -- related to SaveVolatile
@Entrypoint
@Unpreemptible("Becoming another thread interrupts the current thread, avoid preemption in the process")
public static void yieldpointFromEpilogue() {
    Address fp = Magic.getFramePointer();
    yieldpoint(EPILOGUE, fp);
}
Also used : Address(org.vmmagic.unboxed.Address) Unpreemptible(org.vmmagic.pragma.Unpreemptible) Entrypoint(org.vmmagic.pragma.Entrypoint) BaselineSaveLSRegisters(org.vmmagic.pragma.BaselineSaveLSRegisters) NoInline(org.vmmagic.pragma.NoInline) NoOptCompile(org.vmmagic.pragma.NoOptCompile)

Example 85 with Address

use of org.vmmagic.unboxed.Address in project JikesRVM by JikesRVM.

the class SpinLock method tryLock.

/**
 * Conditionally acquire a lock.
 * @return whether acquisition succeeded
 */
public boolean tryLock() {
    if (!VM.runningVM)
        return true;
    VM.disableYieldpoints();
    Offset latestContenderOffset = Entrypoints.latestContenderField.getOffset();
    if (Magic.prepareAddress(this, latestContenderOffset).isZero()) {
        Address cp = Magic.objectAsAddress(RVMThread.getCurrentThread());
        if (Magic.attemptAddress(this, latestContenderOffset, Address.zero(), cp)) {
            if (!VM.MagicAttemptImpliesStoreLoadBarrier)
                Magic.fence();
            return true;
        }
    }
    VM.enableYieldpoints();
    return false;
}
Also used : Address(org.vmmagic.unboxed.Address) Offset(org.vmmagic.unboxed.Offset)

Aggregations

Address (org.vmmagic.unboxed.Address)281 Offset (org.vmmagic.unboxed.Offset)48 CompiledMethod (org.jikesrvm.compilers.common.CompiledMethod)30 NoInline (org.vmmagic.pragma.NoInline)30 Test (org.junit.Test)24 Entrypoint (org.vmmagic.pragma.Entrypoint)22 TypeReference (org.jikesrvm.classloader.TypeReference)21 OptCompiledMethod (org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod)17 RVMType (org.jikesrvm.classloader.RVMType)16 Inline (org.vmmagic.pragma.Inline)15 Uninterruptible (org.vmmagic.pragma.Uninterruptible)14 Word (org.vmmagic.unboxed.Word)14 BaseMMTkTest (org.mmtk.harness.tests.BaseMMTkTest)13 Unpreemptible (org.vmmagic.pragma.Unpreemptible)12 ObjectReference (org.vmmagic.unboxed.ObjectReference)12 Interruptible (org.vmmagic.pragma.Interruptible)11 Extent (org.vmmagic.unboxed.Extent)11 RVMClass (org.jikesrvm.classloader.RVMClass)9 AddressConstantOperand (org.jikesrvm.compilers.opt.ir.operand.AddressConstantOperand)8 IntConstantOperand (org.jikesrvm.compilers.opt.ir.operand.IntConstantOperand)8