UnsafeAllocatorImpl.Mesa
last edited November 9, 1983 8:33 am by Paul Rovner
DIRECTORY
Allocator USING[bsiEscape],
AllocatorOps USING[DoubleFreeHeader, Rover, DFHeaderP, DoCreateMediumSizedObject, DoFreeMediumSizedObject, nonNullType],
VM USING[PagesForWords, AddressForPageNumber, Allocate, CantAllocate];
UnsafeAllocatorImpl: MONITOR
protects the systemUZone free list and rover. Procs herein are simply entry procs that call back into AllocatorImpl.
IMPORTS AllocatorOps, VM
EXPORTS AllocatorOps
= BEGIN OPEN AllocatorOps;
ERRORS
InsufficientVM: ERROR = CODE;
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 ZONELOOPHOLE[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];
};
END.