
    <<Alloc.mesa>>
        <<Copyright © 1985 by Xerox Corporation.  All rights reserved.>>
        <<Sweet, 19-Aug-81 12:14:14>>
        <<Satterthwaite, June 10, 1986 3:02:18 pm PDT>>
        <<Rovner, September 19, 1983 9:36 pm>>
        <<Russ Atkinson (RRA) January 31, 1985 1:05:54 pm PST>>

    DIRECTORY
        VM: TYPE USING[wordsPerPage];

    Alloc: DEFINITIONS = {

        Selector: TYPE = CARDINAL;

        Base: TYPE = LONG ORDERED BASE POINTER;
        Index: TYPE = Base RELATIVE LONG POINTER;
        OrderedIndex: TYPE = Base RELATIVE LONG ORDERED POINTER;

        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: CARD];

    <<allocation from free list >>

        defaultChunkType: Selector = Selector.FIRST;

        GetChunk: PROC[h: Handle, size: CARDINAL, table: Selector_defaultChunkType] RETURNS[Index];
        FreeChunk: PROC[h: Handle, index: Index, size: CARDINAL, table: Selector_defaultChunkType];

    <<inquiries>>

        Bounds: PROC[h: Handle, table: Selector] RETURNS[base: Base, size: CARD];
        Top: PROC[h: Handle, table: Selector] RETURNS[OrderedIndex];
        Bias: PROC[h: Handle, table: Selector] RETURNS[CARD];

    <<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>>

        addrSpan: CARD = 1000000H;    -- 24 bits of address

        TableInfo: TYPE = RECORD[
            tag: [0..100H),            -- 8 bits of tag
            initialPages: CARDINAL, 
            maxPages: CARD_addrSpan/VM.wordsPerPage    -- and 24 bits of offset
            ];

        Create: PROC[weights: DESCRIPTOR FOR ARRAY OF TableInfo] RETURNS[Handle];
        Destroy: PROC[Handle];
        Reset: PROC[Handle];

        Chunkify: PROC[
            h: Handle, table: Selector_defaultChunkType,
            firstSmall: NAT_5, nSmall: NAT_4];
        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: CARD];

        }.

