DragomanPrivate:
CEDAR DEFINITIONS = {
OPEN PrincOps;
Value: TYPE = RECORD [w: WORD]; -- to make a unique type
DValue: TYPE = RECORD [lo, hi: WORD]; -- to make a unique type
Ptr1: TYPE = POINTER TO Value;
Ptr2: TYPE = POINTER TO DValue;
LPtr1: TYPE = LONG POINTER TO Value;
LPtr2: TYPE = LONG POINTER TO DValue;
OpHistorySize: CARDINAL = 64;
OpHistoryItem:
TYPE =
RECORD [
gf: POINTER,
pc: CARDINAL,
stkDepth: [0..16],
stk: ARRAY [0..14) OF UNSPECIFIED,
op: ARRAY [0..3) OF Byte];
OpHistoryRec:
TYPE =
RECORD [
head, tail: CARDINAL ← 0,
data: ARRAY [0..OpHistorySize) OF OpHistoryItem];
OpHistory: TYPE = REF OpHistoryRec;
BitVector: TYPE = PACKED ARRAY PrincOps.GFTIndex OF BOOLEAN;
MachineStateRec:
TYPE =
RECORD [
cacheData: REF ANY ← NIL,
sd: CARDINAL ← 0,
stack: ARRAY [0..14) OF Value ← ALL[[0]],
l, g: POINTER TO Value ← NIL,
cb: LONG POINTER ← NIL,
pc: CARDINAL ← 0,
iCount, outCalls: INT ← 0,
interestingGfi: REF BitVector ← NIL,
singleStep: BOOL ← FALSE,
breakGF: POINTER ← NIL, breakPC: CARDINAL ← 0,
traceOps: BOOL ← FALSE, history: OpHistory ← NIL,
recordXferOut: BOOL ← FALSE, xferData: REF ANY ← NIL,
countOps, flushOnCall: BOOL ← FALSE, opCount: REF ARRAY Byte OF INT ← NIL,
startPulses: BasicTime.Pulses ← 0, startOps: LONG CARDINAL ← 0];
Machine:
TYPE =
REF MachineStateRec;
Byte: TYPE = [0..256);
Bytes: TYPE = RECORD [b1, b2: Byte];
Pair: TYPE = RECORD [filler: Byte, p1, p2: [0..16)];
FieldDescriptor: TYPE = PrincOps.FieldDescriptor;
LCB: TYPE = LONG BASE POINTER TO CSegPrefix;
MagicReturn: PrincOps.ControlLink =
LOOPHOLE[0];
RestartInterpreter:
SIGNAL [iFrame: PrincOps.FrameHandle]
RETURNS [uFrame: PrincOps.FrameHandle];
Conversion Routines
FH:
PROC [p: Ptr1]
RETURNS [FrameHandle] =
TRUSTED
INLINE {
RETURN[LOOPHOLE[p, FrameHandle]]};
CardV:
PROC [v: Value]
RETURNS [
CARDINAL] =
TRUSTED
INLINE {
RETURN[LOOPHOLE[v, CARDINAL]]};
IntV:
PROC [v: Value]
RETURNS [
INTEGER] =
TRUSTED
INLINE {
RETURN[LOOPHOLE[v, INTEGER]]};
Ptr1V:
PROC [v: Value]
RETURNS [Ptr1] =
TRUSTED
INLINE {
RETURN[LOOPHOLE[v, Ptr1]]};
Ptr2V:
PROC [v: Value]
RETURNS [Ptr2] =
TRUSTED
INLINE {
RETURN[LOOPHOLE[v, Ptr2]]};
LCardV:
PROC [v: DValue]
RETURNS [
LONG
CARDINAL] =
TRUSTED
INLINE {
RETURN[LOOPHOLE[v, LONG CARDINAL]]};
LIntV:
PROC [v: DValue]
RETURNS [
LONG
INTEGER] =
TRUSTED
INLINE {
RETURN[LOOPHOLE[v, LONG INTEGER]]};
LPtr1V:
PROC [v: DValue]
RETURNS [LPtr1] =
TRUSTED
INLINE {
RETURN[LOOPHOLE[v, LPtr1]]};
LPtr2V:
PROC [v: DValue]
RETURNS [LPtr2] =
TRUSTED
INLINE {
RETURN[LOOPHOLE[v, LPtr2]]};
VCard:
PROC [v:
CARDINAL]
RETURNS [Value] =
TRUSTED
INLINE {
RETURN[LOOPHOLE[v, Value]]};
VInt:
PROC [v:
INTEGER]
RETURNS [Value] =
TRUSTED
INLINE {
RETURN[LOOPHOLE[v, Value]]};
VPtr1:
PROC [v: Ptr1]
RETURNS [Value] =
TRUSTED
INLINE {
RETURN[LOOPHOLE[v, Value]]};
VPtr2:
PROC [v: Ptr2]
RETURNS [Value] =
TRUSTED
INLINE {
RETURN[LOOPHOLE[v, Value]]};
VLCard:
PROC [v:
LONG
CARDINAL]
RETURNS [DValue] =
TRUSTED
INLINE {
RETURN[LOOPHOLE[v, DValue]]};
VLInt:
PROC [v:
LONG
INTEGER]
RETURNS [DValue] =
TRUSTED
INLINE {
RETURN[LOOPHOLE[v, DValue]]};
VLPtr1:
PROC [v: LPtr1]
RETURNS [DValue] =
TRUSTED
INLINE {
RETURN[LOOPHOLE[v, DValue]]};
VLPtr2:
PROC [v: LPtr2]
RETURNS [DValue] =
TRUSTED
INLINE {
RETURN[LOOPHOLE[v, DValue]]};
Statistics recording
ReadAtAddress: PROC [m: Machine, addr: LONG POINTER];
DoubleReadAtAddress: PROC [m: Machine, addr: LONG POINTER];
ReadLocal: PROC [m: Machine, offset: CARDINAL];
DoubleReadLocal: PROC [m: Machine, offset: CARDINAL];
WriteAtAddress: PROC [m: Machine, addr: LONG POINTER];
DoubleWriteAtAddress: PROC [m: Machine, addr: LONG POINTER];
StoreLocal: PROC [m: Machine, offset: CARDINAL];
DoubleStoreLocal: PROC [m: Machine, offset: CARDINAL];
Utilities
FinishedExecution: SIGNAL;
NextOpByte: PUBLIC PROC [m: Machine, opcode: BOOL ← FALSE] RETURNS [Byte];
SetPc: PUBLIC PROC [m: Machine, pc: CARDINAL];
UnboundProcTrap: PROC [m: Machine, link: ControlLink];
ControlTrap: PROC [m: Machine, link: ControlLink];
InterpreterProblem: TYPE = {confused, boundscheck, nilcheck, unboundProc, controlFault};
Problem: ERROR [m: Machine, reason: InterpreterProblem];
Confusion: PROC [m: Machine];
NilFault: PROC [m: Machine];
BoundsFault:
PROC [m: Machine];
Push: PUBLIC PROC [m: Machine, v: Value];
Pop: PUBLIC PROC [m: Machine] RETURNS [v: Value];
Top: PROC [m: Machine] RETURNS [v: Value];
Push2: PROC [m: Machine, v: DValue];
Pop2: PROC [m: Machine] RETURNS [v: DValue];
Read: PROC [m: Machine, p: LPtr1] RETURNS [Value];
ReadDouble: PROC [m: Machine, p: LPtr2] RETURNS [DValue];
ReadField: PROC [m: Machine, p: LPtr1, fd: FieldDescriptor] RETURNS [Value];
Write: PROC [m: Machine, p: LPtr1, v: Value];
WriteDouble: PROC [m: Machine, p: LPtr2, v: DValue];
WriteField:
PROC [m: Machine, p: LPtr1, fd: FieldDescriptor, v: Value];
RFSOp:
PROC [p: Ptr1, fd: FieldDescriptor]
RETURNS [Value] =
TRUSTED MACHINE
CODE {
PrincOps.zRFS};
RFSLOp:
PROC [p: LPtr1, fd: FieldDescriptor]
RETURNS [Value] =
TRUSTED MACHINE
CODE {
PrincOps.zRFSL};
WFSOp:
PROC [v: Value, p: Ptr1, fd: FieldDescriptor] =
TRUSTED MACHINE
CODE {
PrincOps.zWFS};
WFSLOp:
PROC [v: Value, p: LPtr1, fd: FieldDescriptor] =
TRUSTED MACHINE
CODE {
PrincOps.zWFSL};
CacheIndex: PUBLIC TYPE = [0..8);
CacheInfo: PUBLIC TYPE = REF CacheInfoRec;
CacheInfoRec:
PUBLIC TYPE =
RECORD [
active: BOOL ← TRUE,
iCaches, dCaches: NAT ← 0,
iCache: ARRAY CacheIndex OF CacheModels.Cache ← ALL[NIL],
dCache: ARRAY CacheIndex OF CacheModels.Cache ← ALL[NIL],
iBufferSize: NAT ← 16,
iBufferBytes: NAT ← 0,
afterJump: BOOL ← FALSE];
EnableCaches: PUBLIC PROC [m: Machine, state: BOOL];
PrintCacheStats: PROC [os: IO.STREAM, m: Machine];
FlushAllCaches: PROC [m: Machine];
ResetCacheModel: PROC [m: Machine, instr, data, lines, quads: NAT, lru: BOOL];
EnableCacheModel:
PROC [m: Machine, state:
BOOL, instr, data, lines, quads:
NAT, lru:
BOOL];
from RESIInterface
Initialize: PROC [handle: REF ANY, topProc: PROC];
from RESIDisp.mesa
Execute: PROC [m: Machine];
from RESIOps
SignedOpByte: PROC [m: Machine] RETURNS [INTEGER];
DoSignedJump: PROC [m: Machine, savedPc: CARDINAL, op: Byte];
DoUnsignedJump: PROC [m: Machine, savedPc: CARDINAL, op: Byte];
DoMonitorOps: PROC [m: Machine, op: Byte];
DoLocalOps: PROC [m: Machine, op: Byte];
DoGlobalOps: PROC [m: Machine, op: Byte];
DoLiteralOps: PROC [m: Machine, op: Byte];
DoReadOps: PROC [m: Machine, op: Byte];
DoWriteOps: PROC [m: Machine, op: Byte];
DoReadIndirectOps: PROC [m: Machine, op: Byte];
DoWriteIndirectOps: PROC [m: Machine, op: Byte];
DoWriteSwappedOps: PROC [m: Machine, op: Byte];
DoShortArithmetic: PROC [m: Machine, op: Byte];
from RESIXfer.mesa
AllocFrame: PROC [FrameSizeIndex] RETURNS [FrameHandle] = TRUSTED MACHINE CODE {PrincOps.zALLOC};
FreeFrame: PROC [FrameHandle] = TRUSTED MACHINE CODE {PrincOps.zFREE};
FetchLink: PROC [m: Machine, lki: CARDINAL] RETURNS [ControlLink];
MakeProcDesc: PROC [m: Machine, gf: GlobalFrameHandle, entry: CARDINAL] RETURNS [ControlLink];
Xfer: PROC [m: Machine, dst, src: ControlLink, push: BOOL ← TRUE, free: BOOL ← FALSE];
LoadState: PROC [m: Machine, free: BOOL];
from RESIStats.mesa
PrintOpCounts: PROC [os: IO.STREAM, m: Machine];
PrintProcCounts: PROC [os: IO.STREAM, m: Machine];
}.