Implementing Closures using Run-time Code Generation

Published on February, 2006

Information

Martin Grabmüller: Implementing Closures using Run-time Code Generation, in Forschungsberichte Fakultät IV - Elektrotechnik und Informatik, number 2006-02, Technische Universität Berlin, February 2006.

Part of the work in this report was presented in a talk.

52+iv pages, format DIN A4, English.

Abstract

This report describes an implementation of a purely functional strict programming language which relies heavily on run-time code generation. Closures are not implemented as data structures containing code pointers and bindings for free variables, but instead by generating the machine code for a closure each time it is constructed. The actual values of free variables are embedded into the machine code instead of using references to a closure record. The goal of this experimental implementation is to examine the possibilities of run-time code generation - and just-in-time compilation in general - in the context of purely functional languages. The implementation details are described and the performance of several example programs is measured and compared to other functional language implementations.

Table of Contents

Download

This report is available electronically: [ PDF ]

BibTeX Entry

@TechReport{Grabmueller2006ImplementingClosures,
  author =	 {Martin Grabm{\"u}ller},
  title =	 {{Implementing Closures using Run-time Code
                  Generation}},
  institution =	 {Technische Universit{\"a}t Berlin},
  year =	 2006,
  type =	 {Research report},
  number =	 {\mbox{2006-02} in {\em Forschungsberichte Fakult{\"a}t IV
                  -- Elektrotechnik und Informatik}},
  month =	 {February},
  abstract =	 {This report describes an implementation of a purely
                  functional strict programming language which relies
                  heavily on run-time code generation. Closures are
                  not implemented as data structures containing code
                  pointers and bindings for free variables, but
                  instead by generating the machine code for a closure
                  each time it is constructed. The actual values of
                  free variables are embedded into the machine code
                  instead of using references to a closure record. The
                  goal of this experimental implementation is to
                  examine the possibilities of run-time code
                  generation -- and just-in-time compilation in
                  general -- in the context of purely functional
                  languages. The implementation details are described
                  and the performance of several example programs is
                  measured and compared to other functional language
                  implementations. }
}