In object oriented languages executed on top of virtual machine, tail recursion is something static compiler is not capable of optimising. Tail recursion optimisation must be done on the dynamic compiler – and this task usually falls onto Just-in-time compilers (JITs). Many JITs of Java and .Net VM are however unable to properly recognise and optimise the management of execution frames. There is however substantial diffrence between JVM and .Net here: CIL allows the static compiler to mark a call as tail recursive, as to make the implementation of JIT simpler and more flexible. Mark Lam’s blog offers lots of good insights into the JIT construction and JIT optimisations.

Leave a Reply

Your email address will not be published. Required fields are marked *