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

Constructor and Destructor calls

  When using objects that need virtual methods, the compiler uses two help procedures that are in the run-time library. They are called Help_Destructor and Help_Constructor, and they are written in assembly language. They are used to allocate the necessary memory if needed, and to insert the Virtual Method Table (VMT) pointer in the newly allocated object.

When the compiler encounters a call to an object's constructor, it sets up the stack frame for the call, and inserts a call to the Help_Constructor procedure before issuing the call to the real constructor. The helper procedure allocates the needed memory (if needed) and inserts the VMT pointer in the object. After that, the real constructor is called.

A call to Help_Destructor is inserted in every destructor declaration, just before the destructor's exit sequence.



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