RTTypesBasicPrivate.Mesa
last edited June 17, 1983 8:35 am by Paul Rovner
DIRECTORY
BcdDefs USING[SGIndex, SGNull, BcdBase],
RCMap USING[Index, nullIndex, Limit],
Rope USING[ROPE],
SafeStorage USING[TypeIndex, Type, nullType],
RTSymbolDefs USING[SymbolTableHandle, nullHandle, SymbolIndex, nullSymbolIndex],
TimeStamp USING[Stamp],
TypeStrings USING[TypeString];
RTTypesBasicPrivate: DEFINITIONS
= BEGIN OPEN SafeStorage, RTSymbolDefs;
Types
MapTiTd: TMapTiTd; -- The Runtime Type Table: maps TypeIndex to TypeDesc
RMapTiTd: TYPE = RECORD[ptds: SEQUENCE length: NAT OF PTypeDesc];
TMapTiTd: TYPE = LONG POINTER TO RMapTiTd;
PTypeDesc: TYPE = LONG POINTER TO TypeDesc;
TypeDesc: TYPE = MACHINE DEPENDENT RECORD [
equivalentTypePad: [0..3] ← 0,
equivalentType: Type ← nullType, -- nullType means not "canonicalized"
finalized: BOOLFALSE,
numberPackageRefs: NAT ← 0, -- ucode does not depend on stuff below
rcmx: RCMap.Index ← RCMap.nullIndex,
fill: [0..LAST[CARDINAL]/RCMap.Limit] ← 0,
utf: UniqueTypeFinger,
symbolAccess: SymbolAccess,
next: PTypeDesc ← NIL, -- link in list of types with the same ts hash
myTypePad: [0..3] ← 0,
myType: Type, -- a back pointer(logically)
typeStructure: TypeStructure,
extension: PTypeExtension ← NIL -- LOOPHOLE
];
SymbolAccess: TYPE = RECORD[
sti: SymbolTableIndex ← 0,
sei: SymbolIndex ← nullSymbolIndex
];
SymbolTableIndex: TYPE = NAT; -- index into MapStiStd
PTypeExtension: TYPE = LONG POINTER TO TypeExtension; -- LOOPHOLE
RTypeExtension: TYPE = REF TypeExtension;
TypeExtension: TYPE = RECORD [
next: RTypeExtension, -- link in the list of them; stay honest
finalizationSet: REFNIL,
attachment: REF ANYNIL
];
Access to symbol table information
MapStiStd: TMapStiStd; -- The map from SymbolTableIndex to STDesc. DELICATE intialization.
TMapStiStd: TYPE = REF RMapStiStd;
RMapStiStd: TYPE = RECORD[stiv: SEQUENCE length: SymbolTableIndex OF RSTDesc];
LOOPHOLEDTMapStiStd: TYPE = LONG POINTER TO LOOPHOLEDRMapStiStd;
LOOPHOLEDRMapStiStd: TYPE
= RECORD[stiv: SEQUENCE length: SymbolTableIndex OF PSTDesc];
InitialSTIRangeSize: CARDINAL = 1000B;
A STDesc describes options for finding the bits of a particular symbol table as follows:
If bcd=NIL, the symbolsStamp identifies a compiler-created .bcd file with version=symbolsStamp, and sth is a valid SymbolTableHandle.
else if sgi # SGNull, the symbolsStamp matches a (possibly composite) .bcd or .symbols file version stamp, and the sgi identifies the symbol table within bcd.
else if sgi = SGNull, the symbolsStamp matches an entry in bcd's file table, which identifies a compiler-created .bcd file with version=symbolsStamp.
RSTDesc: TYPE = REF STDesc;
PSTDesc: TYPE = LONG POINTER TO STDesc;
STDesc: TYPE = RECORD [
symbolsStamp: TimeStamp.Stamp,
bcd: BcdDefs.BcdBase ← NIL,
sgi: BcdDefs.SGIndex ← BcdDefs.SGNull,
sth: SymbolTableHandle ← nullHandle
];
TypeStructure: TYPE = TypeStrings.TypeString;
support for NARROW and runtime type-equivalence determination: canonical types.
UniqueTypeFinger: TYPE = RECORD[
umid: TimeStamp.Stamp, -- of original defining module
seIndex: SymbolIndex];  -- type seIndex therein
useCanonicalTypeMicroCode: BOOL; -- exported variable
Procedures
GetLastTypeIndex: PROC RETURNS[TypeIndex];
NumberPackageRefs: PROC[type: Type] RETURNS[NAT] =
INLINE{RETURN[MapTiTd[type].numberPackageRefs]};
MapTiRcmx: PROC[ti: TypeIndex] RETURNS[RCMap.Index] =
INLINE{RETURN[MapTiTd[ti].rcmx]};
PutForFinalization: PROC[type: Type, ref: REF ANY] RETURNS[done: BOOLEAN];
AssignComposite: PROC[rhs, lhs: LONG POINTER, type: Type, nwords: CARDINAL];
AssignCompositeNew: PROC[rhs, lhs: LONG POINTER, type: Type, nwords: CARDINAL];
FreeCollectibleObject: PROC[refObj: REF ANY]; -- nilifies REFs within
MapRefs: PROC[ptr: LONG POINTER, rcmx: RCMap.Index, procLeaf: PROC[p: REF ANY]];
MapRefOffsets: PROC[ref: REF ANY, procLeaf: PROC[offset: LONG CARDINAL]];
DoFREEify: PROC[ptr: LONG POINTER, rcmx: RCMap.Index, procLeaf: PROC[p: REF ANY]];
GetMapTiTd: PROC RETURNS[TMapTiTd];
NotifyAtomRecType: PROC[type: Type];
AcquireTypeForLoader: PROC[
utf: UniqueTypeFinger,
std: STDesc,
sei: SymbolIndex,
ts: TypeStructure,
rcmi: RCMap.Index,
canonicalize: BOOLEANFALSE,
initializing: BOOLFALSE -- TRUE => create MapStiStd entry from uncounted storage
]
RETURNS[Type];
for supporting RTTypes
MakeNewType: PROC[
utf: UniqueTypeFinger,
std: STDesc,
sei: SymbolIndex,
ts: TypeStructure,
rcmx: RCMap.Index,
canonicalize: BOOLEANFALSE,
initializing: BOOLEANFALSE,
i.e., create MapStiStd entry from uncounted storage
type: Type ← nullType]
RETURNS[Type];
FindSTI: PROC[std: STDesc, initializing: BOOLFALSE] RETURNS[i: SymbolTableIndex];
initializing = TRUE => create MapStiStd entry from uncounted storage
BlessMapStiStd: PROC; -- copy initial (uncounted) MapStiStd to counted storage
FindCanonicalPTD: PROC[ts: TypeStructure] RETURNS[ptd: PTypeDesc];
FindPTD: PROC[utf: UniqueTypeFinger, ts: TypeStructure ← NIL] RETURNS[ptd: PTypeDesc];
Enter: PROC[inner: PROC];
ERRORs
NotImplemented: ERROR[msg: Rope.ROPE];
END.