The cost of guaranteed tail call optimization is that you have to adopt the Pascal (callee side) convention for stack frame cleanup, so functions can’t reuse outgoing argument space. Does it matter in practice? Dunno.
-
-
Replying to @pcwalton
I don't understand what you mean by "reuse": if a fn makes multiple non-tail calls it reuses a region of stack for each; and if it finishes with a tail call, it reuses the place its own inbound args went. What am I missing?
1 reply 0 retweets 0 likes -
Replying to @leastfixedpoint
The problem is if you tail call a function that takes more argument space than you do.
2 replies 0 retweets 0 likes -
Replying to @pcwalton
Is moving the stack pointer by the delta, moving the return address, and then proceeding as normal a workable approach for that case? Or, adopt something neither fish nor fowl like this: https://eighty-twenty.org/2012/11/27/arm-tail-calling-convention … (I may be entirely missing your point!! Sorry if so!)
2 replies 0 retweets 0 likes -
Replying to @leastfixedpoint
I haven’t thought through that in detail, but it’s definitely not the C ABI anymore if you do that.
1 reply 0 retweets 0 likes -
Replying to @pcwalton
Ah, I see -- or maybe I don't. Weren't you saying proper TCO demands the Pascal convention (or something like it)? Which is of course not C ABI either.
1 reply 0 retweets 0 likes -
Replying to @leastfixedpoint
Right, that’s what I mean. You have to do *something* different from the C calling convention. Does it matter? I dunno! Someone should test :)
2 replies 0 retweets 0 likes -
Replying to @pcwalton @leastfixedpoint
What does it mean to test this? If Chez or MLton has really fast function calls, does it prove something?
1 reply 0 retweets 1 like -
Replying to @samth @leastfixedpoint
Run SPECint with an LLVM that compiles all functions with your custom calling convention?
2 replies 0 retweets 0 likes -
Replying to @pcwalton @leastfixedpoint
Here's a different test: have any languages with tail calls ever tried to find opportunities to use the C convention? I think the answer is no, but I certainly don't know every system.
2 replies 0 retweets 0 likes
I doubt it, but that’s probably due to history more than anything else. The Lisp/Scheme tradition way predates the C ABI becoming ubiquitous.
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.