tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Using qsort(3) in the kernel



Matt Thomas wrote:

On Nov 17, 2008, at 2:13 AM, Johnny Billquist wrote:

Andrew Reilly wrote:
On Sun, Nov 16, 2008 at 06:32:15PM -0800, Matt Thomas wrote:
And not all architectures can do tail call optimizations...
Really?  I thought that a tail call optimization essentially
turned a return into a goto (plus some variable (re)binding).

Well, strictly it should replace a call followed by a return, into a goto. :-)

But yeah, I agree. I can't see why any architecture should (could?) make any difference here.

VAX. The use of CALLS/RET instruction pretty inhibit the use of tall call optimizations since you can't guarantee the existing call frame has preserved the needed saved registers of the function you will transfer control to. And let's ignore manufacturing the needed argument list.

For tail call *recursion* the optimization is definitely possible, even if you use CALLS/RET on a VAX.

Actually, I only had my mind focused on tail call recursion optimization. For general tail call optimization, there are more traps for the unwary. And that is probably true for more architectures than VAX.

        Johnny



Home | Main Index | Thread Index | Old Index