## Implementing Memoization for Partial Evaluation (1997)

Venue: | In Herbert Kuchen and Doaitse Swierstra, editors, International Symposium on Programming Languages, Implementations, Logics and Programs (PLILP '96 |

Citations: | 5 - 4 self |

### BibTeX

@INPROCEEDINGS{Thiemann97implementingmemoization,

author = {Peter Thiemann},

title = {Implementing Memoization for Partial Evaluation},

booktitle = {In Herbert Kuchen and Doaitse Swierstra, editors, International Symposium on Programming Languages, Implementations, Logics and Programs (PLILP '96},

year = {1997},

pages = {198--212},

publisher = {Springer-Verlag}

}

### Years of Citing Articles

### OpenURL

### Abstract

. Memoization is a key ingredient in every partial evaluator. It enables folding by caching previously specialized functions. It is essential to make polyvariant specialization terminate. Its implementation is reasonably straightforward in a standard specializer that represents functions by closures. With the advent of handwritten programgenerator generators (PGGs), implementing memoization gets harder, because PGGs use efficient standard representations of data at specialization time. We present several implementations of memoization for PGGs that are able to deal with all features of current partial evaluators, specifically partially static data and functions. The first implementation is based on message passing. It is simple, portable, and efficient, but only suitable for untyped higher-order languages such as Scheme. The second implementation is geared towards typed language such as SML. Whereas the first two implementations are completely portable, our third implementation exploit...

### Citations

1562 | The Definition of Standard ML
- Miller, Tofte, et al.
- 1990
(Show Context)
Citation Context ...ification of the insertion of sp-functions, we can guarantee that specialization terminates for some input if and only if standard evaluation does so the same input. Some knowledge of Scheme [17], ML =-=[25]-=-, and partial evaluation [18] is a prerequisite to this paper. (define (static-constructor ctor closed-value vvs bts) (let ((ctor-vvs (cons ctor vvs))) (lambda (what) (case what ((value) (apply closed... |

639 |
Partial Evaluation and Automatic Program Generation. Available online: http://www.itu.dk/people/sestoft/pebook
- Jones, Gomard, et al.
- 1993
(Show Context)
Citation Context ...--a specialized version of the program, which on application to the remaining dynamic parameters produces the same result as the original program applied to all parameters. Offline partial evaluation =-=[10,18]-=- consists of two phases, binding-time analysis (BTA) and static reduction. BTA transforms a program and the binding times (static/dynamic) of the parameters into an annotated program. Subsequently, th... |

299 | Definitional interpreters for higher-order programming languages
- Reynolds
- 1972
(Show Context)
Citation Context ...lambda (what) ...) has no ML type, because the result of the 'value message is a function and the result of the 'static message is a list. Hence, we have to perform some variant of closure conversion =-=[30]-=-. It is, however, well-known that closure conversion is not straightforward in a typed setting [26]. The untyped appraoch closure conversion introduces a datatype AllClosures which has a constructor f... |

297 | Control-Flow Analysis of Higher-Order Languages
- SHIVERS
- 1991
(Show Context)
Citation Context ...by monomorphic expansion. Applying Closure Analysis When we assume the availability of the explicitly typed source program (after type reconstruction) and the results of a closure analysis (see e.g., =-=[14, 33, 35]-=-), we can solve the typing problem. Suppose each program point is marked with a unique label ` 2 Labels. An (equational) flow analysis partitions Labels into disjoint flow classes L 1 [ : : :[Ln such ... |

236 | Tutorial notes on partial evaluation
- Consel, Danvy
- 1993
(Show Context)
Citation Context ...--a specialized version of the program, which on application to the remaining dynamic parameters produces the same result as the original program applied to all parameters. Offline partial evaluation =-=[10,18]-=- consists of two phases, binding-time analysis (BTA) and static reduction. BTA transforms a program and the binding times (static/dynamic) of the parameters into an annotated program. Subsequently, th... |

207 | Type-directed partial evaluation - Danvy |

173 | Partial evaluation of computation process an approach to a compiler-compiler. Higher Order Symbol
- Futamura
- 1999
(Show Context)
Citation Context ...fication for spec is the mix equation [18, 19]: Jp 0 K inp d = JpK inp s inp d where p 0 = JspecK p inp s (1) Double self-application of the specializer constructs a program-generator generatorscogen =-=[11, 37]-=-. This cogen is a generator of program generators. Consider again the program p with inputs inp s and inp d . Applying cogen to p yields a program p-gen with some interesting properties: p-gen = Jcoge... |

154 | Typed closure conversion
- Minamide, Morrisett, et al.
- 1996
(Show Context)
Citation Context ...esult of the 'static message is a list. Hence, we have to perform some variant of closure conversion [30]. It is, however, well-known that closure conversion is not straightforward in a typed setting =-=[26]-=-. The untyped appraoch closure conversion introduces a datatype AllClosures which has a constructor for each abstraction in the program. The constructor takes the values of the abstraction's free vari... |

122 |
An experiment in partial evaluation: The generation of a compiler generator
- Jones, Sestoft, et al.
- 1985
(Show Context)
Citation Context ... to partial evaluation, there is a specializer spec, a source program p, and some input data divided into a static part inp s and a dynamic part inp d . The specification for spec is the mix equation =-=[18, 19]-=-: Jp 0 K inp d = JpK inp s inp d where p 0 = JspecK p inp s (1) Double self-application of the specializer constructs a program-generator generatorscogen [11, 37]. This cogen is a generator of program... |

117 | Automatic autoprojection of recursive equations with global variables and abstract data types
- Bondorf, Danvy
- 1991
(Show Context)
Citation Context ...ic abstractions. This may introduce loops not present under standard evaluation. The most effective way to break these loops is to introduce new sp-functions for dynamic conditionals and abstractions =-=[5,7]-=-. With this setup the specializer only memoizes calls to sp-functions and unfolds all others. Partially Static Data Partially static data [27, 28] consists of a static skeleton and dynamic parts. For ... |

91 | Efficient type inference for higherorder binding-time analysis
- Henglein
- 1991
(Show Context)
Citation Context ...by monomorphic expansion. Applying Closure Analysis When we assume the availability of the explicitly typed source program (after type reconstruction) and the results of a closure analysis (see e.g., =-=[14, 33, 35]-=-), we can solve the typing problem. Suppose each program point is marked with a unique label ` 2 Labels. An (equational) flow analysis partitions Labels into disjoint flow classes L 1 [ : : :[Ln such ... |

90 |
Automatic autoprojection of higher order recursive equations
- Bondorf
- 1991
(Show Context)
Citation Context ...ic abstractions. This may introduce loops not present under standard evaluation. The most effective way to break these loops is to introduce new sp-functions for dynamic conditionals and abstractions =-=[5,7]-=-. With this setup the specializer only memoizes calls to sp-functions and unfolds all others. Partially Static Data Partially static data [27, 28] consists of a static skeleton and dynamic parts. For ... |

59 | Efficient multi-level generating extensions for program specialization
- Glück, Jørgensen
- 1995
(Show Context)
Citation Context ...ot just those that are amenable to specialization. A final point in favor of PGGs is the simplification of correctness proofs. By now, there are several PGGs for functional languages: SML [3], Scheme =-=[12]-=-, the lambda calculus [8, 23, 36]. 1 Overview of This Work The goal of PGGs in using the underlying language implementation to perform static computations conflicts with the necessity to provide an (i... |

54 | A tractable scheme implementation
- Kelsey, Rees
- 1994
(Show Context)
Citation Context ... PGGs. A cogen generated by self-application cannot utilize such a feature, as it is derived from a specializer which has its own implementation of environments. The current version 0.44 of Scheme 48 =-=[20]-=- has exactly the features that we need. Specifically, the procedures -- make-closure accepts a template (which contains a unique identification, literals, and code) and an environment (a vector) to bu... |

45 |
Partially static structures in a self-applicable partial evaluator
- Mogensen
- 1987
(Show Context)
Citation Context ...w sp-functions for dynamic conditionals and abstractions [5,7]. With this setup the specializer only memoizes calls to sp-functions and unfolds all others. Partially Static Data Partially static data =-=[27, 28]-=- consists of a static skeleton and dynamic parts. For example, a (static) pair can have a static component and a dynamic one; the length of a list may be known statically, but the elements of the list... |

44 | Partial evaluation of standard ML
- Birkedal, Welinder
- 1993
(Show Context)
Citation Context ... the program p with inputs inp s and inp d . Applying cogen to p yields a program p-gen with some interesting properties: p-gen = JcogenK p p 0 = Jp-genK inp s result = Jp 0 K inp d = JpK inp s inp d =-=(2)-=- p-gen is a program generator specific to p. It accepts the static input of p and produces a specialized residual program p 0 . For this reason p-gen is called a generating extension of p. The interes... |

42 |
Finiteness analysis
- Holst
- 1991
(Show Context)
Citation Context ...ble to compare two closures. If the closure representation is abstract, such a comparison is impossible. The termination of partial evaluation is usually addressed by means of program analysis. Holst =-=[15]-=- and Glenstrup and Jones [13] have defined enhanced BTA algorithms to ensure termination. Andersen and Holst [1] have defined a termination analysis for higher-order specialization. Our current approa... |

31 |
Separating binding times in language specifications
- Mogensen
- 1989
(Show Context)
Citation Context ...w sp-functions for dynamic conditionals and abstractions [5,7]. With this setup the specializer only memoizes calls to sp-functions and unfolds all others. Partially Static Data Partially static data =-=[27, 28]-=- consists of a static skeleton and dynamic parts. For example, a (static) pair can have a static component and a dynamic one; the length of a list may be known statically, but the elements of the list... |

29 |
Handwriting cogen to avoid problems with static typing
- Holst, Launchbury
- 1991
(Show Context)
Citation Context ...al: Specialization with generating extensions is usually four to ten times faster than direct specialization [5, 27] [18, Chapter 4.10]. Hand-written Program-Generator Generators Holst and Launchbury =-=[21]-=- have discovered that cogen can be written by hand. We call such a hand-written program-generator generator PGG. PGGs solve the infamous encoding problem which hindered the development of efficient se... |

28 |
Automatic call unfolding in a partial evaluator
- Sestoft
- 1988
(Show Context)
Citation Context ...s it builds on incremental specialization. Intricate call graph analyses have been developed to find a set of memoized calls which is as small as possible but still ensures terminating specialization =-=[19, 31, 32]-=-. Our algorithm to insert sp-functions is a variation of Bondorf and Danvy's algorithm [5, 7] which works satisfactory in practice. The idea of specializing data types to avoid type problems has been ... |

27 |
Hand-writing program generator generators
- Birkedal, Welinder
- 1994
(Show Context)
Citation Context ... language, not just those that are amenable to specialization. A final point in favor of PGGs is the simplification of correctness proofs. By now, there are several PGGs for functional languages: SML =-=[3]-=-, Scheme [12], the lambda calculus [8, 23, 36]. 1 Overview of This Work The goal of PGGs in using the underlying language implementation to perform static computations conflicts with the necessity to ... |

27 |
The structure of a self-applicable partial evaluator
- Sestoft
(Show Context)
Citation Context ...s it builds on incremental specialization. Intricate call graph analyses have been developed to find a set of memoized calls which is as small as possible but still ensures terminating specialization =-=[19, 31, 32]-=-. Our algorithm to insert sp-functions is a variation of Bondorf and Danvy's algorithm [5, 7] which works satisfactory in practice. The idea of specializing data types to avoid type problems has been ... |

27 | Cogen in six lines
- Thiemann
- 1996
(Show Context)
Citation Context ...nable to specialization. A final point in favor of PGGs is the simplification of correctness proofs. By now, there are several PGGs for functional languages: SML [3], Scheme [12], the lambda calculus =-=[8, 23, 36]-=-. 1 Overview of This Work The goal of PGGs in using the underlying language implementation to perform static computations conflicts with the necessity to provide an (intensional) equality for function... |

23 | BTA algorithms to ensure termination of off-line partial evaluation
- Glenstrup, Jones
- 1996
(Show Context)
Citation Context ...If the closure representation is abstract, such a comparison is impossible. The termination of partial evaluation is usually addressed by means of program analysis. Holst [15] and Glenstrup and Jones =-=[13]-=- have defined enhanced BTA algorithms to ensure termination. Andersen and Holst [1] have defined a termination analysis for higher-order specialization. Our current approach is orthogonal as it builds... |

21 |
An equational framework for the flow analysis of higher order functional programs
- Strfanescu, Zhou
- 1994
(Show Context)
Citation Context ...by monomorphic expansion. Applying Closure Analysis When we assume the availability of the explicitly typed source program (after type reconstruction) and the results of a closure analysis (see e.g., =-=[14, 33, 35]-=-), we can solve the typing problem. Suppose each program point is marked with a unique label ` 2 Labels. An (equational) flow analysis partitions Labels into disjoint flow classes L 1 [ : : :[Ln such ... |

20 |
Building interpreters by composing monads
- Jr
- 1994
(Show Context)
Citation Context ...ons is a variation of Bondorf and Danvy's algorithm [5, 7] which works satisfactory in practice. The idea of specializing data types to avoid type problems has been used before, for example by Steele =-=[34]-=-. 7 Conclusions We have presented four contributions to the implementation of memoization for partial evaluation. We have developed implementations of memoization for partially static functions, for u... |

19 |
Similix 5.0
- Bondorf
- 1993
(Show Context)
Citation Context ... function may have free variables with dynamic components. Partially static data increases the power of a partial evaluator considerably. It is a standard feature of current partial evaluators (e.g., =-=[6, 9]-=-). Program-Generator Generators In the standard approach to partial evaluation, there is a specializer spec, a source program p, and some input data divided into a static part inp s and a dynamic part... |

15 | Improving CPS-based partial evaluation: Writing cogen by hand
- Bondorf, Dussart
- 1994
(Show Context)
Citation Context ...nable to specialization. A final point in favor of PGGs is the simplification of correctness proofs. By now, there are several PGGs for functional languages: SML [3], Scheme [12], the lambda calculus =-=[8, 23, 36]-=-. 1 Overview of This Work The goal of PGGs in using the underlying language implementation to perform static computations conflicts with the necessity to provide an (intensional) equality for function... |

14 |
A tour of Schism
- Consel
(Show Context)
Citation Context ... function may have free variables with dynamic components. Partially static data increases the power of a partial evaluator considerably. It is a standard feature of current partial evaluators (e.g., =-=[6, 9]-=-). Program-Generator Generators In the standard approach to partial evaluation, there is a specializer spec, a source program p, and some input data divided into a static part inp s and a dynamic part... |

14 |
The use of metasystem transition in theorem proving and program optimization
- Turchin
- 1980
(Show Context)
Citation Context ...fication for spec is the mix equation [18, 19]: Jp 0 K inp d = JpK inp s inp d where p 0 = JspecK p inp s (1) Double self-application of the specializer constructs a program-generator generatorscogen =-=[11, 37]-=-. This cogen is a generator of program generators. Consider again the program p with inputs inp s and inp d . Applying cogen to p yields a program p-gen with some interesting properties: p-gen = Jcoge... |

12 | Termination analysis for offline partial evaluation of a higher order functional language
- Andersen, Holst
- 1996
(Show Context)
Citation Context ...ination of partial evaluation is usually addressed by means of program analysis. Holst [15] and Glenstrup and Jones [13] have defined enhanced BTA algorithms to ensure termination. Andersen and Holst =-=[1]-=- have defined a termination analysis for higher-order specialization. Our current approach is orthogonal as it builds on incremental specialization. Intricate call graph analyses have been developed t... |

7 | The Scheme of things: The
- Rees
- 1992
(Show Context)
Citation Context ...xtracts the unique identification from a template, and -- closure-env extracts the environment from a closure. This is all we need to get things to work. 5 Incremental Memoization In Scheme with eval =-=[29]-=-, generating extensions can perform incremental specialization just by changing the memoization code. The idea is that the specializer only processes code when there is a demand to run it. No time is ... |

2 |
Continuation-based partial evaluation. Extended version of [22] from ftp://ftp.daimi.aau.dk/pub/danvy/Papers
- Lawall, Danvy
- 1995
(Show Context)
Citation Context ...nable to specialization. A final point in favor of PGGs is the simplification of correctness proofs. By now, there are several PGGs for functional languages: SML [3], Scheme [12], the lambda calculus =-=[8, 23, 36]-=-. 1 Overview of This Work The goal of PGGs in using the underlying language implementation to perform static computations conflicts with the necessity to provide an (intensional) equality for function... |