Transformation by interpreter specialisation

  • Authors:
  • Neil D. Jones

  • Affiliations:
  • DIKU, University of Copenhagen, Denmark

  • Venue:
  • Science of Computer Programming - Special issue on program transformation
  • Year:
  • 2004

Quantified Score

Hi-index 0.00

Visualization

Abstract

A program may be transformed by specialising an interpreter for the language in which it is written. Efficiency of the transformed program is determined by the efficiency of the interpreter's dynamic operations; the efficiency of its static operations is irrelevant, since all will be "specialised away". This approach is automatic (as automatic as the specialiser is); general, in that it applies to all of the interpreter's input programs; and flexible, in that a wide range of program transformations are achievable since the transformed program inherits the style of the interpreter. The chief practical challenge is understanding cause and effect: how should one write the interpreter so that specialisation produces efficient transformed programs? The core of this paper is a series of examples, both positive and negative, showing how the way the interpreter is written can influence the removal of interpretational overhead, and thus the efficiency and size of the target programs obtained by specialisation. In principle this method can speed up source programs by an arbitrary amount: the limit depends only on how efficiently the interpreter can be written. An example shows that a "memoising" interpreter can yield asymptotic speedup, transforming an exponential-time program into one running in polynomial time. A final analysis is made of the speed of the output programs in relation to the speed of the interpreter from which they are derived. It is argued that this relative speedup is linear, with a constant coefficient depending on the program being transformed.