[Openmcl-devel] CCL LAP info...

R. Matthew Emerson rme at clozure.com
Sun Feb 14 16:36:17 PST 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 [33] in the disassembly below;  we're loading the symbol 3-ARG-TAKER from the function's constants.)

>> Example:
>> 
>> (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.

Yes.

>> ? (defun 3-arg-caller ()
>>    (3-arg-taker 1 2 3)
>>    'foo))
>> 3-ARG-CALLER
>> ? (df *)
> 
> Simple, but handy!
> 
> 
>> ;;; (defun 3-arg-caller () (3-arg-taker 1 2 3) 'foo)
>>  [0]     (recover-fn)
>>  [5]     (testl (% temp1) (% temp1))
>>  [7]     (jne L66)
>>  [9]     (pushl (% ebp))
>>  [10]    (movl (% esp) (% ebp))
>> 
>> ;;; (3-arg-taker 1 2 3)
>> 
>>          ;; here the caller reserves space for a frame
>>  [12]    (pushl ($ -21))
>>  [14]    (pushl ($ -21))
>>          ;; pass the first parameter on the stack
>>          ;; (the number 4 represents fixnum 1)
>>  [16]    (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
>>  [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.





More information about the Openmcl-devel mailing list