Types of Function Call Desired: - Normal Function call 1 result expected (MV flag of callee cleared). - Function Call Multiple Values expected (MV flag of callee set). - Tail Function call (frame is re-used, MV flag unchanged). - Intermediate Fn call (pass MV flag to callee). Function Call Opcodes: - Fn0-7 Function call of 0 - 7 arguments. - TFn0-7 Tail Function call of 0-7 arguments. Stack frame is re-used. The Multiple value flag of the callee will be that of the caller's MV flag. - APPLY.N.M Call function indicated by M with N arguments. N contains information to indicate the type of Fn call: Normal, MV, Tail, or Intermediate. - APPLY Call function Tos-1 with Tos arguments. Tos contains the information to indicate the type of Fn call: Normal, MV, Tail, or Intermediate. The information bits for APPLY are as follows: Bits: 2-0 are # Args. Bits 4-3 are encoded: 4 3 0 0 Clear callee's MV flag 0 1 Set callee's MV flag (I'm expecting MVs) 1 1 Pass caller's current MV flag to callee Bit 5 means: 0 use a new frame 1 re-use the current frame Function Call Semantics: - Read Memory for Definition Cell of the Atom, store @ code slot - Read Memory for the function header word & set: Fn Flags, MV flag, #Args, & Tos - Set the IVar slots to NIL - Copy the Args - Read Memory for the PC, set context - Copy the binding stack pointer from previous frame Function Return Semantics: - Pop result of stack, Check for TrapOnExit - Push result into previous frame, Check for TrapOnReturnTo, Change context to previous frame NOTE: A TrapOnExit or TrapOnReturnTo will require dumping the frames to memory so that the Ufn can hack the frames as needed. Questions - Where/When is Multiple Value flag to be checked? At RETURN - How are multiple values to be returned? (list, object, etc?) - What is needed for closures? Can it be slower and/or a different opcode? Do you always know ahead of time that you are doing a closure call? - Bit in frame saying I'm a tail frame. (skip M.V's through me)? Answered Questions - Is a Nametable entry needed, Can the code pointer be used as the nametable entry, Or can the nametable entry be NIL (i.e. in slot 7 of IVars) and be set only when changing the nametable? NO NAMETABLE PTR. - If a binding stack is desired can it be in IVar slot 7 (therefore NIL) and set only when 1st bind takes place? This would speed up fn call but make 1st bind of a function run slower. It may have to look back n frames to find where last bind took place. A BINDING STACK PTR. - What opcodes should be explicitly encoded? (Fn0-7 vrs Apply style) FN0-7 ... TFN0-7 (re-use frame) LFN.N.M - Should there be a call that re-uses the same frame? What variations are important? How important would this call be? Yes TFN0-7 - Should we assume a valid CCodeP in definition slots of all atoms? NO - Is it necessary to set 1st 8 Ivars to NIL? Yes - Is it necessary to set 1st 8 Pvars to Unbound? Even with a binding stack? No Unbounds.