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());
}
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);
}
}
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);
}
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);
}
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;
}
Aggregations