TYPES
UZHandle: TYPE = LONG POINTER TO UZObject;
UZObject:
TYPE =
MACHINE
DEPENDENT
RECORD [
procs(0:0..31): LONG POINTER TO UZProcs
];
UZProcs:
TYPE =
MACHINE
DEPENDENT
RECORD [
new(0): PROC[self: UZHandle, size: CARDINAL] RETURNS[LONG POINTER],
free(1): PROC[self: UZHandle, object: LONG POINTER]
];
UNCOUNTED ZONES and their data
the permanentPageZone
ppzProcs: UZProcs ← [new: PPZNew, free: NIL];
ppzObject: UZObject ← [procs: @ppzProcs];
permanentPageZone:
PUBLIC
UNCOUNTED
ZONE ←
LOOPHOLE[
LONG[@ppzObject]];
permanentPageZone requires no ENTRY procs
permanentPageZone is ready for use
the systemUZone free list and rover
heapRoot: DoubleFreeHeader ← [
dummy entry; the "uncountedHeap" free list never has NIL ptrs
eh: [extendedSize: 0, normalHeader: [blockSizeIndex: Allocator.bsiEscape]],
nextFree: @heapRoot,
prevFree: @heapRoot
];
heapRover: Rover ← @heapRoot;
IMPLEMENTATION of permanentPageZone
Referenced only from permanentPageZone (its NEW proc)
PPZNew:
PROC[self: UZHandle, size:
CARDINAL]
RETURNS[lp:
LONG
POINTER] = {
nPages: INT = VM.PagesForWords[size];
lp ←
VM.AddressForPageNumber
[VM.Allocate[count: nPages, in64K: TRUE ! VM.CantAllocate => GOTO noVM].page];
EXITS noVM => ERROR InsufficientVM;
IMPLEMENTATION support for the systemUZone; here because these need their own monitor
Called only from AllocatorImpl.NewHeapObject.
size includes overhead, has been quantized and is >= SIZE[DoubleFreeHeader].
This proc may return an object of a larger size than requested.
Returns NIL if free list needs expansion.
CreateMediumSizedHeapObject:
PUBLIC
ENTRY
PROC[size:
NAT]
RETURNS[LONG POINTER] = {ENABLE UNWIND => NULL;
RETURN[
AllocatorOps.DoCreateMediumSizedObject[size, nonNullType, @heapRover, FALSE]];
};
Called only from ExpandDoubleFreeList and FreeHeapObject in AllocatorImpl.
Assume header is made
FreeMediumSizedHeapObject:
PUBLIC ENTRY
PROC[ptr: DFHeaderP] = {
ENABLE UNWIND => NULL;
AllocatorOps.DoFreeMediumSizedObject[ptr, heapRover];
};