Semantics-Based Compiling: A Case Study in Type-Directed Partial Evaluation
Olivier Danvy A, René Vestergaard · BRICS Report Series · 1996
We illustrate a simple and effective solution to semantics-based compiling. Our solution is based on type-directed partial evaluation, where - our compiler generator is expressed in a few lines, and is efficient; - its input is a well-typed, purely functional definitional interpreter in the manner of denotational semantics; - the output of the generated compiler is three-address code, in the fashion and efficiency of the Dragon Book; - the generated compiler processes several hundred lines of source code per second. The source language considered in this case study is imperative, block-structured, higher-order, call-by-value, allows subtyping, and obeys stack discipline. It is bigger than what is usually reported in the literature on semantics-based compiling and partial evaluation. Our compiling technique uses the first Futamura projection, i.e., we compile programs by specializing a definitional interpreter with respect to this program. Our denitional interpreter is completely straightforward, stack-based, and in direct style. In particular, it requires no clever staging technique (currying, continuations, binding-time improvements, etc.), nor does it rely on any other framework (attribute grammars, annotations, etc.) than the typed lambda-calculus. In particular, it uses no other program analysis than traditional type inference. The overall simplicity and effectiveness of the approach has encouraged us to write this paper, to illustrate this genuine solution to denotational semantics-directed compilation, in the spirit of Scott and Strachey.
Cited by 12 works. doi:10.7146/brics.v3i13.19976 Open-access PDF
Authors
References
- Compilers: Principles, Techniques, and Tools
- Correspondence between ALGOL 60 and Church's Lambda-notation
- Denotational semantics: The scott-strachey approach to programming language theory
- Definitional interpreters for higher-order programming languages
- Partial evaluation and automatic program generation
- A Theory of Programming Language Semantics
- Denotational Semantics: A Methodology for Language Development
- Mix: A self-applicable partial evaluator for experiments in compiler generation
- Tutorial notes on partial evaluation
- Revised 6 Report on the Algorithmic Language Scheme