Search in sources :

Example 26 with TIB

use of org.jikesrvm.objectmodel.TIB in project JikesRVM by JikesRVM.

the class InterfaceInvocation method buildITable.

private static ITable buildITable(RVMClass C, RVMClass I) {
    RVMMethod[] interfaceMethods = I.getDeclaredMethods();
    TIB tib = C.getTypeInformationBlock();
    ITable iTable = MemoryManager.newITable(interfaceMethods.length + 1);
    iTable.set(0, I);
    for (RVMMethod im : interfaceMethods) {
        if (im.isClassInitializer())
            continue;
        if (VM.VerifyAssertions)
            VM._assert(im.isPublic() && im.isAbstract());
        RVMMethod vm = C.findVirtualMethod(im.getName(), im.getDescriptor());
        // Since the methods in question take no arguments, we can get away with this.
        if (vm == null || vm.isAbstract()) {
            vm = Entrypoints.raiseAbstractMethodError;
        } else if (!vm.isPublic()) {
            vm = Entrypoints.raiseIllegalAccessError;
        }
        if (vm.isStatic()) {
            vm.compile();
            iTable.set(getITableIndex(I, im.getName(), im.getDescriptor()), vm.getCurrentEntryCodeArray());
        } else {
            iTable.set(getITableIndex(I, im.getName(), im.getDescriptor()), tib.getVirtualMethod(vm.getOffset()));
        }
    }
    return iTable;
}
Also used : ITable(org.jikesrvm.objectmodel.ITable) TIB(org.jikesrvm.objectmodel.TIB)

Example 27 with TIB

use of org.jikesrvm.objectmodel.TIB in project JikesRVM by JikesRVM.

the class InterfaceInvocation method invokeInterface.

/*
   * PART I: runtime routines to implement the invokeinterface bytecode.
   *         these routines are called from the generated code
   *         as part of the interface invocation sequence.
   */
/**
 * Resolve an interface method call.
 * This routine is never called by the IMT-based dispatching code.
 * It is only called for directly indexed ITables when the table
 * index was unknown at compile time (i.e. the target Interface was not loaded).
 *
 * @param target object to which interface method is to be applied
 * @param mid id of the MemberReference for the target interface method.
 * @return machine code corresponding to desired interface method
 */
@Entrypoint
public static CodeArray invokeInterface(Object target, int mid) throws IncompatibleClassChangeError {
    MethodReference mref = MemberReference.getMemberRef(mid).asMethodReference();
    RVMMethod sought = mref.resolveInterfaceMethod();
    RVMClass I = sought.getDeclaringClass();
    RVMClass C = Magic.getObjectType(target).asClass();
    if (VM.BuildForITableInterfaceInvocation) {
        TIB tib = C.getTypeInformationBlock();
        ITable iTable = findITable(tib, I.getInterfaceId());
        return iTable.getCode(getITableIndex(I, mref.getName(), mref.getDescriptor()));
    } else {
        if (!RuntimeEntrypoints.isAssignableWith(I, C))
            throw new IncompatibleClassChangeError();
        RVMMethod found = C.findVirtualMethod(sought.getName(), sought.getDescriptor());
        if (found == null)
            throw new IncompatibleClassChangeError();
        return found.getCurrentEntryCodeArray();
    }
}
Also used : ITable(org.jikesrvm.objectmodel.ITable) TIB(org.jikesrvm.objectmodel.TIB) Entrypoint(org.vmmagic.pragma.Entrypoint)

Example 28 with TIB

use of org.jikesrvm.objectmodel.TIB in project JikesRVM by JikesRVM.

the class DebugUtil method validRef.

@Uninterruptible
public static boolean validRef(ObjectReference ref) {
    if (ref.isNull())
        return true;
    if (!Space.isMappedObject(ref)) {
        VM.sysWrite("validRef: REF outside heap, ref = ");
        VM.sysWrite(ref);
        VM.sysWriteln();
        Space.printVMMap();
        return false;
    }
    if (MOVES_OBJECTS) {
    /*
      TODO: Work out how to check if forwarded
      if (Plan.isForwardedOrBeingForwarded(ref)) {
        // TODO: actually follow forwarding pointer
        // (need to bound recursion when things are broken!!)
        return true;
      }
      */
    }
    TIB tib = ObjectModel.getTIB(ref);
    Address tibAddr = Magic.objectAsAddress(tib);
    if (!Space.isMappedObject(ObjectReference.fromObject(tib))) {
        VM.sysWrite("validRef: TIB outside heap, ref = ");
        VM.sysWrite(ref);
        VM.sysWrite(" tib = ");
        VM.sysWrite(tibAddr);
        VM.sysWriteln();
        ObjectModel.dumpHeader(ref);
        return false;
    }
    if (tibAddr.isZero()) {
        VM.sysWrite("validRef: TIB is Zero! ");
        VM.sysWrite(ref);
        VM.sysWriteln();
        ObjectModel.dumpHeader(ref);
        return false;
    }
    if (tib.length() == 0) {
        VM.sysWrite("validRef: TIB length zero, ref = ");
        VM.sysWrite(ref);
        VM.sysWrite(" tib = ");
        VM.sysWrite(tibAddr);
        VM.sysWriteln();
        ObjectModel.dumpHeader(ref);
        return false;
    }
    ObjectReference type = ObjectReference.fromObject(tib.getType());
    if (!validType(type)) {
        VM.sysWrite("validRef: invalid TYPE, ref = ");
        VM.sysWrite(ref);
        VM.sysWrite(" tib = ");
        VM.sysWrite(Magic.objectAsAddress(tib));
        VM.sysWrite(" type = ");
        VM.sysWrite(type);
        VM.sysWriteln();
        ObjectModel.dumpHeader(ref);
        return false;
    }
    return true;
}
Also used : Address(org.vmmagic.unboxed.Address) ObjectReference(org.vmmagic.unboxed.ObjectReference) TIB(org.jikesrvm.objectmodel.TIB) Uninterruptible(org.vmmagic.pragma.Uninterruptible)

Example 29 with TIB

use of org.jikesrvm.objectmodel.TIB in project JikesRVM by JikesRVM.

the class MemoryManager method newNonMovingShortArray.

/**
 * Allocates a non moving short array.
 *
 * @param size The size of the array
 * @return the new non moving short array
 */
@NoInline
@Interruptible
public static short[] newNonMovingShortArray(int size) {
    if (!VM.runningVM) {
        return new short[size];
    }
    RVMArray arrayType = RVMArray.ShortArray;
    int headerSize = ObjectModel.computeArrayHeaderSize(arrayType);
    int align = ObjectModel.getAlignment(arrayType);
    int offset = ObjectModel.getOffsetForAlignment(arrayType, false);
    int width = arrayType.getLogElementSize();
    TIB arrayTib = arrayType.getTypeInformationBlock();
    return (short[]) allocateArray(size, width, headerSize, arrayTib, Plan.ALLOC_NON_MOVING, align, offset, Plan.DEFAULT_SITE);
}
Also used : RVMArray(org.jikesrvm.classloader.RVMArray) TIB(org.jikesrvm.objectmodel.TIB) Entrypoint(org.vmmagic.pragma.Entrypoint) Interruptible(org.vmmagic.pragma.Interruptible) NoInline(org.vmmagic.pragma.NoInline)

Example 30 with TIB

use of org.jikesrvm.objectmodel.TIB in project JikesRVM by JikesRVM.

the class MemoryManager method allocateCode.

/**
 * Allocate a CodeArray into a code space.
 * Currently the interface is fairly primitive;
 * just the number of instructions in the code array and a boolean
 * to indicate hot or cold code.
 * @param numInstrs number of instructions
 * @param isHot is this a request for hot code space allocation?
 * @return The  array
 */
@NoInline
@Interruptible
public static CodeArray allocateCode(int numInstrs, boolean isHot) {
    RVMArray type = RVMType.CodeArrayType;
    int headerSize = ObjectModel.computeArrayHeaderSize(type);
    int align = ObjectModel.getAlignment(type);
    int offset = ObjectModel.getOffsetForAlignment(type, false);
    int width = type.getLogElementSize();
    TIB tib = type.getTypeInformationBlock();
    int allocator = isHot ? Plan.ALLOC_HOT_CODE : Plan.ALLOC_COLD_CODE;
    return (CodeArray) allocateArray(numInstrs, width, headerSize, tib, allocator, align, offset, Plan.DEFAULT_SITE);
}
Also used : CodeArray(org.jikesrvm.compilers.common.CodeArray) RVMArray(org.jikesrvm.classloader.RVMArray) TIB(org.jikesrvm.objectmodel.TIB) Entrypoint(org.vmmagic.pragma.Entrypoint) Interruptible(org.vmmagic.pragma.Interruptible) NoInline(org.vmmagic.pragma.NoInline)

Aggregations

TIB (org.jikesrvm.objectmodel.TIB)36 Entrypoint (org.vmmagic.pragma.Entrypoint)16 RVMArray (org.jikesrvm.classloader.RVMArray)14 RVMType (org.jikesrvm.classloader.RVMType)13 NoInline (org.vmmagic.pragma.NoInline)9 Interruptible (org.vmmagic.pragma.Interruptible)8 Address (org.vmmagic.unboxed.Address)7 Test (org.junit.Test)5 CodeArray (org.jikesrvm.compilers.common.CodeArray)4 ITable (org.jikesrvm.objectmodel.ITable)4 RVMClass (org.jikesrvm.classloader.RVMClass)3 RVMMethod (org.jikesrvm.classloader.RVMMethod)3 Offset (org.vmmagic.unboxed.Offset)3 CompiledMethod (org.jikesrvm.compilers.common.CompiledMethod)2 IMT (org.jikesrvm.objectmodel.IMT)2 ITableArray (org.jikesrvm.objectmodel.ITableArray)2 Inline (org.vmmagic.pragma.Inline)2 BufferedOutputStream (java.io.BufferedOutputStream)1 FileOutputStream (java.io.FileOutputStream)1 PrintStream (java.io.PrintStream)1