Class ItableAllocator<T>
java.lang.Object
com.google.j2cl.transpiler.backend.wasm.ItableAllocator<T>
Assigns a field index in the itable for each interface.
Each interfaces implemented in the same class will have a different field indices, 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 most implemented interfaces. Each index in the itable instance will have the interface vtable 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.
-