use of org.vmmagic.pragma.NoInline in project JikesRVM by JikesRVM.
the class TIB method setVirtualMethod.
/**
* Set a virtual method in this TIB.
*
* When running the VM, we must translate requests to use the internal
* lazy compilation trampoline.
*
* @param virtualMethodIndex the index of the virtual metho
* @param code the code for the virtual method
*/
@NoInline
public void setVirtualMethod(int virtualMethodIndex, CodeArray code) {
if (VM.VerifyAssertions)
VM._assert(virtualMethodIndex >= 0);
if (VM.runningVM && code == LazyCompilationTrampoline.getInstructions()) {
Address tibAddress = Magic.objectAsAddress(this);
Address callAddress = tibAddress.plus(Offset.fromIntZeroExtend(lazyMethodInvokerTrampolineIndex() << LOG_BYTES_IN_ADDRESS));
set(TIB_FIRST_VIRTUAL_METHOD_INDEX + virtualMethodIndex, callAddress);
} else {
set(TIB_FIRST_VIRTUAL_METHOD_INDEX + virtualMethodIndex, code);
}
}
use of org.vmmagic.pragma.NoInline in project JikesRVM by JikesRVM.
the class MemoryManager method newTIB.
/**
* Allocates a new type information block (TIB).
*
* @param numVirtualMethods the number of virtual method slots in the TIB
* @param alignCode alignment encoding for the TIB
* @return the new TIB
* @see AlignmentEncoding
*/
@NoInline
@Interruptible
public static TIB newTIB(int numVirtualMethods, int alignCode) {
int elements = TIB.computeSize(numVirtualMethods);
if (!VM.runningVM) {
return TIB.allocate(elements, alignCode);
}
if (alignCode == AlignmentEncoding.ALIGN_CODE_NONE) {
return (TIB) newRuntimeTable(elements, RVMType.TIBType);
}
RVMType type = RVMType.TIBType;
if (VM.VerifyAssertions)
VM._assert(VM.runningVM);
TIB realTib = type.getTypeInformationBlock();
RVMArray fakeType = RVMType.WordArrayType;
TIB fakeTib = fakeType.getTypeInformationBlock();
int headerSize = ObjectModel.computeArrayHeaderSize(fakeType);
int align = ObjectModel.getAlignment(fakeType);
int offset = ObjectModel.getOffsetForAlignment(fakeType, false);
int width = fakeType.getLogElementSize();
int elemBytes = elements << width;
if (elemBytes < 0 || (elemBytes >>> width) != elements) {
/* asked to allocate more than Integer.MAX_VALUE bytes */
throwLargeArrayOutOfMemoryError();
}
int size = elemBytes + headerSize + AlignmentEncoding.padding(alignCode);
Selected.Mutator mutator = Selected.Mutator.get();
Address region = allocateSpace(mutator, size, align, offset, type.getMMAllocator(), Plan.DEFAULT_SITE);
region = AlignmentEncoding.adjustRegion(alignCode, region);
Object result = ObjectModel.initializeArray(region, fakeTib, elements, size);
mutator.postAlloc(ObjectReference.fromObject(result), ObjectReference.fromObject(fakeTib), size, type.getMMAllocator());
/* Now we replace the TIB */
ObjectModel.setTIB(result, realTib);
return (TIB) result;
}
use of org.vmmagic.pragma.NoInline in project JikesRVM by JikesRVM.
the class MemoryManager method newStack.
/**
* Allocate a stack
* @param bytes the number of bytes to allocate. Must be greater than
* 0.
* @return The stack
*/
@NoInline
@Unpreemptible
public static byte[] newStack(int bytes) {
if (bytes <= 0) {
if (VM.VerifyAssertions) {
VM.sysWrite("Invalid stack size: ");
VM.sysWrite(bytes);
VM.sysWriteln("!");
VM._assert(VM.NOT_REACHED, "Attempted to create stack with size (in bytes) of 0 or smaller!");
} else {
bytes = StackFrameLayout.getStackSizeNormal();
}
}
if (!VM.runningVM) {
return new byte[bytes];
} else {
RVMArray stackType = RVMArray.ByteArray;
int headerSize = ObjectModel.computeArrayHeaderSize(stackType);
int align = ObjectModel.getAlignment(stackType);
int offset = ObjectModel.getOffsetForAlignment(stackType, false);
int width = stackType.getLogElementSize();
TIB stackTib = stackType.getTypeInformationBlock();
return (byte[]) allocateArray(bytes, width, headerSize, stackTib, Plan.ALLOC_STACK, align, offset, Plan.DEFAULT_SITE);
}
}
use of org.vmmagic.pragma.NoInline in project JikesRVM by JikesRVM.
the class RuntimeEntrypoints method athrow.
// ---------------------------------------------------------------//
// Exception Handling. //
// ---------------------------------------------------------------//
/**
* Deliver a software exception to current java thread.
* @param exceptionObject exception object to deliver
* (null --> deliver NullPointerException).
* does not return
* (stack is unwound and execution resumes in a catch block)
*
* This method is public so that it can be invoked by java.lang.VMClass.
*/
@NoInline
@Entrypoint
@Unpreemptible("Deliver exception possibly from unpreemptible code")
public static void athrow(Throwable exceptionObject) {
if (traceAthrow) {
VM.sysWriteln("in athrow.");
RVMThread.dumpStack();
}
RVMThread myThread = RVMThread.getCurrentThread();
AbstractRegisters exceptionRegisters = myThread.getExceptionRegisters();
// VM.enableGC() is called when the exception is delivered.
VM.disableGC();
Magic.saveThreadState(exceptionRegisters);
exceptionRegisters.setInUse(true);
deliverException(exceptionObject, exceptionRegisters);
}
use of org.vmmagic.pragma.NoInline 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