logoalt Hacker News

mark-probstyesterday at 11:31 PM2 repliesview on HN

> In 2001 Mark Probst implemented tail-call optimization in GCC

That's me.

The motivation back then was to allow compilers that target C to assume that tail calls will be "proper". That's different from an optimization, which is usually optional, and which compilers don't guarantee.

The LWN post briefly sketches why this is hard: C allows variable-argument functions (like printf) where only the caller knows for sure how many arguments it passed, which means that only the caller can clean up the stack, unless the stack frame size is also communicated, which "normal" C calling conventions don't do. But when the callee does a proper tail call, the stack frame that returns to the callee is not the stack frame that the callee originally sent. This is explained in more detail in my thesis starting on page 16: https://hostr.flingit.run/s/proper-tail-calls.pdf


Replies

anitiltoday at 2:02 AM

That is a very cool contribution, I actually didn't know that it required a new calling convention! I look forward to reading your thesis

show 1 reply