Based on Henglein's efficient binding-time analysis for the lambda calculus (with constants and ‘fix’) (Henglein, 1991), we develop three efficient analyses for use in the preprocessing phase of Similix, a self-applicable partial evaluator for a higher-order subset of Scheme. The analyses developed in this paper are almost-linear in the size of the analysed program. (1) A flow analysis determines possible value flow between lambda-abstractions and function applications and between constructor applications and selector/predicate applications. The flow analysis is not particularly biased towards partial evaluation; the analysis corresponds to the closure analysis of Bondorf (1991b). (2) A (monovariant) binding-time analysis distinguishes static from dynamic values; the analysis treats both higher-order functions and partially static data structures. (3) A new is-used analysis , not present in Bondorf (1991b), finds a non-minimal binding-time annotation which is ‘safe’ in a certain way: a first-order value may only become static if its result is ‘needed’ during specialization; this ‘poor man's generalization’ (Holst, 1988) increases termination of specialization. The three analyses are performed sequentially in the above mentioned order since each depends on results from the previous analyses. The input to all three analyses are constraint sets generated from the program being analysed. The constraints are solved efficiently by a normalizing union/find-based algorithm in almost-linear time. Whenever possible, the constraint sets are partitioned into subsets which are solved in a specific order; this simplifies constraint normalization. The framework elegantly allows expressing both forwards and backwards components of analyses. In particular, the new is-used analysis is of backwards nature. The three constraint normalization algorithms are proved correct (soundness, completeness, termination, existence of a best solution). The analyses have been implemented and integrated in the Similix system. The new analyses are indeed much more efficient than those of Bondorf (1991b); the almost-linear complexity of the new analyses is confirmed by the implementation.
[1]
Peter Sestoft,et al.
An experiment in partial evaluation: the generation of a compiler generator
,
1985,
SIGP.
[2]
Peter Sestoft,et al.
An experiment in partial evaluation: the generation of a compiler generator
,
1985,
SIGP.
[3]
Flemming Nielson,et al.
Automatic Binding Time Analysis for a Typed lambda-Calculus
,
1988,
Sci. Comput. Program..
[4]
Neil D. Jones,et al.
Mix: A self-applicable partial evaluator for experiments in compiler generation
,
1989,
LISP Symb. Comput..
[5]
John Launchbury,et al.
Projection factorisations in partial evaluation
,
1991
.
[6]
Peter Sestoft,et al.
Replacing function parameters by global variables
,
1989,
FPCA.
[7]
Anders Bondorf,et al.
Automatic Autoprojection of Higher Order Recursive Equations
,
1990,
Sci. Comput. Program..
[8]
Charles Consel,et al.
Binding time analysis for high order untyped functional languages
,
1990,
LISP and Functional Programming.
[9]
Fritz Henglein,et al.
Efficient Type Inference for Higher-Order Binding-Time Analysis
,
1991,
FPCA.
[10]
Anders Bondorf,et al.
Automatic Autoprojection of Recursive Equations with Global Variables and Abstract Data Types
,
1991,
Sci. Comput. Program..
[11]
Neil D. Jones,et al.
A partial evaluator for the untyped lambda-calculus
,
1991,
Journal of Functional Programming.
[12]
Daniel Weise,et al.
Towards a New Perspective on Partial Evaluation
,
1992,
PEPM.
[13]
Jesper Jørgensen,et al.
Generating a compiler for a lazy language by partial evaluation
,
1992,
POPL '92.
[14]
Anders Bondorf,et al.
Improving binding times without explicit CPS-conversion
,
1992,
LFP '92.
[15]
J. Jørgensen,et al.
Efficient Analyses for Realistic Off-Line Partial Evaluation : Extended Version
,
1993
.
[16]
Mitchell Wand,et al.
Specifying the correctness of binding-time analysis
,
1993,
POPL '93.
[17]
Jens Palsberg,et al.
Correctness of binding-time analysis
,
1993,
Journal of Functional Programming.