From: Frode Vatvedt Fjeld
Subject: i386 call-arguments-limit
Date: 
Message-ID: <2helcka93k.fsf@vserver.cs.uit.no>
Duane Rettig wrote:

> [..] Of course, I can understand why LispWorks has a limit of 255,
> and it is probably on the x86, and probably due to the count
> register being considered a byte value (it takes too much
> instruction real-estate to load up four explicit bytes into a count
> register).  When we did our second port to the x86 in 15 years, we
> didn't want such a small limit, so we found a way around it without
> forcing 5-or-6-byte instructions just to load up the count register,
> but to still get the full benefit of a full-word count.

One way to achieve this that I just thought of would be to use a
non-linear encoding of the arguments count. That is, for argcounts in
the 8-bit range just use the low 8-bit register, and for greater
values put an escape code in the low 8 and the value in the upper
24. Take care that the escape code is such that the ordering (as
determined by the cmpl instruction) is not altered, for example the
escape value can be #xff.

This strategy will certainly complicate certain situations (for
example when there is an &rest parameter you will probably need to
normalize the argcount by checking for the escape code), but for the
presumably common case of the argcount being within a known range
below 255 or so, only the 8-bit register needs to be considered
throughout the function-call code-path, there would be no need to mask
off the upper 24 bits.

It does limit the argcount to about 24 bits, though, but I think that
should be sufficient.

-- 
Frode Vatvedt Fjeld