use of org.vmmagic.unboxed.Address in project JikesRVM by JikesRVM.
the class Memory method arraycopy16Bit.
/**
* Low level copy of len elements from src[srcPos] to dst[dstPos].
* <p>
* Assumption; {@code src != dst || (srcPos >= dstPos + 2)}.
*
* @param src the source array
* @param srcPos index in the source array to begin copy
* @param dst the destination array
* @param dstPos index in the destination array to being copy
* @param len number of array elements to copy
*/
public static void arraycopy16Bit(Object src, int srcPos, Object dst, int dstPos, int len) {
Address srcPtr = Magic.objectAsAddress(src).plus(srcPos << LOG_BYTES_IN_SHORT);
Address dstPtr = Magic.objectAsAddress(dst).plus(dstPos << LOG_BYTES_IN_SHORT);
int copyBytes = len << LOG_BYTES_IN_SHORT;
aligned16Copy(dstPtr, srcPtr, copyBytes);
}
use of org.vmmagic.unboxed.Address in project JikesRVM by JikesRVM.
the class Memory method arraycopy8Bit.
/**
* Low level copy of len elements from src[srcPos] to dst[dstPos].
*
* Assumptions: <code> src != dst || (scrPos >= dstPos + 4) </code>
* and src and dst are 8Bit arrays.
* @param src the source array
* @param srcPos index in the source array to begin copy
* @param dst the destination array
* @param dstPos index in the destination array to being copy
* @param len number of array elements to copy
*/
public static void arraycopy8Bit(Object src, int srcPos, Object dst, int dstPos, int len) {
Address srcPtr = Magic.objectAsAddress(src).plus(srcPos);
Address dstPtr = Magic.objectAsAddress(dst).plus(dstPos);
aligned8Copy(dstPtr, srcPtr, len);
}
use of org.vmmagic.unboxed.Address in project JikesRVM by JikesRVM.
the class Memory method internalAlignedWordCopy.
/**
* Copy <code>numbytes</code> from <code>src</code> to <code>dst</code>.
* Assumption either the ranges are non overlapping, or <code>src >= dst + BYTES_IN_ADDRESS</code>.
* @param dst The destination addr
* @param src The source addr
* @param numBytes The number of bytes to copy
*/
private static void internalAlignedWordCopy(Address dst, Address src, int numBytes) {
Address end = src.plus(numBytes);
while (src.LT(end)) {
dst.store(src.loadWord());
src = src.plus(BYTES_IN_ADDRESS);
dst = dst.plus(BYTES_IN_ADDRESS);
}
}
use of org.vmmagic.unboxed.Address in project JikesRVM by JikesRVM.
the class RuntimeEntrypoints method deliverHardwareException.
/**
* Deliver a hardware exception to current java thread.
* <p>
* Does not return.
* (stack is unwound, starting at trap site, and
* execution resumes in a catch block somewhere up the stack)
* /or/ execution resumes at instruction following trap
* (for TRAP_STACK_OVERFLOW)
*
* <p> Note: Control reaches here by the actions of an
* external "C" signal handler
* which saves the register state of the trap site into the
* "exceptionRegisters" field of the current
* Thread object.
* The signal handler also inserts a <hardware trap> frame
* onto the stack immediately above this frame, for use by
* HardwareTrapGCMapIterator during garbage collection.
*
* @param trapCode code indicating kind of exception that was trapped
* (see TRAP_xxx, above)
* @param trapInfo array subscript (for array bounds trap, only), marker
* (for stack overflow traps on PPC) or
*/
@Entrypoint
@UnpreemptibleNoWarn
static void deliverHardwareException(int trapCode, Word trapInfo) {
if (VM.verboseSignalHandling)
VM.sysWriteln("delivering hardware exception");
RVMThread myThread = RVMThread.getCurrentThread();
if (VM.verboseSignalHandling)
VM.sysWriteln("we have a thread = ", Magic.objectAsAddress(myThread));
if (VM.verboseSignalHandling)
VM.sysWriteln("it's in state = ", myThread.getExecStatus());
AbstractRegisters exceptionRegisters = myThread.getExceptionRegisters();
if (VM.verboseSignalHandling)
VM.sysWriteln("we have exception registers = ", Magic.objectAsAddress(exceptionRegisters));
if ((trapCode == TRAP_STACK_OVERFLOW || trapCode == TRAP_JNI_STACK) && myThread.getStack().length < (StackFrameLayout.getMaxStackSize() >> LOG_BYTES_IN_ADDRESS) && !myThread.hasNativeStackFrame()) {
// (C trap handler has set register.ip to the instruction following the trap).
if (trapCode == TRAP_JNI_STACK) {
RVMThread.resizeCurrentStack(myThread.getStackLength() + StackFrameLayout.getJNIStackGrowthSize(), exceptionRegisters);
} else {
RVMThread.resizeCurrentStack(myThread.getStackLength() + StackFrameLayout.getStackGrowthSize(), exceptionRegisters);
}
if (VM.VerifyAssertions)
VM._assert(exceptionRegisters.getInUse());
exceptionRegisters.setInUse(false);
Magic.restoreHardwareExceptionState(exceptionRegisters);
if (VM.VerifyAssertions)
VM._assert(NOT_REACHED);
}
// GC stress testing
if (canForceGC()) {
// VM.sysWriteln("FORCING GC: in deliverHardwareException");
System.gc();
}
// Hardware traps in uninterruptible code should be considered hard failures.
if (!VM.sysFailInProgress()) {
Address fp = exceptionRegisters.getInnermostFramePointer();
int compiledMethodId = Magic.getCompiledMethodID(fp);
if (compiledMethodId != StackFrameLayout.getInvisibleMethodID()) {
CompiledMethod compiledMethod = CompiledMethods.getCompiledMethod(compiledMethodId);
Address ip = exceptionRegisters.getInnermostInstructionAddress();
Offset instructionOffset = compiledMethod.getInstructionOffset(ip);
if (compiledMethod.isWithinUninterruptibleCode(instructionOffset)) {
VM.sysWriteln();
switch(trapCode) {
case TRAP_NULL_POINTER:
VM.sysWriteln("Fatal error: NullPointerException within uninterruptible region.");
break;
case TRAP_ARRAY_BOUNDS:
VM.sysWriteln("Fatal error: ArrayIndexOutOfBoundsException within uninterruptible region (index was ", trapInfo.toInt(), ").");
break;
case TRAP_DIVIDE_BY_ZERO:
VM.sysWriteln("Fatal error: DivideByZero within uninterruptible region.");
break;
case TRAP_STACK_OVERFLOW:
case TRAP_JNI_STACK:
VM.sysWriteln("Fatal error: StackOverflowError within uninterruptible region.");
break;
case TRAP_CHECKCAST:
VM.sysWriteln("Fatal error: ClassCastException within uninterruptible region.");
break;
case TRAP_MUST_IMPLEMENT:
VM.sysWriteln("Fatal error: IncompatibleClassChangeError within uninterruptible region.");
break;
case TRAP_STORE_CHECK:
VM.sysWriteln("Fatal error: ArrayStoreException within uninterruptible region.");
break;
case TRAP_UNREACHABLE_BYTECODE:
VM.sysWriteln("Fatal error: Reached a bytecode that was determined to be unreachable within uninterruptible region.");
break;
default:
VM.sysWriteln("Fatal error: Unknown hardware trap within uninterruptible region.");
break;
}
VM.sysWriteln("trapCode = ", trapCode);
VM.sysWriteln("trapInfo = ", trapInfo.toAddress());
VM.sysFail("Exiting virtual machine due to uninterruptibility violation.");
}
}
}
Throwable exceptionObject;
switch(trapCode) {
case TRAP_NULL_POINTER:
exceptionObject = new java.lang.NullPointerException();
break;
case TRAP_ARRAY_BOUNDS:
exceptionObject = new java.lang.ArrayIndexOutOfBoundsException(trapInfo.toInt());
break;
case TRAP_DIVIDE_BY_ZERO:
exceptionObject = new java.lang.ArithmeticException();
break;
case TRAP_STACK_OVERFLOW:
case TRAP_JNI_STACK:
exceptionObject = new java.lang.StackOverflowError();
break;
case TRAP_CHECKCAST:
exceptionObject = new java.lang.ClassCastException();
break;
case TRAP_MUST_IMPLEMENT:
exceptionObject = new java.lang.IncompatibleClassChangeError();
break;
case TRAP_STORE_CHECK:
exceptionObject = new java.lang.ArrayStoreException();
break;
case TRAP_UNREACHABLE_BYTECODE:
exceptionObject = new java.lang.InternalError(UNREACHABLE_BC_MESSAGE);
break;
default:
exceptionObject = new java.lang.UnknownError();
RVMThread.traceback("UNKNOWN ERROR");
break;
}
// VM.enableGC() is called when the exception is delivered.
VM.disableGC();
deliverException(exceptionObject, exceptionRegisters);
}
use of org.vmmagic.unboxed.Address in project JikesRVM by JikesRVM.
the class StackTrace method countFramesUninterruptible.
/**
* Walk the stack counting the number of stack frames encountered.
* The stack being walked is our stack, so code is Uninterruptible to stop the
* stack moving.
*
* @param stackTraceThread the thread whose stack is walked
* @return number of stack frames encountered
*/
@Uninterruptible
@NoInline
private int countFramesUninterruptible(RVMThread stackTraceThread) {
int stackFrameCount = 0;
Address fp;
/* Stack trace for the thread */
if (stackTraceThread == RVMThread.getCurrentThread()) {
fp = Magic.getFramePointer();
} else {
AbstractRegisters contextRegisters = stackTraceThread.getContextRegisters();
fp = contextRegisters.getInnermostFramePointer();
}
fp = Magic.getCallerFramePointer(fp);
while (Magic.getCallerFramePointer(fp).NE(StackFrameLayout.getStackFrameSentinelFP())) {
int compiledMethodId = Magic.getCompiledMethodID(fp);
if (compiledMethodId != StackFrameLayout.getInvisibleMethodID()) {
CompiledMethod compiledMethod = CompiledMethods.getCompiledMethod(compiledMethodId);
if ((compiledMethod.getCompilerType() != CompiledMethod.TRAP) && compiledMethod.hasBridgeFromNativeAnnotation()) {
// skip native frames, stopping at last native frame preceeding the
// Java To C transition frame
fp = RuntimeEntrypoints.unwindNativeStackFrame(fp);
}
}
stackFrameCount++;
fp = Magic.getCallerFramePointer(fp);
}
// VM.sysWriteln("stack frame count = ",stackFrameCount);
return stackFrameCount;
}
Aggregations