[Openmcl-devel] CCL LAP info...
gb at clozure.com
Wed Feb 17 07:52:09 UTC 2010
On Sun, 14 Feb 2010, Jon S. Anthony wrote:
> On Sun, 2010-02-14 at 19:36 -0500, R. Matthew Emerson wrote:
>>>> ;; pass last two parameters in registers
>>>>  (movl ($ 8) (% arg_y))
>>>>  (movl ($ 12) (% arg_z))
>>>> ;; number of arguments, as a fixnum
>>>> ;; on x8632, temp1 doubles as nargs
>>>>  (movl ($ 12) (% temp1))
>>>>  (movl (@ '3-ARG-TAKER (% fn)) (% temp0))
>>> Out of curiosity, what's in fn here?
>> The address of the function 3-ARG-CALLER.
> So, as you pointed out earlier (and Gary went over this a bit too) fn
> provides the "context" of the current function. In this code (from the
> original example) does temp0 also have this address and is used to make
> the actual call (in that example generated code)?
In something similar:
(defun foo (x) (values (bar x))) ; the use of VALUES inhibits tail-call optimization
the x8632 disassembly contains:
;;; (bar x)
 (movl ($ 4) (% temp1))
 (movl (@ 'BAR (% fn)) (% temp0)) ; set %temp0 to the symbol BAR
 (leal (@ 0 (% arg_y)) (% arg_y)) ; this is a NOP
 (calll (@ 6 (% temp0))) ; call what's in %temp0's function cell
A symbol will always have something callable in its function cell:
either a real FUNCTION or some little bit of code that signals an
error (complaining that %temp0 doesn't have a real function in its
If you actually have to call a globally-named function from LAP code,
you'd be well advised to use the CALL-SYMBOL lap macro (or to do
exactly what it does.) The call instruction above is "tail-aligned"
so that the return address (pointing at a RECOVER-FN) is tagged (has
the value X8632::FULLTAG-TRA = 5 in its low 3 bits.) An x8632
function actually starts at a memory address that has 6 in its low 3
bits, so the relative address 31 in the function is tagged as (mod (+
6 31) 8) or 5. Treating return addresses as tagged objects means that
they're almost first-class lisp objects (and distinguishable from other
kinds of lisp objects) and can be freely intermixed with other kinds
of lisp objects on the stack.
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
More information about the Openmcl-devel