CircularGarbageTraceAndSweep.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
Bob Hagmann August 13, 1985 11:17:29 am PDT
DIRECTORY
Allocator USING [NHeaderP],
PrincOps USING [GlobalFrameHandle],
SafeStorage USING [Type];
CircularGarbageTraceAndSweep: DEFINITIONS
= BEGIN
maxNReferers: NAT = 10;
APNodes: TYPE = ARRAY [0..maxNReferers) OF Allocator.NHeaderP;
WhoPointsTo:
PROC [nhp: Allocator.NHeaderP, cycleLimit:
NAT ← 20]
RETURNS [ referers:
REF APNodes, gfh: PrincOps.GlobalFrameHandle, foundInLocalFrame, foundInCircularStructure:
BOOL, cycles:
NAT ← 0] ;
Look up the referer chain. Stop if a gfh found, or if foundInLocalFrame, or if a loop is found, or if more than 1 referer is found, or if no referers are found (changed conserv scan)
WhoPointsToRef:
PROC [ref:
REF, cycleLimit:
NAT ← 20]
RETURNS [ referers:
LIST
OF
REF, gfh: PrincOps.GlobalFrameHandle, foundInLocalFrame, foundInCircularStructure:
BOOL, cycles:
NAT ← 0] ;
Same as WhoPointsTo but for REF's
FindCircularGarbageTypes:
PROC [nObjects:
CARDINAL, reportRopes:
BOOL ←
TRUE]
RETURNS [ nGarbage, nSeen:
INT, garbage:
LIST
OF SafeStorage.Type ←
NIL] ;
This procedure first does a standard incremental collection. Then it goes thru the motions of a TandS, but does not reclaim any garbage. Instead, it records the Types in a list. Do not do two of these at once!!
FindCircularGarbage:
PROC [nObjects:
CARDINAL, reportRopes:
BOOL ←
TRUE]
RETURNS [ nGarbage, nSeen:
INT, garbage:
LIST
OF
REF ←
NIL] ;
This procedure first does a standard incremental collection. Then it goes thru the motions of a TandS, but does not reclaim any garbage. Instead, it records the REFs in a list. Do not do two of these at once!!
FindConnectedComponent:
PROC [rootObject:
REF
ANY, nObjects:
CARDINAL, reportRopes:
BOOL ←
TRUE]
RETURNS [ allOnList:
BOOL, countReturned:
INT, circularObjects:
LIST
OF
REF ];
This procedure takes the rootObject, and find all object that it recursively points to. nObjects is the maximum number of objects to return. ROPEs will not be returned if reportRopes is FALSE. allOnList indicates that the list is complete: it was not stopped because nObjects was reached. In any case, ROPEs and ATOMs once found and possibly reported, will not be processed any further for the circularity.
REFToNHP: PROC[ref: REF ANY] RETURNS[Allocator.NHeaderP] ;
NHPToREF:
PROC[nhp: Allocator.NHeaderP]
RETURNS[
REF
ANY];
Non-INLINE versions of the AllocatorOps procedures for use from an interpreter.
END.
Bob Hagmann August 9, 1985 5:07:50 pm PDT
created
Bob Hagmann August 12, 1985 9:26:19 am PDT
added FindCircularStructure, WhoPointsToRef
Bob Hagmann August 12, 1985 10:08:25 am PDT
changes to: WhoPointsToRef
Bob Hagmann August 12, 1985 10:09:26 am PDT
changes to: WhoPointsToRef, FindCircularStructure, REFToNHP, NHPToREF
Bob Hagmann August 13, 1985 11:17:29 am PDT
renamed FindCircularStructure to FindConnectedComponent