Search in sources :

Example 11 with NoInline

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);
    }
}
Also used : Address(org.vmmagic.unboxed.Address) NoInline(org.vmmagic.pragma.NoInline)

Example 12 with NoInline

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;
}
Also used : Address(org.vmmagic.unboxed.Address) RVMArray(org.jikesrvm.classloader.RVMArray) RVMType(org.jikesrvm.classloader.RVMType) TIB(org.jikesrvm.objectmodel.TIB) Entrypoint(org.vmmagic.pragma.Entrypoint) Interruptible(org.vmmagic.pragma.Interruptible) NoInline(org.vmmagic.pragma.NoInline)

Example 13 with NoInline

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);
    }
}
Also used : RVMArray(org.jikesrvm.classloader.RVMArray) TIB(org.jikesrvm.objectmodel.TIB) Entrypoint(org.vmmagic.pragma.Entrypoint) Unpreemptible(org.vmmagic.pragma.Unpreemptible) NoInline(org.vmmagic.pragma.NoInline)

Example 14 with NoInline

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 --&gt; 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);
}
Also used : RVMThread(org.jikesrvm.scheduler.RVMThread) AbstractRegisters(org.jikesrvm.architecture.AbstractRegisters) Unpreemptible(org.vmmagic.pragma.Unpreemptible) Entrypoint(org.vmmagic.pragma.Entrypoint) NoInline(org.vmmagic.pragma.NoInline)

Example 15 with NoInline

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;
}
Also used : Address(org.vmmagic.unboxed.Address) AbstractRegisters(org.jikesrvm.architecture.AbstractRegisters) BaselineCompiledMethod(org.jikesrvm.compilers.baseline.BaselineCompiledMethod) CompiledMethod(org.jikesrvm.compilers.common.CompiledMethod) OptCompiledMethod(org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod) Uninterruptible(org.vmmagic.pragma.Uninterruptible) NoInline(org.vmmagic.pragma.NoInline)

Aggregations

NoInline (org.vmmagic.pragma.NoInline)46 Entrypoint (org.vmmagic.pragma.Entrypoint)23 Address (org.vmmagic.unboxed.Address)22 Unpreemptible (org.vmmagic.pragma.Unpreemptible)10 TIB (org.jikesrvm.objectmodel.TIB)9 Interruptible (org.vmmagic.pragma.Interruptible)9 RVMArray (org.jikesrvm.classloader.RVMArray)8 Word (org.vmmagic.unboxed.Word)6 NoOptCompile (org.vmmagic.pragma.NoOptCompile)5 Offset (org.vmmagic.unboxed.Offset)5 MethodReference (org.jikesrvm.classloader.MethodReference)4 CodeArray (org.jikesrvm.compilers.common.CodeArray)4 CompiledMethod (org.jikesrvm.compilers.common.CompiledMethod)4 AbstractRegisters (org.jikesrvm.architecture.AbstractRegisters)3 RVMMethod (org.jikesrvm.classloader.RVMMethod)3 BaselineCompiledMethod (org.jikesrvm.compilers.baseline.BaselineCompiledMethod)3 OptCompiledMethod (org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod)3 BaselineSaveLSRegisters (org.vmmagic.pragma.BaselineSaveLSRegisters)3 RVMType (org.jikesrvm.classloader.RVMType)2 RVMThread (org.jikesrvm.scheduler.RVMThread)2