RMTWPrivate.mesa
Copyright Ó 1991, 1992 by Xerox Corporation. All rights reserved.
Sturgis, April 20, 1990 2:22 pm PDT
Last changed by Theimer on November 29, 1989 1:34:53 am PST
Last tweaked by Mike Spreitzer on April 10, 1992 3:57 pm PDT
Coolidge, July 5, 1990 11:10 pm GMT
Philip James, August 27, 1991 1:44 pm PDT
Laurie Horton, September 19, 1991 3:52 pm PDT
DIRECTORY
BasicTime USING[GMT],
CardTab,
CirioNubAccess USING[Handle, RemoteAddress],
CirioTypes,
LoadStateAccess USING[BasicPCInfo, LoadedModuleInfo, LoadedSegmentInfo, LoadStateHandle],
MobAccess USING[BodySE, BTH, CTXH, CTXR, MobCookie, SEH, SER, TypeInfoConsSE],
MobObjectFiles,
MobDefs USING[VersionStamp],
NewRMTW USING[CedarModuleSet],
PFS,
PFSNames USING [PATH],
Records USING[FieldCase],
RefTab USING[Ref],
Rope USING[ROPE],
Symbols USING[SEIndex, SENull],
SystemInterface USING[CirioFile];
RMTWPrivate: CEDAR DEFINITIONS =
BEGIN OPEN LSA:LoadStateAccess;
ROPE: TYPE ~ Rope.ROPE;
PATH: TYPE = PFSNames.PATH;
Nat: TYPE = CirioTypes.Nat;
Node: TYPE = CirioTypes.Node;
Type: TYPE = CirioTypes.Type;
CC: TYPE = CirioTypes.CompilerContext;
BitAddr: TYPE = CirioTypes.BitAddr;
BitStretch: TYPE = CirioTypes.BitStretch;
Mem: TYPE = CirioTypes.Mem;
BasicTypeInfo: TYPE = CirioTypes.BasicTypeInfo;
BasicTypeInfoPrivate: TYPE = CirioTypes.BasicTypeInfoPrivate;
ModuleScope: TYPE = CirioTypes.ModuleScope;
SEH: TYPE = MobAccess.SEH;
SER: TYPE = MobAccess.SER;
CTXH: TYPE = MobAccess.CTXH;
CTXR: TYPE = MobAccess.CTXR;
bitsPerAu: Nat = CirioTypes.bitsPerAu;
bitsPerPtr: Nat = CirioTypes.bitsPerPtr;
unspecdBA: BitAddr = CirioTypes.unspecdBA;
zeroBA: BitAddr = CirioTypes.zeroBA;
ptrSize: BitAddr = CirioTypes.ptrSize;
noMem: Mem = CirioTypes.noMem;
TargetWorlds
RemoteMimosaTargetWorld: TYPE = REF RemoteMimosaTargetWorldBody;
RemoteMimosaTargetWorldBody: TYPE = RECORD[
sehHash: SehHashTable,
bthHash: BthHashTable,
ctxHash: CtxHashTable,
tcHash: CardTab.Ref--type code -> Type--,
unknownSymbolFlushTime: BasicTime.GMT,
ropeStudyTime: BasicTime.GMT,
atomSei: Symbols.SEIndex ¬ Symbols.SENull,
atomRecSeh: SEH,
atomRecRT: Type,
serverName: ROPE,
nub: CirioNubAccess.Handle,
cc: CC,
moduleScope: ModuleScope,
cedarModules: NewRMTW.CedarModuleSet,
lsh: LSA.LoadStateHandle,
setCTC: BOOL];
CtxHashTable: TYPE = REF CtxHashTableBody;
CtxHashTableBody: TYPE = RECORD[table: RefTab.Ref];
The entries in this hash table are CTXInfo.
CreateCtxHashTable: PROC RETURNS[CtxHashTable];
StudyRopes: PROC [rmtw: RemoteMimosaTargetWorld];
FindHelpingSehs: PROC [ctxh: CTXH, rmtw: RemoteMimosaTargetWorld] RETURNS [atomRecSeh: SEH];
FindSeh: PROC [ctxh: CTXH, name: ROPE, rmtw: RemoteMimosaTargetWorld] RETURNS [n, t: SEH];
Some Comments
We construct three classes of information: Type information, Structural information, and Node information. Roughly speaking, for a given SEH, there is only one piece of Type information, there is a different piece of Structural information for each logical place that the type appears, and there is a different piece of Node information for each physical place that the type appears. Thus, if we have some type which occurs exactly as the type of two variables in some procedure, then there will be two pieces of Structural information for that type, one for each of the two variables, and there will be many pieces of Node information, two for each invocation of the procedure.
All types in this module are nominally represented as a contiguous sequence of bits in memory and their Cedar type is defined by some SEH. However, it is conceivable that the presumed contiguous sequence of bits is actualy stored in some other way. This other way is independent of the structure of the represented value, but rather, it is dependent upon where the bits themselves are stored. For example, some of these values will be found embedded in the interior of some C variables. These may turn out to be multi-register C variables. We may not have direct access to the values in these registers as consecutive bytes in memory. We use Mems, defined below, to make it appear that these bits are, in fact, consecutive.
BTH Info
Three different kinds of information are keyed off of BTHs.
(1) nested blocks have record structures that are defined by the localCtx of a BTH
(2) the outermost structure of a procedure frame (procedure, arguments record, results record, enclosing context) is defined by assorted symbol information reached from the outermost BTH
(3) the set of nested blocks and outermost BTH of a procedure are defined by the BTH associated with the bracket pair that most tightly encloses a given pc.
BthHashTable: TYPE = REF BthHashTableBody;
BthHashTableBody: TYPE = RECORD[table: RefTab.Ref];
CreateBthHashTable: PROC RETURNS[BthHashTable];
implemented in RMTWFrames.mesa
SEH info
SehHashTable: TYPE = REF SehHashTableBody;
SehHashTableBody: TYPE = RECORD[table: RefTab.Ref];
CreateSehHashTable: PROC RETURNS[SehHashTable];
implemented in RMTWAtomics.mesa
UnderTypeSEH: PROC[seh: SEH, rmtw: RemoteMimosaTargetWorld] RETURNS[SEH];
implemented in RMTWAtomics.mesa
SehKnowledge: TYPE ~ {none, notSpecial, ROPE, RopeRep, ATOM};
Represents knowledge about an seh. ROPE means REF RopeRep. RopeRep includes partially bound variants.
AnalyzeSEH: PROC[seh: SEH, rmtw: RemoteMimosaTargetWorld, sk: SehKnowledge] RETURNS[Type];
Implemented in RMTWAtomics.mesa.
FmtSeh: PROC [seh: SEH, name: ROPE] RETURNS [ROPE];
Typestring info
TsDict: TYPE ~ REF TsDictPrivate;
TsDictPrivate: TYPE ~ RECORD [
tc: CARD,
ts: ROPE,
defs: ARRAY CHAR OF TsDef ¬ ALL[[]] ];
TsDef: TYPE ~ RECORD [
start: INT ¬ INT.FIRST,
type: Type ¬ NIL];
AnalyzeTc: PROC [rmtw: RemoteMimosaTargetWorld, tc: CARD] RETURNS [Type];
AnalyzeTs: PROC [rmtw: RemoteMimosaTargetWorld, tsd: TsDict, i: INT, opts: TsOptions ¬ ALL[FALSE]] RETURNS [Type, INT];
TsOptions: TYPE ~ PACKED ARRAY TsOption OF BOOL ¬ ALL[FALSE];
TsOption: TYPE ~ {mds, ordered, packed, readOnly, safe};
TsoSet: PROC [old: TsOptions, opt: TsOption] RETURNS [TsOptions]
~ INLINE {old[opt] ¬ TRUE; RETURN [old]};
Record Contexts
Contexts are used to describe record types both by ordinary records and by various frame components (nested blocks, arguments, and results). Consequently we provide a separate analysis to be used by both clients.
If the last type in the sequence is a sequence or union (as viewed from a mob) then the record type will report an unknown type for the last type. The corresponding field info will contain the correct name, seh, ser, serBody, and fieldLoc; but the analyzedFieldSEH will be for an unknown type (when valid).
The field list type will always report one less field, thus it can be used by Cirio Sequences and Cirio variant records as the preamble type.
AnalyzedCTX: TYPE = REF AnalyzedCTXBody;
AnalyzedCTXBody: TYPE = RECORD[
painted, blockRecord, hasNtConst: BOOLEAN,
recordType: Type, --direct
fieldListType: Type, --direct
ampersandFields: LIST OF FieldInfo,
typeFields: LIST OF FieldInfo,
rmtw: RemoteMimosaTargetWorld,
bitSize: BitAddr,
AnalyzeField: PROC [ctxInfo: AnalyzedCTX, index: CARDINAL, fi: FieldInfo] RETURNS [FieldInfo],
repData: MobCtxRep,
Read by RecordIndexToNTConstant and AnalyzeField.
fields: SEQUENCE nFields: CARDINAL OF FieldInfo];
MobCtxRep: TYPE ~ REF MobCtxRepPrivate;
MobCtxRepPrivate: TYPE ~ RECORD [
mob: MobAccess.MobCookie,
jmpi: MobObjectFiles.JointMobParsedInfo,
bth: MobAccess.BTH--present iff blockRecord
];
FieldInfo: TYPE = RECORD[
name: ROPE,
rmtw: RemoteMimosaTargetWorld,
fieldCase: Records.FieldCase,
analysisValid: BOOLEAN ¬ FALSE,
fieldDirectType: Type, -- valid only if analysisValid
unionAnalysis: Type ¬ NIL,
Meaningful for variantCases contexts.
fieldLoc: REF BitStretch ¬ NIL,
Meaningful for ordinary records.
varLoc: MobObjectFiles.VarLoc ¬ NIL,
Meaningful for block records.
repData: MobFieldRep
Read by RecordIndexToNTConstant and AnalyzeField.
];
MobFieldRep: TYPE ~ REF MobFieldRepPrivate;
MobFieldRepPrivate: TYPE ~ RECORD [
seh: SEH,
this is the idSEH that occurs in the context list
the SEH for the type of the value in the field is to be found at serBody.idType
ser: SER,
serBody: REF id MobAccess.BodySE,
sk: SehKnowledge];
AnalyzeTsRecord: PROC [rmtw: RemoteMimosaTargetWorld, tsd: TsDict, i: INT] RETURNS [Type, INT];
AnalyzeCTX: PROC[ctxh: CTXH, bindSeh: SEH, painted, unpackedArgResultRecord, blockRecord, maybeVariant, variantCases, isHelper, defer: BOOL, rmtw: RemoteMimosaTargetWorld, bitSize: BitAddr ¬ unspecdBA, jmpi: MobObjectFiles.JointMobParsedInfo ¬ NIL, bth: MobAccess.BTH ¬ NIL] RETURNS[ctxInfo: AnalyzedCTX, recType: Type];
Normally returns an AnalyzedCTX and its recordType; may instead return NIL and a variant or sequence-containing record type.
As a special dispensation, in order to handle empty argument/result records, this procedure will accept ctxh=NIL to produce an effectively empty record.
jmpi and bth needed iff blockRecord.
unpackedArgResultRecord triggers a workaround. (problem in mobs)
shouldbe true exactly when we are dealing with an unpacked reocord that is a proc arg or result record.
blockRecord indicates whether the Mem given to the record and fieldlist types should be a Frame Mem, wherein the fields are located by VarLocs, or a Simple Mem, wherein the fields are located according to their offsets in the mob.
If the record may have node-time constant (ie, constant procedure) fields, the supplied Mem must be able to read the "text" segment register.
bitSize is meaningful when blockRecord is FALSE.
maybeVariant => last field may indicate sequence or variant record.
bindSeh#NIL => last field *will* indicate variant record; return the bound variant type described by bindSeh (which is, unfortunately, the constructor, not the name); nobody cares about the returned AnalyzedCTX.
variantCases => this context describes the cases of a variant record.
isHelper => We're working on CirioRopeHelper, so invent some SehKnowledge.
defer => refrain from analyzing element types.
GetCompleteContext: PROC[ctxh: CTXH, rmtw: RemoteMimosaTargetWorld] RETURNS[CTXH, CTXR];
Get a completely copied context from some definitions mob
Mems
CreateSimpleMem: PROC[addr: CirioNubAccess.RemoteAddress, size: BitAddr ¬ unspecdBA] RETURNS[Mem];
Create a Simple Mem.
MakeDualMem: PROC [nub: CirioNubAccess.Handle, fp, sp: CARD, text, data, bss: LSA.LoadedSegmentInfo, fep, simple: BitStretch] RETURNS [mem: Mem];
Create a Mem that is both Frame and Simple.
SelectVarLoc: PROC [nub: CirioNubAccess.Handle, fm: Mem, vl: MobObjectFiles.VarLoc] RETURNS [Mem];
Given a Frame Mem.
definition files
(implementation is in RMTWModules)
returns nil if can't be found
one should try later if search path characteristics change
GetDefinitionMob: PROC[modules: NewRMTW.CedarModuleSet, vs: MobDefs.VersionStamp, stem: PATH ¬ NIL] RETURNS[MobAccess.MobCookie];
Interface between AnalyzeSEH and some of its more specialized equivalents; namely AnalyzeRecordSEH and AnalyzeArraySEH.
(RMTWCompounds contains the code for handling records, sequences, arrays, and variant records.)
AnalyzeArraySEH: PROC[seh: SEH, ser: SER, cons: REF cons MobAccess.BodySE, ti: REF array MobAccess.TypeInfoConsSE, rmtw: RemoteMimosaTargetWorld] RETURNS[Type];
AnalArrayTs: PROC [rmtw: RemoteMimosaTargetWorld, tsd: TsDict, i: INT, opts: TsOptions] RETURNS [Type, INT];
AnalyzeRecordSEH: PROC[seh: SEH, ser: SER, cons: REF cons MobAccess.BodySE, ti: REF record MobAccess.TypeInfoConsSE, rmtw: RemoteMimosaTargetWorld, isRopeRep: BOOL] RETURNS[Type];
EnumeratedTypeIndexToName: PROC [type: Type, index: INT, cc: CC] RETURNS [ROPE];
ConvertFromIndirectToPointer: PROC[indirect: CirioTypes.Node, mem: Mem, rmtw: RemoteMimosaTargetWorld] RETURNS[CirioTypes.Node];
AnalyzeRefSEH: PROC[dft: Type, seh: SEH, ser: SER, cons: REF cons MobAccess.BodySE, ti: REF ref MobAccess.TypeInfoConsSE, rmtw: RemoteMimosaTargetWorld, sk: SehKnowledge] RETURNS[Type];
AnalyzeProcedureSEH: PROC[ti: REF transfer MobAccess.TypeInfoConsSE, cons: REF cons MobAccess.BodySE, ser: SER, seh: SEH, rmtw: RemoteMimosaTargetWorld] RETURNS[Type];
AnalProcTs: PROC [rmtw: RemoteMimosaTargetWorld, tsd: TsDict, i: INT, opts: TsOptions] RETURNS [Type, INT];
AnalyzedUnknownSEH: PROC[seh: SEH, rmtw: RemoteMimosaTargetWorld, explanation: ROPE, bits: INT] RETURNS[Type];
Negative bits make Unknown, non-negative make Transparent.
MakeBrokenType: PROC [rmtw: RemoteMimosaTargetWorld, explanation: ROPE, bits: INT] RETURNS [Type];
Negative bits make Unknown, non-negative make Transparent.
UnimplementedTypeNode: PROC[targetType: Type, rmtw: RemoteMimosaTargetWorld, explanation: ROPE] RETURNS[Node];
Procedures for Constants
CreateProcConstant: PROC [rmtw: RemoteMimosaTargetWorld, jmpi: MobObjectFiles.JointMobParsedInfo, searchMem: Mem, textBase: CARD, bth: MobAccess.BTH] RETURNS [Node];
searchMem describes where to look for the proc descriptor (the pair of startPC and flag).
Special procedure for procedure call mechanism
the following is a special purpose routine used in RMTWAtomics.CallProc to obtain info about each argument parameter. This works only due to many special dispensations.
GenRecordFields: PROC[type: Type, cc: CC, nFields: PROC[CARD], eachField: PROC[index: CARD, byteOffset: INT, bitOffset: INT, bitSize: CARD] ];
Source assistance.
NameParts: TYPE = RECORD[
principalDirectory: PATH,
Syntactically an absolute directory, up to but not including the "sun4*" component (if any).
sun4: PATH,
nameStem: ROPE
The part of the last component before any extension.
c2c: PATH
];
At this point no one seems to use sun4 or c2c...
GetNamePartsFromFullPathName: PROC [fullPathName: PATH] RETURNS [NameParts];
SeekCSource: PROC [cms: NewRMTW.CedarModuleSet, basicInfo: REF LSA.BasicPCInfo, ledo: REF LSA.LoadedModuleInfo] RETURNS [foundFile: SystemInterface.CirioFile];
END..