News for hackers. Stuff that matters.
Re:Lisp in Dart 2.0 by dreamcompiler on Sunday September 23, 2018 @07:28PM (#18053921)
If function A tail-jumps to function B and B exits with a Return instruction (rather than another JMP) then B's Return cleans up A's stack frame automatically. It doesn't have to care that the current frame actually belongs to A rather than B.

If A has local variables, the compiler will insert an instruction to increment the SP before the final JMP, which cleans up the space for the locals.

[This requires stack frames to push local variables after pushing the return address (if any), but that's easy to arrange.]

The point is that the compiler can make the TCO decision statically just by inspecting the function in question. Dynamic analysis of who-calls- who is not necessary.

There are no comments on this comment yet.