[Openmcl-devel] CCL LAP info...
Gary Byers
gb at clozure.com
Tue Feb 16 23:52:09 PST 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
>>>> [18] (movl ($ 8) (% arg_y))
>>>> [23] (movl ($ 12) (% arg_z))
>>>> ;; number of arguments, as a fixnum
>>>> ;; on x8632, temp1 doubles as nargs
>>>> [28] (movl ($ 12) (% temp1))
>>>> [33] (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)
[14] (movl ($ 4) (% temp1))
[19] (movl (@ 'BAR (% fn)) (% temp0)) ; set %temp0 to the symbol BAR
[25] (leal (@ 0 (% arg_y)) (% arg_y)) ; this is a NOP
[28] (calll (@ 6 (% temp0))) ; call what's in %temp0's function cell
[31] (recover-fn)
? x8632::symbol.fcell
6
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
function cell.)
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.
>
> /Jon
>
>
> _______________________________________________
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
> http://clozure.com/mailman/listinfo/openmcl-devel
>
>
More information about the Openmcl-devel
mailing list