org.jikesrvm.classloader
Class InterfaceInvocation

java.lang.Object
  extended by org.jikesrvm.classloader.InterfaceInvocation
All Implemented Interfaces:
TIBLayoutConstants, SizeConstants

public class InterfaceInvocation
extends Object
implements TIBLayoutConstants, SizeConstants

Runtime system mechanisms and data structures to implement interface invocation.

We support two mechanisms:

   IMT-based (Alpern, Cocchi, Fink, Grove, and Lieber OOPSLA'01).
   ITable-based (searched at dispatch time with 1 entry move-to-front cache)
 


Nested Class Summary
private static class InterfaceInvocation.IMTDict
           
 
Field Summary
 
Fields inherited from interface org.jikesrvm.objectmodel.TIBLayoutConstants
IMT_METHOD_SLOTS, NEEDS_DYNAMIC_LINK, TIB_ARRAY_ELEMENT_TIB_INDEX, TIB_DOES_IMPLEMENT_INDEX, TIB_FIRST_SPECIALIZED_METHOD_INDEX, TIB_FIRST_VIRTUAL_METHOD_INDEX, TIB_INTERFACE_DISPATCH_TABLE_INDEX, TIB_SUPERCLASS_IDS_INDEX, TIB_TYPE_INDEX
 
Fields inherited from interface org.jikesrvm.SizeConstants
BITS_IN_ADDRESS, BITS_IN_BOOLEAN, BITS_IN_BYTE, BITS_IN_CHAR, BITS_IN_DOUBLE, BITS_IN_EXTENT, BITS_IN_FLOAT, BITS_IN_INT, BITS_IN_LONG, BITS_IN_OFFSET, BITS_IN_PAGE, BITS_IN_SHORT, BITS_IN_WORD, BYTES_IN_ADDRESS, BYTES_IN_BOOLEAN, BYTES_IN_BYTE, BYTES_IN_CHAR, BYTES_IN_DOUBLE, BYTES_IN_EXTENT, BYTES_IN_FLOAT, BYTES_IN_INT, BYTES_IN_LONG, BYTES_IN_OFFSET, BYTES_IN_PAGE, BYTES_IN_SHORT, BYTES_IN_WORD, LOG_BITS_IN_ADDRESS, LOG_BITS_IN_BOOLEAN, LOG_BITS_IN_BYTE, LOG_BITS_IN_CHAR, LOG_BITS_IN_DOUBLE, LOG_BITS_IN_EXTENT, LOG_BITS_IN_FLOAT, LOG_BITS_IN_INT, LOG_BITS_IN_LONG, LOG_BITS_IN_OFFSET, LOG_BITS_IN_PAGE, LOG_BITS_IN_SHORT, LOG_BITS_IN_WORD, LOG_BYTES_IN_ADDRESS, LOG_BYTES_IN_BOOLEAN, LOG_BYTES_IN_BYTE, LOG_BYTES_IN_CHAR, LOG_BYTES_IN_DOUBLE, LOG_BYTES_IN_EXTENT, LOG_BYTES_IN_FLOAT, LOG_BYTES_IN_INT, LOG_BYTES_IN_LONG, LOG_BYTES_IN_OFFSET, LOG_BYTES_IN_PAGE, LOG_BYTES_IN_SHORT, LOG_BYTES_IN_WORD
 
Constructor Summary
InterfaceInvocation()
           
 
Method Summary
private static InterfaceInvocation.IMTDict buildIMTDict(RVMClass klass, RVMClass[] interfaces)
          Build up a description of the IMT contents for the given class.
private static ITable buildITable(RVMClass C, RVMClass I)
          Build a single ITable for the pair of class C and interface I
static ITable findITable(TIB tib, int id)
          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.
static int getITableIndex(RVMClass klass, Atom mname, Atom mdesc)
          Return the index of the interface method m in the itable
static void initializeDispatchStructures(RVMClass klass)
          Main entrypoint called from RVMClass.instantiate to initialize the interface dispatching data structures for the given class.
private static void installITable(RVMClass C, RVMClass I)
          Build and install an iTable for the given class interface pair (used for iTable miss on searched iTables).
static ArchitectureSpecific.CodeArray invokeInterface(Object target, int mid)
          Resolve an interface method call.
private static void populateIMT(RVMClass klass, InterfaceInvocation.IMTDict d)
          Populate an indirect IMT for C using the IMTDict d
static void unresolvedInvokeinterfaceImplementsTest(int mid, Object rhsObject)
          mid is the dictionary id of an interface method we are trying to invoke RHStib is the TIB of an object on which we are attempting to invoke it.
static void updateTIBEntry(RVMClass klass, RVMMethod m)
          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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InterfaceInvocation

public InterfaceInvocation()
Method Detail

invokeInterface

public static ArchitectureSpecific.CodeArray invokeInterface(Object target,
                                                             int mid)
                                                      throws IncompatibleClassChangeError
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).

Parameters:
target - object to which interface method is to be applied
mid - id of the MemberReference for the target interface method.
Returns:
machine code corresponding to desired interface method
Throws:
IncompatibleClassChangeError

findITable

public static ITable findITable(TIB tib,
                                int id)
                         throws IncompatibleClassChangeError
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.

Parameters:
tib - the TIB for the class
id - interface id of the interface sought (NOT dictionary id!!)
Returns:
iTable for desired interface
Throws:
IncompatibleClassChangeError

unresolvedInvokeinterfaceImplementsTest

public static void unresolvedInvokeinterfaceImplementsTest(int mid,
                                                           Object rhsObject)
                                                    throws IncompatibleClassChangeError
mid is the dictionary id of an interface method we are trying to invoke RHStib is the TIB of an object on which we are attempting to invoke it. We were unable to resolve the member reference at compile time. Therefore we must resolve it now and then call invokeinterfaceImplementsTest with the right LHSclass.

Parameters:
mid - Dictionary id of the MemberReference for the target interface method.
rhsObject - The object on which we are attempting to invoke the interface method
Throws:
IncompatibleClassChangeError

initializeDispatchStructures

public static void initializeDispatchStructures(RVMClass klass)
Main entrypoint called from RVMClass.instantiate to initialize the interface dispatching data structures for the given class.

Parameters:
klass - the RVMClass to initialize the dispatch structures for.

buildIMTDict

private static InterfaceInvocation.IMTDict buildIMTDict(RVMClass klass,
                                                        RVMClass[] interfaces)
Build up a description of the IMT contents for the given class. NOTE: this structure is only used during class loading, so we don't have to worry about making it space efficient.

Parameters:
klass - the RVMClass whose IMT we are going to build.
Returns:
an IMTDict that describes the IMT we need to build for the class.

populateIMT

private static void populateIMT(RVMClass klass,
                                InterfaceInvocation.IMTDict d)
Populate an indirect IMT for C using the IMTDict d


installITable

private static void installITable(RVMClass C,
                                  RVMClass I)
Build and install an iTable for the given class interface pair (used for iTable miss on searched iTables).


buildITable

private static ITable buildITable(RVMClass C,
                                  RVMClass I)
Build a single ITable for the pair of class C and interface I


getITableIndex

public static int getITableIndex(RVMClass klass,
                                 Atom mname,
                                 Atom mdesc)
Return the index of the interface method m in the itable


updateTIBEntry

public static void updateTIBEntry(RVMClass klass,
                                  RVMMethod m)
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.

Parameters:
klass - the RVMClass who's IMT/ITable is being reset
m - the method that needs to be updated.