Hello!

After thinking about this, it seems to be that the "compound literal" approach 
is the best one. What this means is that CPS-calls are changed in such a 
manner, that arguments are passed rthrough a pointer to a C_word-array (so it 
doesn't have to do anything with compound literals, that was just the first 
idea.) This approach has several advantages compared to other methods: 

- It's completely ABI independent.

- It simplifies code-generation a bit: there is no need for separate 
  "trampoline" procedures for normal CPS calls, as the vector can directly be 
  used for saving arguments on the temp-stack, with restoration being 
unnecessary 
  (the args are picked out of the argvector anyway). 

- There is no need for "rest-arg wrappers", functions that extract the rest
  argument and then call the actual compiled C function. This can be done
  directly from the argvector.

- "Direct" (leaf) routines and "customizable" procedures still use normal
  argument variables as before, as here callees are known at the call-site.

The problem with other approaches (own implementation of varargs, using 
assembly for forcing some sort of generic call, etc.) is that they are 
provisional hacks and take at least as much time to implement as the cleaner 
and more promising approach. 

How this will influence performance, I can't say. This will reduce code size 
(many trampolines go, as do rest-arg wrappers). Allocation of arg-vectors will 
use more stack-space, but removal of trampolines will remove activation-frames. 
Calls to known targets can still be done as normal C calls.

Whatever approach is used, this will be a substantial change, taking a lot of 
work: the backend needs to be changed, and all hand-written CPS primitives need 
to be adapted, also changing the way rest-args are handled. This needs to be 
implemented for CHICKEN 4 and later ported to CHICKEN 5, adapting all new CPS 
procedures that where introduced with the bignum-related changes. Oh, what 
fun... 

Comments? Ideas?


felix

_______________________________________________
Chicken-hackers mailing list
Chicken-hackers@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-hackers

Reply via email to