3 ms·
The point of the tail call is to not have to maintain the activation that you are tail calling from. So we’d need to reconstruct some information about the act
by chrisseaton 7y ago
The point of the tail call is to not have to maintain the activation that you are tail calling from.
So we’d need to reconstruct some information about the activation. How are you proposing we do that? From what information?
Are you suggesting we could store some metadata perhaps? Can you suggest a mechanism for the metadata we should use? There’s a tricky constraint before you suggest an idea! It has to use constant storage, because making storage not grow with the number of calls is the whole point in the first place.
- ridiculous_fish 7y agoJavaScriptCore has probably the best answer for this question, and it's the hilariously-named "Shadow Chicken" mechanism. JSC's call stack is the C stack, and this stack has real TCO. There is a separate, heap-allocated "shadow" stack which records calls (but not returns). A single recycled C-stack frame may correspond to multiple shadow-stack calls, but between the two, a debugger can recover many tail calls. It's best effort. The GC may collect frames if it chooses to. Highly optimized code won't touch the shadow stack. etc. But it's good enough for a debugger. It's named "Shadow Chicken" because it's a shadow stack inspired by CHICKEN scheme, which uses the legendary Cheney-on-the-MTA strategy. https://trac.webkit.org/changeset/199076/webkit https://trac.webkit.org/changeset/199076/webkit
- deleted 7y ago[deleted]