IMDEA Software

IMDEA initiative

Home > Events > Software Seminar Series > 2019 > Tail-call optimisation in lazy functional languages

Panagiotis Bougoulias

Friday, June 14, 2019

10:45am Lecture hall 1, level B

Panagiotis Bougoulias, PhD Student, IMDEA Software Institute

Tail-call optimisation in lazy functional languages

Abstract:

In this talk, I will present tail-call optimisation in a functional programming language in the presence of multiple evaluation orders (strict, lazy, call-by-name semantics). The source language, similar to Haskell, is transformed to a low-level, minimal, first-order functional language with non-strict semantics, lazy evaluation and lazy structured data as well as strictness annotations. To find opportunities for optimisation, I performed a static analysis on the low-level functional language, to spot tail-call positions. The interesting part, compared with languages with strict semantics, is that lazy semantics makes program values escape their context and thus finding tail-call positions is not trivial. This optimisation was evaluated on an interpreter of the language that explicitly allocates and measures frames, so that on tail-call positions found by the analysis, I could properly replace the unnecessary current frame’s arguments with the arguments needed by the frame that represents the next function call. This optimisation either improves program run-time, or does not change it. Also, in the case of strict programs, the optimisation is equivalent to classic tail-call optimisation. In conclusion, in a non-strict, lazy-evaluated functional language with lazy data constructors and strictness annotations, for all benchmarks, there is always memory optimisation, and for the majority of them there is a significant memory optimisation with performance boost.