[Openmcl-devel] CCL LAP info...
R. Matthew Emerson
rme at clozure.com
Mon Feb 15 00:36:17 UTC 2010
On Feb 14, 2010, at 1:48 PM, Jon S. Anthony wrote:
> Thanks, that is some valuable info! BTW, I've seen TCR and this fn
> being "established" and such, and have wondered what they are being used
> for/as. Couple sentence description?
Chapter 16 of the manual talks about this stuff a little bit. It should be basically accurate, too.
%fn contains the address of the current function. It's used to reference the function's "constants" and also to enable the GC to identify what function the program counter (er, "instruction pointer") is in. (See  in the disassembly below; we're loading the symbol 3-ARG-TAKER from the function's constants.)
>> (defx8632lapfunction 3-arg-taker ((stack-arg1 4) #|(ra 0)|#
> What is the annotation #|(ra 0)|# here?
That's just a reminder that the return address is at an offset of 0 from the stack pointer. stack-arg1 is at an offset of 4.
>> (arg2 arg_y) (arg3 arg_z))
>> ;; last two args passed in registers, others are on the stack
>> (movl (@ stack-arg1 (% esp)) (% temp0))
>> (movl (% temp0) (% arg_z))
>> (single-value-return 3))
> So, this just returns the stack arg (arg1) in standard return reg argz
> and then pops off the arg1 and 2 extra reserved (alignment??) words.
>> ? (defun 3-arg-caller ()
>> (3-arg-taker 1 2 3)
>> ? (df *)
> Simple, but handy!
>> ;;; (defun 3-arg-caller () (3-arg-taker 1 2 3) 'foo)
>>  (recover-fn)
>>  (testl (% temp1) (% temp1))
>>  (jne L66)
>>  (pushl (% ebp))
>>  (movl (% esp) (% ebp))
>> ;;; (3-arg-taker 1 2 3)
>> ;; here the caller reserves space for a frame
>>  (pushl ($ -21))
>>  (pushl ($ -21))
>> ;; pass the first parameter on the stack
>> ;; (the number 4 represents fixnum 1)
>>  (pushl ($ 4))
> This is very interesting - this seems to indicate that CCL uses the
> _low_ order bits as the tag bits? That would explain some things...
Right. Chapter 16 of the manual talks about tagging, too.
>> ;; 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.
More information about the Openmcl-devel