← Back to context

Comment by jorkadeen

3 days ago

We have to emulate tail calls using trampolines. This means that in some cases we have to represent stack frames as objects on the heap. Fortunately, in the common case where a recursive function simply calls itself in tail position, we can rewrite the call to a bytecode level loop and there is no overhead.

Thanks for explaining that term. That sounds really bad indeed. Maybe this is way too technical, but representing them as stack pointers was unfeasible?

  • The JVM (and other VMs for that matter) do not grant direct access to the stack.

    But the good news is that the common case incurs no overhead.