-- NewReadRTNumbers.mesa -- last edit February 25, 1983 1:06 pm Sturgis DIRECTORY IO USING[char, CR, int, Put, rope, STREAM], RTMicrocode USING[RTMOVESTATUS], RTRefCounts USING[GCState], UserExec USING[CommandProc, GetStreams, RegisterCommand]; NewReadRTNumbers: PROGRAM IMPORTS IO, RTMicrocode, RTRefCounts, UserExec = BEGIN HTArray: TYPE = ARRAY[0..77777b] OF INTEGER; Read: PROCEDURE RETURNS[nHTEmpty: INTEGER, nHTEntries: INTEGER, nHTChains: INTEGER, nFreeOE: INTEGER] = BEGIN theHTArray: LONG POINTER TO HTArray = LOOPHOLE[LOOPHOLE[RTRefCounts.GCState, LONG CARDINAL] + 400B]; nHTEntries _ 0; nHTEmpty _ 0; nHTChains _ 0; [] _ RTMicrocode.RTMOVESTATUS[toMemory, 0]; FOR I: CARDINAL IN [0..77777b] DO entry: INTEGER _ theHTArray[I]; IF entry > 0 THEN nHTEntries _ nHTEntries + 1; IF entry = -1 THEN nHTEmpty _ nHTEmpty + 1; IF entry < -1 THEN nHTChains _ nHTChains + 1; ENDLOOP; RETURN[nHTEmpty, nHTEntries, nHTChains, RTRefCounts.GCState.GCStateBasic.nOiFree] END; oldNHTEntries: INTEGER _ 0; oldNFreeOE: INTEGER _ 0; oldNHTChains: INTEGER _ 0; ShowRefCounts: PROCEDURE[out: IO.STREAM] = BEGIN nHTEmpty: INTEGER; nHTEntries: INTEGER; nHTChains: INTEGER; nFreeOE: INTEGER; deltaEntries: INTEGER; [nHTEmpty, nHTEntries, nHTChains, nFreeOE] _ Read[]; deltaEntries _ nHTEntries-oldNHTEntries+ oldNFreeOE-nFreeOE+nHTChains-oldNHTChains; oldNHTEntries _ nHTEntries; oldNFreeOE _ nFreeOE; oldNHTChains _ nHTChains; IO.Put[out, IO.rope["nHTEmpty: "], IO.int[nHTEmpty], IO.rope[", "]]; IO.Put[out, IO.rope["nHTEntries: "], IO.int[nHTEntries], IO.rope[", "]]; IO.Put[out, IO.rope["nHTChains: "], IO.int[nHTChains], IO.rope[", "]]; IO.Put[out, IO.rope["nFreeOE: "], IO.int[nFreeOE], IO.rope[", "]]; IO.Put[out, IO.rope["deltaEntries: "], IO.int[deltaEntries], IO.char[IO.CR]]; END; CreateDeadChain: PROCEDURE = BEGIN chain1: Cell _ NIL; chain2: Cell _ NIL; FOR I: INTEGER IN [1..1000] DO new: Cell _ NEW[CellBody _ [chain1, chain2]]; chain1 _ chain2 _ new; ENDLOOP; END; Cell: TYPE = REF CellBody; CellBody: TYPE = RECORD[c1: Cell, c2: Cell]; FillRefCounts: UserExec.CommandProc = TRUSTED BEGIN chain1: Cell _ NIL; chain2: Cell _ NIL; ShowRefCounts[UserExec.GetStreams[exec].out]; FOR I: INTEGER IN [1..10] DO FOR J: INTEGER IN [1..1000] DO new: Cell _ NEW[CellBody _ [chain1, chain2]]; chain1 _ chain2 _ new; ENDLOOP; CreateDeadChain[]; ShowRefCounts[UserExec.GetStreams[exec].out]; ENDLOOP; END; CountRefCounts: UserExec.CommandProc = TRUSTED BEGIN ShowRefCounts[UserExec.GetStreams[exec].out]; END; -- main code [nHTEntries: oldNHTEntries, nFreeOE: oldNFreeOE] _ Read[]; UserExec.RegisterCommand["FillRefCounts", FillRefCounts, ""]; UserExec.RegisterCommand["CountRefCounts", CountRefCounts, ""]; END.. -- February 17, 1983 8:46 am: Sturgis, started ReadRTNumbers.mesa -- February 18, 1983 11:04 am: add exec commands -- February 25, 1983 1:06 pmT: convert to 4.0, call it NewReadRTNumbers