Class ItableAllocator<T>
Each interface inheritance chain implemented in the same class will have a distinct field index, but across different parts of the hierarchy indices can be reused. This algorithm heuristically minimizes the size of the itable by trying to assign indices in order of interfaces with most implementors. Each index in the itable instance will have the interface vtable (for the most specific interface in the inheritance chain) for the class and can be used for both dynamic interface dispatch and interface "instanceof" checks.
This is a baseline implementation of "packed encoding" based on the algorithm described in section 4.3 of "Efficient type inclusion tests" by Vitek et al (OOPSLA 97). Although the ideas presented in the paper are for performing "instanceof" checks, they generalize to interface dispatch.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintgetItableFieldIndex(T type) Returns the field index for an interface, or -1 if the interface is not implemented by any class.intReturns the number of fields needed in the itable structures.
-
Constructor Details
-
ItableAllocator
-
-
Method Details
-
getItableSize
public int getItableSize()Returns the number of fields needed in the itable structures. -
getItableFieldIndex
Returns the field index for an interface, or -1 if the interface is not implemented by any class.
-