Search in sources :

Example 36 with Address

use of org.vmmagic.unboxed.Address 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 37 with Address

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

the class SpecializedScanMethod method scalar.

// All Scalars
public static void scalar(Object object, TransitiveClosure trace) {
    Address base = Magic.objectAsAddress(object);
    int[] offsets = ObjectModel.getObjectType(object).getReferenceOffsets();
    for (int i = 0; i < offsets.length; i++) {
        trace.processEdge(ObjectReference.fromObject(object), base.plus(offsets[i]));
    }
}
Also used : Address(org.vmmagic.unboxed.Address)

Example 38 with Address

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

the class JNIEnvironment method entryToJNI.

/**
 * Save data and perform necessary conversions for entry into JNI.
 * NB only used for Intel.
 *
 * @param encodedReferenceOffsets
 *          bit mask marking which elements on the stack hold objects that need
 *          encoding as JNI ref identifiers
 */
@Uninterruptible("Objects on the stack won't be recognized by GC, therefore don't allow GC")
@Entrypoint
public void entryToJNI(int encodedReferenceOffsets) {
    // Save processor
    savedTRreg = Magic.getThreadRegister();
    // Save frame pointer of calling routine, once so that native stack frames
    // are skipped and once for use by GC
    Address callersFP = Magic.getCallerFramePointer(Magic.getFramePointer());
    // NB old value saved on call stack
    basePointerOnEntryToNative = callersFP;
    JNITopJavaFP = callersFP;
    if (VM.traceJNI) {
        RVMMethod m = CompiledMethods.getCompiledMethod(Magic.getCompiledMethodID(callersFP)).getMethod();
        VM.sysWrite("calling JNI from ");
        VM.sysWrite(m.getDeclaringClass().getDescriptor());
        VM.sysWrite(" ");
        VM.sysWrite(m.getName());
        VM.sysWrite(m.getDescriptor());
        VM.sysWriteln();
    }
    // Save current JNI ref stack pointer
    if (JNIRefsTop > 0) {
        uninterruptiblePushJNIRef(Address.fromIntSignExtend(JNIRefsSavedFP), false);
        JNIRefsSavedFP = JNIRefsTop;
    }
    // Convert arguments on stack from objects to JNI references
    Address fp = Magic.getFramePointer();
    Offset argOffset = Offset.fromIntSignExtend(5 * BYTES_IN_ADDRESS);
    fp.store(uninterruptiblePushJNIRef(fp.loadAddress(argOffset), true), argOffset);
    while (encodedReferenceOffsets != 0) {
        argOffset = argOffset.plus(BYTES_IN_ADDRESS);
        if ((encodedReferenceOffsets & 1) != 0) {
            fp.store(uninterruptiblePushJNIRef(fp.loadAddress(argOffset), true), argOffset);
        }
        encodedReferenceOffsets >>>= 1;
    }
    // Transition processor from IN_JAVA to IN_JNI
    RVMThread.enterJNIFromCallIntoNative();
}
Also used : RVMMethod(org.jikesrvm.classloader.RVMMethod) Address(org.vmmagic.unboxed.Address) Offset(org.vmmagic.unboxed.Offset) Uninterruptible(org.vmmagic.pragma.Uninterruptible) Entrypoint(org.vmmagic.pragma.Entrypoint)

Example 39 with Address

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

the class ArchBridgeDataExtractor method setupArchitectureSpecificDynamicBridgeMapping.

@Override
protected final void setupArchitectureSpecificDynamicBridgeMapping(Address fp) {
    Address ip = Magic.getReturnAddressUnchecked(fp);
    fp = Magic.getCallerFramePointer(fp);
    int callingCompiledMethodId = Magic.getCompiledMethodID(fp);
    CompiledMethod callingCompiledMethod = CompiledMethods.getCompiledMethod(callingCompiledMethodId);
    Offset callingInstructionOffset = callingCompiledMethod.getInstructionOffset(ip);
    updateWithInfoForDynamicLink(callingCompiledMethod, callingInstructionOffset);
    if (dynamicLink.isInvokedWithImplicitThisParameter()) {
        // this + return addr
        bridgeSpilledParamInitialOffset = 2 * WORDSIZE;
    } else {
        // return addr
        bridgeSpilledParamInitialOffset = WORDSIZE;
    }
    bridgeSpilledParamInitialOffset += (bridgeTarget.getParameterWords() << LG_WORDSIZE);
    bridgeSpilledParameterMappingRequired = callingCompiledMethod.getCompilerType() != CompiledMethod.BASELINE;
}
Also used : Address(org.vmmagic.unboxed.Address) CompiledMethod(org.jikesrvm.compilers.common.CompiledMethod) Offset(org.vmmagic.unboxed.Offset)

Example 40 with Address

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

the class BaselineExceptionDeliverer method deliverException.

/**
 * Pass control to a catch block.
 */
@Override
@Unpreemptible("Deliver exception possibly from unpreemptible code")
public void deliverException(CompiledMethod compiledMethod, Address catchBlockInstructionAddress, Throwable exceptionObject, AbstractRegisters registers) {
    Address fp = registers.getInnermostFramePointer();
    RVMThread myThread = RVMThread.getCurrentThread();
    // reset sp to "empty expression stack" state
    // 
    Address sp = fp.plus(((ArchBaselineCompiledMethod) compiledMethod).getEmptyStackOffset());
    // push exception object as argument to catch block
    // 
    sp = sp.minus(BYTES_IN_ADDRESS);
    sp.store(Magic.objectAsAddress(exceptionObject));
    registers.getGPRs().set(SP.value(), sp.toWord());
    // set address at which to resume executing frame
    registers.setIP(catchBlockInstructionAddress);
    // branch to catch block
    // 
    // disabled right before RuntimeEntrypoints.deliverException was called
    VM.enableGC();
    if (VM.VerifyAssertions)
        VM._assert(registers.getInUse());
    registers.setInUse(false);
    // 'give back' the portion of the stack we borrowed to run
    // exception delivery code when invoked for a hardware trap.
    // If this was a straight software trap (athrow) then setting
    // the stacklimit should be harmless, since the stacklimit should already have exactly
    // the value we are setting it too.
    myThread.stackLimit = Magic.objectAsAddress(myThread.getStack()).plus(STACK_SIZE_GUARD);
    Magic.restoreHardwareExceptionState(registers);
    if (VM.VerifyAssertions)
        VM._assert(NOT_REACHED);
}
Also used : Address(org.vmmagic.unboxed.Address) RVMThread(org.jikesrvm.scheduler.RVMThread) Unpreemptible(org.vmmagic.pragma.Unpreemptible)

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