InitHacks.mesa
Russ Atkinson, August 4, 1983 5:18 pm
DIRECTORY
AMBridge,
AMTypes USING [Error],
BBContext,
Space,
Rope,
RopeFile,
RTBasic USING [TV],
Runtime USING [IsBound],
UserProfile,
VersionMap,
VersionMapDefaults;
InitHacks: CEDAR PROGRAM
IMPORTS
AMBridge, AMTypes, BBContext, Space, Rope, RopeFile, Runtime, UserProfile, VersionMap, VersionMapDefaults
= BEGIN OPEN RTBasic;
ROPE: TYPE = Rope.ROPE;
Greedy: PROC [] = TRUSTED {
... "steals" pages from the spaces used for Pilot Transactions. The size of the new spaces depends on the User Profile option TransactionImpl.logSpaceSize, which is the name of the global variable we set.
transImplTV: TV = BBContext.GlobalFrameSearch[NIL, "TransactionImpl"].tv;
pageCountTV: TV = BBContext.RecordSearch[transImplTV, "logSpaceSize"].tv;
pageCountPtr: LONG POINTER TO CARDINAL =
LOOPHOLE[AMBridge.PointerFromTV[pageCountTV]];
oldPageCount: INT = pageCountPtr^;
newSize: INT = UserProfile.Number["TransactionImpl.logSpaceSize", oldPageCount];
IF newSize IN [1..oldPageCount) THEN {
logSpaceTV: TV = BBContext.RecordSearch[transImplTV, "logSpace"].tv;
logSpacePtr: LONG POINTER TO Space.Handle =
LOOPHOLE[AMBridge.PointerFromTV[logSpaceTV]];
clientSpaceTV: TV = BBContext.RecordSearch[transImplTV, "clientSpace"].tv;
clientSpacePtr: LONG POINTER TO Space.Handle =
LOOPHOLE[AMBridge.PointerFromTV[clientSpaceTV]];
Space.Delete[logSpacePtr^];
Space.Delete[clientSpacePtr^];
pageCountPtr^ ← newSize;
logSpacePtr^ ← Space.Create[pageCountPtr^, Space.virtualMemory, Space.defaultBase];
clientSpacePtr^ ← Space.Create[pageCountPtr^, Space.virtualMemory, Space.defaultBase];
};
};
InstallRopeFile: PROC = TRUSTED {
... installs RopeFile routines as the file access routines for version maps. This saves significant VM at a small cost in safety and/or search time. The UserProfile option that gioverns this feature is VersionMap.UseRopeFile.
IF Runtime.IsBound[RopeFile.SubstrCreate]
AND UserProfile.Boolean["VersionMap.UseRopeFile", FALSE] THEN {
vmapImplTV: TV = BBContext.GlobalFrameSearch[NIL, "VersionMapImpl"].tv;
vmapDefImplTV: TV = BBContext.GlobalFrameSearch[NIL, "VersionMapDefaultsImpl"].tv;
substrCreatorTV: TV = BBContext.RecordSearch[vmapImplTV, "substrCreator"].tv;
substrCreatorPtr: LONG POINTER TO PROC ANY RETURNS ANY =
LOOPHOLE[AMBridge.PointerFromTV[substrCreatorTV]];
amvImplTV: TV = BBContext.GlobalFrameSearch[NIL, "AMViewerOpsImpl"].tv;
ropeCreatorTV: TV = BBContext.RecordSearch[amvImplTV, "ropeCreator"].tv;
ropeCreatorPtr: LONG POINTER TO PROC ANY RETURNS ANY =
LOOPHOLE[AMBridge.PointerFromTV[ropeCreatorTV]];
rootTV: TV = BBContext.RecordSearch[vmapDefImplTV, "root"].tv;
rootPtr: LONG POINTER TO REF = LOOPHOLE[AMBridge.PointerFromTV[rootTV]];
substrCreatorPtr^ ← RopeFile.SubstrCreate;
ropeCreatorPtr^ ← RopeFile.SimpleCreate;
rootPtr^ ← NIL;
};
};
AppendVersionMaps: PROC = {
... adds the version maps stored in the files specified in the UserProfile options VersionMap.Symbols and VersionMap.Source to the version maps to be searched.
AddListToMapList[$Symbols, "VersionMap.Symbols"];
AddListToMapList[$Source, "VersionMap.Source"];
};
ReverseAndUnique: PROC [list: LIST OF ROPE] RETURNS [new: LIST OF ROPENIL] = {
... reverses a list and removes duplicates.
FOR subList: LIST OF ROPE ← list, subList.rest WHILE subList # NIL DO
outer: ROPE ← subList.first;
found: BOOLFALSE;
FOR rest: LIST OF ROPE ← list.rest, rest.rest WHILE rest # NIL DO
inner: ROPE ← rest.first;
IF Rope.Equal[outer, inner, FALSE] THEN {
found ← TRUE;
EXIT;
};
ENDLOOP;
IF found THEN LOOP;
new ← CONS[outer, new];
ENDLOOP;
};
AddListToMapList: PROC
[which: ATOM, key: ROPE] = {
... is a utility to add version maps specified by the UserProfile option named by key to the list specified by which. The resulting search order is as given in the option, which means that we have to add the maps in the reverse order. The file name extension defaults to "VersionMap". Missing version map files are ignored.
nameList: LIST OF ROPE ← ReverseAndUnique[UserProfile.ListOfTokens[key]];
mapList: VersionMap.MapList ← VersionMapDefaults.GetMapList[which];
the above line forces the map list to be made current if it is NIL.
FOR each: LIST OF ROPE ← nameList, each.rest WHILE each # NIL DO
name: ROPE ← Rope.Flatten[each.first];
map: VersionMap.Map ← NIL;
WHILE Rope.Match["*.", name] DO
name ← name.Flatten[0, name.Size[]-1];
ENDLOOP;
map ← VersionMap.RestoreMapFromFile[
name, TRUE
! ANY => CONTINUE];
IF map = NIL AND NOT Rope.Match["*.VersionMap", name, FALSE] THEN {
name ← name.Concat[".VersionMap"].Flatten[];
map ← VersionMap.RestoreMapFromFile[
name, TRUE
! ANY => CONTINUE];
};
IF map # NIL THEN VersionMapDefaults.AddToMapList[which, map];
ENDLOOP;
};
Initialization
InstallRopeFile[! AMTypes.Error => CONTINUE];
Greedy[! AMTypes.Error => CONTINUE];
AppendVersionMaps[];
END.