4 ms·
JavaScriptCore 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
by ridiculous_fish 7y ago
JavaScriptCore 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