Search in sources :

Example 1 with ITableArray

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

the class InterfaceInvocation method installITable.

private static void installITable(RVMClass C, RVMClass I) {
    TIB tib = C.getTypeInformationBlock();
    ITableArray iTables = tib.getITableArray();
    if (iTables == null) {
        iTables = MemoryManager.newITableArray(2);
        tib.setITableArray(iTables);
    } else {
        for (int i = 0; i < iTables.length(); i++) {
            if (iTables.get(i).isFor(I)) {
                // some other thread just built the iTable
                return;
            }
        }
        ITableArray tmp = MemoryManager.newITableArray(iTables.length() + 1);
        for (int i = 0; i < iTables.length(); i++) {
            tmp.set(i, iTables.get(i));
        }
        iTables = tmp;
        tib.setITableArray(iTables);
    }
    if (VM.VerifyAssertions)
        VM._assert(iTables.get(iTables.length() - 1) == null);
    ITable iTable = buildITable(C, I);
    iTables.set(iTables.length() - 1, iTable);
    // iTables[0] is a move to front cache; fill it here so we can
    // assume it always contains some iTable.
    iTables.set(0, iTable);
}
Also used : ITableArray(org.jikesrvm.objectmodel.ITableArray) ITable(org.jikesrvm.objectmodel.ITable) TIB(org.jikesrvm.objectmodel.TIB) Entrypoint(org.vmmagic.pragma.Entrypoint)

Example 2 with ITableArray

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

the class InterfaceInvocation method updateTIBEntry.

/**
 * If there is an an IMT or ITable entry that contains
 * compiled code for the argument method, then update it to
 * contain the current compiled code for the method.
 *
 * @param klass the RVMClass who's IMT/ITable is being reset
 * @param m the method that needs to be updated.
 */
public static void updateTIBEntry(RVMClass klass, RVMMethod m) {
    TIB tib = klass.getTypeInformationBlock();
    if (VM.BuildForIMTInterfaceInvocation) {
        RVMMethod[] map = klass.noIMTConflictMap;
        if (map != null) {
            for (int i = 0; i < IMT_METHOD_SLOTS; i++) {
                if (map[i] == m) {
                    IMT imt = tib.getImt();
                    imt.set(i, m.getCurrentEntryCodeArray());
                    // all done -- a method is in at most 1 IMT slot
                    return;
                }
            }
        }
    } else if (VM.BuildForITableInterfaceInvocation) {
        if (tib.getITableArray() != null) {
            ITableArray iTables = tib.getITableArray();
            Atom name = m.getName();
            Atom desc = m.getDescriptor();
            for (int i = 0; i < iTables.length(); i++) {
                ITable iTable = iTables.get(i);
                if (iTable != null) {
                    RVMClass I = iTable.getInterfaceClass();
                    RVMMethod[] interfaceMethods = I.getDeclaredMethods();
                    for (RVMMethod im : interfaceMethods) {
                        if (im.getName() == name && im.getDescriptor() == desc) {
                            iTable.set(getITableIndex(I, name, desc), m.getCurrentEntryCodeArray());
                        }
                    }
                }
            }
        }
    }
}
Also used : IMT(org.jikesrvm.objectmodel.IMT) ITableArray(org.jikesrvm.objectmodel.ITableArray) ITable(org.jikesrvm.objectmodel.ITable) TIB(org.jikesrvm.objectmodel.TIB) Entrypoint(org.vmmagic.pragma.Entrypoint)

Example 3 with ITableArray

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

the class InterfaceInvocation method findITable.

/**
 * Return a reference to the itable for a given class, interface pair
 * We might not have created the iTable yet, in which case we will do that and then return it.
 *
 * @param tib the TIB for the class
 * @param id interface id of the interface sought (NOT dictionary id!!)
 * @return iTable for desired interface
 */
@Entrypoint
public static ITable findITable(TIB tib, int id) throws IncompatibleClassChangeError {
    ITableArray iTables = tib.getITableArray();
    // Search for the right ITable
    RVMType I = RVMClass.getInterface(id);
    if (iTables != null) {
        // check the cache at slot 0
        ITable iTable = iTables.get(0);
        if (iTable.isFor(I)) {
            // cache hit :)
            return iTable;
        }
        // Have to search the 'real' entries for the iTable
        for (int i = 1; i < iTables.length(); i++) {
            iTable = iTables.get(i);
            if (iTable.isFor(I)) {
                // found it; update cache
                iTables.set(0, iTable);
                return iTable;
            }
        }
    }
    // Didn't find the itable, so we don't yet know if
    // the class implements the interface. :(((
    // Therefore, we need to establish that and then
    // look for the iTable again.
    RVMClass C = (RVMClass) tib.getType();
    if (!RuntimeEntrypoints.isAssignableWith(I, C))
        throw new IncompatibleClassChangeError();
    synchronized (C) {
        installITable(C, (RVMClass) I);
    }
    ITable iTable = findITable(tib, id);
    if (VM.VerifyAssertions)
        VM._assert(iTable != null);
    return iTable;
}
Also used : ITableArray(org.jikesrvm.objectmodel.ITableArray) ITable(org.jikesrvm.objectmodel.ITable) Entrypoint(org.vmmagic.pragma.Entrypoint) Entrypoint(org.vmmagic.pragma.Entrypoint)

Aggregations

ITable (org.jikesrvm.objectmodel.ITable)3 ITableArray (org.jikesrvm.objectmodel.ITableArray)3 Entrypoint (org.vmmagic.pragma.Entrypoint)3 TIB (org.jikesrvm.objectmodel.TIB)2 IMT (org.jikesrvm.objectmodel.IMT)1