Next: Unknown-Values Returns, Previous: Local Calls, Up: Calling Convention [Contents]
;;; There is something of a cross-product effect with full calls. ;;; Different versions are used depending on whether we know the ;;; number of arguments or the name of the called function, and ;;; whether we want fixed values, unknown values, or a tail call. ;;; ;;; In full call, the arguments are passed creating a partial frame on ;;; the stack top and storing stack arguments into that frame. On ;;; entry to the callee, this partial frame is pointed to by FP.
Basically, we use caller-allocated frames, pass an fdefinition,
function, or closure in EAX
, argcount in ECX
, and first
three args in EDX
, EDI
, and ESI
. EBP
points to just past the start of the frame (the first frame slot is at
[EBP-4]
, not the traditional [EBP]
, due in part to how
the frame allocation works). The caller stores the link for the old
frame at [EBP-4]
and reserved space for a return address at
[EBP-8]
. [EBP-12]
appears to be an empty slot that
conveniently makes just enough space for the first three multiple
return values (returned in the argument passing registers) to be
written over the beginning of the frame by the receiver. The first
stack argument is at [EBP-16]
. The callee then reallocates the
frame to include sufficient space for its local variables, after
possibly converting any &rest
arguments to a proper list.
The above scheme was changed in 1.0.27 on x86 and x86-64 by swapping the old frame pointer with the return address and making EBP point two words later:
On x86/x86-64 the stack now looks like this (stack grows downwards):
---------- RETURN PC ---------- OLD FP ---------- <- FP points here EMPTY SLOT ---------- FIRST ARG ----------
just as if the function had been CALLed and upon entry executed the standard prologue: PUSH EBP; MOV EBP, ESP. On other architectures the stack looks like this (stack grows upwards):
---------- FIRST ARG ---------- EMPTY SLOT ---------- RETURN PC ---------- OLD FP ---------- <- FP points here
Next: Unknown-Values Returns, Previous: Local Calls, Up: Calling Convention [Contents]