InternalAlloc.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
Sweet, 19-Aug-81 12:14:14
Satterthwaite, October 11, 1985 4:57:53 pm PDT
Rovner, September 19, 1983 9:36 pm
Russ Atkinson (RRA) January 31, 1985 1:05:54 pm PST
Alloc:
DEFINITIONS = {
Selector:
TYPE =
CARDINAL;
Base: TYPE = LONG ORDERED BASE POINTER;
Limit: CARDINAL = CARDINAL.LAST;
Index: TYPE = Base RELATIVE POINTER [0..Limit);
OrderedIndex:
TYPE = Base
RELATIVE
ORDERED
POINTER [0..Limit);
Handle: TYPE = REF InstanceData;
InstanceData: TYPE;
allocation from the tables as stacks
Words: PROC[h: Handle, table: Selector, size: CARDINAL] RETURNS[OrderedIndex];
Trim: PROC[h: Handle, table: Selector, size: CARDINAL];
allocation from free list
defaultChunkType: Selector = Selector.FIRST;
GetChunk: PROC[h: Handle, size: CARDINAL, table: SelectorultChunkType] RETURNS[Index];
FreeChunk: PROC[h: Handle, index: Index, size: CARDINAL, table: SelectorultChunkType];
inquiries
Bounds: PROC[h: Handle, table: Selector] RETURNS[base: Base, size: CARDINAL];
Top:
PROC[h: Handle, table: Selector]
RETURNS[OrderedIndex] =
INLINE {
RETURN[OrderedIndex.FIRST + h.Bounds[table].size]};
inquiries and notification of moving subtables
BaseSeq: TYPE = RECORD[SEQUENCE length: NAT OF Base];
Notifier: TYPE = PROC[base: REF BaseSeq];
AddNotify: PROC[h: Handle, proc: Notifier];
DropNotify: PROC[h: Handle, proc: Notifier];
initialization and termination
maxForBits:
ARRAY [1..16]
OF
CARDINAL = [
1b, 3b, 7b, 17b, 37b, 77b, 177b, 377b,
777b, 1777b, 3777b, 7777b, 17777b, 37777b, 77777b, 177777b];
pagesForBits:
ARRAY [1..16]
OF
CARDINAL = [
1, 1, 1, 1, 1, 1, 1, 1,
2, 4, 8, 16, 32, 64, 128, 256];
defaultIndexBits: CARDINAL = 14;
defaultTileSize: CARDINAL = 8;
TableInfo:
TYPE =
RECORD[
initialPages: [0..377b],
indexBits: [0..16]ultIndexBits,
variant:
SELECT useFullVmem:
BOOL
FROM
FALSE => [initialVMemPages: [0..177b]],
TRUE => [],
ENDCASE ← TRUE[]];
Create:
PROC[
weights: DESCRIPTOR FOR ARRAY OF TableInfo, tileSize: CARDINALultTileSize]
RETURNS[Handle];
Destroy: PROC[Handle];
Reset: PROC[Handle];
Chunkify:
PROC[
h: Handle, table: SelectorultChunkType,
firstSmall: CARDINAL𡤃, nSmall: CARDINAL𡤄];
UnChunkify: PROC[h: Handle, table: Selector];
ResetChunk: PROC[h: Handle, table: Selector];
ResetTable: PROC[h: Handle, table: Selector, info: TableInfo];
Failure: ERROR[h: Handle, table: Selector];
Overflow: SIGNAL[h: Handle, table: Selector] RETURNS[extra: CARDINAL];
}.