Heap Objects Stable Storage
4.3.3. S Abstract data types
word 2 a pointer to the type descriptor word 3. .n the remaining pointer fields word n+1 .m the nonpointer fields
word m.. the type keys for the witness types and constancy bitmap
Note that all fields of witness types are implemented as polymorphic objects. Therefore each is assigned space for a double length scalar and double length pointer object. This allows the calculation of field addresses to be performed statically. The dynamic type information of the witness types is stored in the last scalar fields of the object. The implementation of A.D.T. S is described fully in section 5.3.10.
4.3.3 9 The Root Object
In the PS-algol machine the standard frame became a major obstacle to change. Revisions of the standard frame meant that programs compiled with the old version were no longer executable because offsets into the old frame had been hard wired into the code.
Many of the functions in the PS-algol standard frame were not primitive machine instructions. One example of this is the Iwb function which returns the lower bound of a vector. This function is implemented in the machine implementation language in the PS- algol system.
In PAM, most of the functions which were implemented in implementation language in the PS-algol machine have been replaced with short sequences of abstract machine code These functions are known as primitive instructions. Functions, like Iwb, may easily be implemented in this way, resulting in a simpler underlying machine.
Not all functions may be implemented in this way. Some functions like sin are true primitive machine operations. These have been implemented as abstract machine instructions in the Persistent Abstract Machine. Using these techniques we have removed the need for a standard frame. A fixed point is still needed in the machine -this is provided by the root object. The root object provides a set of known addresses in PAM. There is one root object per machine invocation. It contains literal values such as nil, pi, nullimage and maxint. A pointer to a vector of single character strings is included in the root object. This was an optimisation first used in the S-algol abstract machine to lessen heap fragmentation and speed up string manipulation.
The root object also contains some procedures used by the machine. These include the startup procedure which is run when the machine is invoked. A type checking procedure that checks if two type representations are the same is also stored here.
A pointer to a vector of error processing procedures that are called when hard errors occur in the machine and a pointer to the vector of event handlers are also included in the root object. These procedures are ordinary procedures written in Napier. A set of special functions, written in PAIL, are provided for assigning values and retrieving values from these locations.
word 2 the pointer literal nil
word 3 the code vector for the startup procedure word 4 the static link for the startup procedure word 5 the logical root of persistence
word 6 the file literal nullfile word 7 the string literal ""
word 8 a pointer to the vector of all 128 single character strings word 9 the image literal nullimage
word 10 the code vector for the error processing procedure word 11 the static link for the error processing procedure word 12 a pointer to the vector of event handling procedures word 13 a pointer to the vector of error handling procedures word 14 a pointer to the vector of open files
word 15 a pointer to the frame of the currently executing procedure word 16 the code vector for the type checking procedure
word 17 the static link for the type checking procedure
word 18 a pointer location for use in comparing variants, nil if not in use word 19 a pointer location for use in comparing variants, nil if not in use word 20 a pointer location for use in comparing variants, nil if not in use word 21 a pointer location for use in coniparing variants, nil if not in use word 22 the error number for the last 1/0 instmction executed
word 23 the integer literal maxint word 24,25 the real literal maxreal word 26,27 the real literal pi word 28,29 the real literal epsilon 4.3.4 Stable Storage
Stable storage in the persistent abstract machine is provided by the object management module. This module is a module within the abstract machine and implements the heap. The heap is the top layer of a hierarchy of levels that implements the persistent store. The heap interface consists of eight functions. These are the only functions which deal with object management and operate on basic object formats. That is, they can only determine the size of objects and how many pointers they have.
1. Initialise_Heap 2. Shutdown_Heap 3. Create_Object 4. Destroy_Object 5. Hlegal„Address 6. Root_Object 7. Stabilise_Heap 8. Garbage_Collect
The functions Initialise_Heap and Shutdown_Heap are used to initialise and shutdown the persistent store.
Create_Object is the only mechanism provided in the system for object creation. All high level functions that create objects therefore use this function.
The function Root_Object returns a pointer to the root object. Illegal_Address is the function that translates pids into Ions, both these functions have already been discussed.
The function Destroy_Object is provided as an optimisation tool. In certain cases the code generator can detect statically when an object is no longer reachable. This system may be used to release space used by these objects. This function is particularly useful for optimising recursive function calls. The usual way of reclaiming space is by calling the garbage collector. This is usually called when a Create_Object fails.
The function Stabilise_Heap causes all new and changed objects to be copied to stable storage. This also causes the store to checkpoint itself causing the store to move into a stable state. A fatal failure in the system such as power loss causes any data changed or modified since the last stabilise to be lost, but data changed or modified before the last stabilise will be retained. Stabilise_Heap is an atomic operation.