next up previous contents
Next: Generated code Up: Objects Previous: Memory storage of objects

The Virtual Method Table

  The Virtual Method Table (VMT) for each object type consists of 2 check fields (containing the size of the data), a pointer to the object's anchestor's VMT (Nil if there is no anchestor), and then the pointers to all virtual methods. The VMT layout is illustrated in table (5.2).

The VMT is constructed by the compiler. Every instance of an object receives a pointer to its VMT.

  

Offset What
+0 Size of object type data
+4 Minus the size of object type data. Enables determining of valid VMT pointers.
+8 Pointer to ancestor VMT, Nil if no ancestor available.
+12 Pointers to the virtual methods.
...
Table 5.2: Virtual Method Table memory layout



Michael Van Canneyt
Thu Sep 10 14:04:11 CEST 1998