Store records can be moved in memory by the operating system, when the store is inactive. To compensate for this, as mentioned in the previous section, pointers need to be updated. This requires the VM to be able to tell the difference between a pointer and scalar data at any point where a pointer adjustment may take place. Otherwise, say, an int could be misinterpreted as a pointer and would thus be modified after an object (or a record) was moved in memory - leading at best to an erroneous computation.
Being able to tell exactly which values are pointers and which are scalars is referred to as exactness or type accuracy. It can be achieved by:
The Spotless VM's memory management identifies a heap cell's type by analyzing the class of the object that the cell belongs to. Thus an object's class stores which fields contain pointer data and which scaler data. To identify a stack cell's type, the VM keeps a parallel stack containing the required type information. The secondary stack is called a tag stack, as it keeps a tag corresponding to each stack value and whither its a pointer or not. Each time the execution stack is modified, the tag stack is updated accordingly.
The garbage collector consists of a mark-sweep algorithm with sliding compaction that uses a break table to update pointers to moved objects [Jones and Lins, 1996]. Although this algorithm is relatively slow, it has two crucial advantages:
The current garbage collection algorithm does not move objects between heap segments. Although it is a compacting collector, this means there is still some fragmentation. Furthermore, when a computation is suspended, the VM will almost never find an empty segment that could be returned to the operating system. We have considered alterations to the algorithm to make it ``multi-segmented'', but would suggest that later implementations should instead take advantage of the segmentation and implement a generational collector.