Prototyped functions: there are a range of possibilities. 2. Everything gets PMC-ized and passed in P5..P15+P3. Ix is an arg count for the number of args passed in P5..P15. P3 is empty if argcount <= 11 (so you have to completely fill P5..P15 before putting stuff in P3.)
That is exactly the unprototyped case.
4. PMCs get passed in P5..P15+P3, ints get passed in I5..I15+P3, etc. Ix is a total argument count (number of non-overflowed PMC args + number of non-overflowed int args + ...). Arguments are always ordered, so it is unambiguous which ones were omitted in a varargs situation. I think this is what Leo is arguing for.
Almost. An argument count doesn't help in the general case (e.g. against swapped params of the same type or such). So I'd just omit it for the probably more common case of fixed and known arguments.
But, we need something for varargs or even changed signatures (wherever they might come from). The HLL compiler shouldn't know much about the underlying calling conventions. OTOH the code generated for argument binding in the callee has to interface with the HLL code for providing values for missing (default) arguments.
We might need something like this
.sub prototyped var_args # I1 is count of I-args .param int a # I5 when presemt .if_missing_param a # if I1 >= 1 goto a_is_valid # HLL code to set a # ... # a = some # I5 = ... .end # a_is_valid:
So while its up to the HLL to produce the code for providing a default value, its up to our calling conventions to allow such code to interface, when a param is missing. Just having counts isn't enough to provide all we need. We must provide an interface for the HLL to fill in code for missing arguments.
Changed signatures can't be handled with counts anyway.
The other question is how much high-level argument passing stuff (eg,
default values) should be crammed in.
See above.
... The argument against is that it
will bloat the interface and slow down calling.
I'd really have fixed and vararg cases separated for this reason. The fib() benchmark measuring raw call speed mainly, is already slow enough.
leo