In order to make persistence transparent, it is necessary
to over-ride the built in heap mechanism of Pascal.
Syntactically the interface to the Pascal heap is provided
by two `procedures': new, and dispose.
These differ from other procedures in not being
strictly type checked. One can pass to new a pointer to
any type, and it will create a new instance of the type.
This violation of the type rules is an indication that these
procedures are not what they seem to be. In fact they
are not procedures at all, but a piece of `procedure like'
disguising what the compiler really generates.

A moments thought will reveal that for new to work it
really requires two parameters: a var parameter for the pointer
to be returned and a second hidden parameter specifying either
the size or the type of the object being created. The Borland
Pascal compiler makes the underlying procedure directly available
as:

procedure GetMem(var P: Pointer; Size: Word);

In this form it is useful for creating arrays on the
heap whose size is not known until run time.
Dispose is similarly translated by the compiler
into a call on FreeMem.

During its startup sequence the persistence manager replaces
the first instruction of GetMem with a jump
to its own store allocator. The first instruction of
FreeMem is replaced with a return instruction, since
in a system with a garbage collector, freeing memory is
a null action.

The extended syntax that is used with
constructors new(p,init(a,b,...))
is translated by the compiler directly into a call on the
user declared
constructor init.
At the start of the constructor method the compiler plants
a call to another store allocation routine
, call it PrivateAlloc, which, instead
of being passed the objects size, is passed its
VMT offset. Since the first word in a
VMT always contains the size of the object, this provides
sufficient information to create the object.

The persistence manager patches PrivateAlloc to branch
to an allocation routine that searches the list of persistent
classes for the one with the appropriate VMT and then
allocates an object from the private heap of that class.
For this to function, the class list must have been updated
to have entries for all persistent classes. Thus as
part of its initialisation sequence, the persistence manager
searches the data segment for VMTs and registers all the
persistent classes whose VMTs it finds.