Abstract
Program specialization can divide a computation into several computation stages. This paper investigates the theoretical limitations and practical problems of standard specialization tools, presents multi-level specialization, and demonstrates that, in combination with the cogen approach, it is far more practical than previously supposed. The program generator which we designed and implemented for a higher-order functional language converts programs into very compact multi-level generating extensions that guarantee fast successive specialization. Experimental results show a remarkable reduction of generation time and generator size compared to previous attempts of multi-level specialization by self-application. Our approach to multi-level specialization seems well-suited for applications where generation time and program size are critical.
Similar content being viewed by others
References
Andersen, L.O. Program analysis and specialization for the C programming language. Ph.D. Thesis, DIKU Report 94/19. Dept. of Computer Science, University of Copenhagen, 1994.
Andersen, P.H. and Holst, C.K. Termination analysis for offline partial evaluation of a higher order functional language. In Static Analysis, R. Cousot and D. Schmidt (Eds.). Springer-Verlag, Lecture Notes in Computer Science, vol. 1145, pp. 67–82, 1996.
Barklund, J., Boberg, K., Dell'Acqua, P., and Veanes, M. Meta-programming with theory systems, In Meta-Logics and Logic Programming, K. Apt and F. Turini (Eds.), Logic Programming, MIT Press, pp. 195–224, 1995.
Beckman, L., Haraldson, A., Oskarsson, Ö., and Sandewall, E. A partial evaluator and its use as a programming tool. Artificial Intelligence, 7:319–357, 1976.
Birkedal, L. and Welinder, M. Partial evaluation of Standard ML. DIKU Report 93/22. Dept. of Computer Science, University of Copenhagen, 1993.
Birkedal, L. and Welinder, M. Binding-time analysis for Standard ML. Lisp and Symbolic Computation, 8(3):191–208, 1995.
Birkedal, L. and Welinder, M. Hand-writing program generator generators. In Programming Language Implementation and Logic Programming, M. Hermenegildo and J. Penjam (Eds.). Springer-Verlag, Lecture Notes in Computer Science, vol. 844, pp. 198–214, 1994.
Bjørner, D., Ershov, A.P., and Jones, N.D. (Eds.). Partial Evaluation and Mixed Computation. North-Holland, 1988.
Bondorf, A. Self-Applicable Partial Evaluation. Ph.D. Thesis, Report 90/17. DIKU Dept. of Computer Science, University of Copenhagen, 1990.
Bondorf, A. Automatic autoprojection of higher order recursive equations. Science of Computer Programming, 17(1-3):3–34, 1991.
Bondorf, A. and Danvy, O. Automatic autoprojection of recursive equations with global variables and abstract data types. Science of Computer Programming, 16:151–195, 1991.
Bondorf, A. and Jørgensen, J. Efficient analyses for realistic off-line partial evaluation. Journal of Functional Programming, 3(3):315–346, 1993.
Bondorf, A. and Dussart, D. Improving cps-based partial evaluation: Writing cogen by hand. In ACM SIGPLAN Workshop on Partial Evaluation and Semantics-Based Program Manipulation, Technical Report 94/9. University of Melbourne, Australia, pp. 1–9, 1994.
Bulyonkov, M.A. Polyvariant mixed computation for analyzer programs. Acta Informatica, 21:473–484, 1984.
Cardone, F. and Coppo, M. Type inference with recursive types: Syntax and semantics. Information and Computation, 92:48–80, 1991.
Consel, C. A tour of Schism: a partial evaluation system for higher-order applicative languages. In Proceedings of the Symposium on Partial Evaluation and Semantics-Based Program Manipulation. ACM Press, pp. 145–154, 1993.
Consel, C. and Danvy, O. From interpreting to compiling binding times. In ESOP '90, N.D. Jones (Ed.). Springer-Verlag, Lecture Notes in Computer Science, vol. 432, pp. 88–105, 1990.
Danvy, O., Glück, R., and Thiemann, P. (Eds.). Partial Evaluation. Springer-Verlag, Lecture Notes in Computer Science, vol. 1110, 1996.
Davies, R. and Pfenning, F. A modal analysis of staged computation. In Symposium on Principles of Programming Languages. ACM Press, pp. 258-270, 1996.
Ershov, A.P. On the essence of compilation. In Formal Description of Programming Concepts, E.J. Neuhold (Ed.). North-Holland, pp. 391–420, 1978.
Futamura, Y. Partial evaluation of computation process—An approach to a compiler-compiler. Systems, Computers, Controls, 2(5):45–50, 1971.
Glenstrup, A. and Jones, N.D. BTA algorithms to ensure termination of off-line partial evaluation. In Perspectives of System Informatics, D. Bjørner, M. Broy, and I.V. Pottosin (Eds.). Springer-Verlag, Lecture Notes in Computer Science, vol. 1181, pp. 273–284, 1996.
Glück, R. Towards multiple self-application. In Proceedings of the Symposium on Partial Evaluation and Semantics-Based Program Manipulation. ACM Press, pp. 309–320, 1991.
Glück, R. On the generation of specializers. Journal of Functional Programming, 4(4):499–514, 1994.
Glück, R. and Jørgensen, J. Generating transformers for deforestation and supercompilation. In Static Analysis, B. Le Charlier (Ed.). Springer-Verlag, Lecture Notes in Computer Science, vol. 864, pp. 432–448, 1994.
Glück, R. and Jørgensen, J. Efficient multi-level generating extensions for program specialization. In Programming Languages, Implementations, Logics and Programs, M. Hermenegildo and S.D. Swierstra (Eds.). Springer-Verlag, Lecture Notes in Computer Science, vol. 982, pp. 259–278, 1995.
Glück, R. and Jørgensen, J. Fast binding-time analysis for multi-level specialization. In Perspectives of System Informatics, D. Bjørner, M. Broy, and I.V. Pottosin (Eds.). Springer-Verlag, Lecture Notes in Computer Science, vol. 1181, pp. 261–272, 1996.
Gomard, C.K. and Jones, N.D. A partial evaluator for the untyped lambda calculus. Journal of Functional Programming, 1(1):21–69, 1991.
Hatcliff, J. Mechanically verifying the correctness of an off-line partial evaluator. In Programming Languages, Implementations, Logics and Programs, M. Hermenegildo and S.D. Swierstra (Eds.). Springer-Verlag, Lecture Notes in Computer Science, vol. 982, pp. 279–298, 1995.
Henglein, F. Efficient type inference for higher-order binding-time analysis. In Functional Programming and Computer Architecture, J. Hughes (Ed.). Springer-Verlag, Lecture Notes in Computer Science, vol. 523, pp. 448–472, 1991.
Holst, C.K. Syntactic currying: Yet another approach to partial evaluation. Technical report. DIKU, Department of Computer Science, University of Copenhagen, 1989.
Holst, C.K. and Launchbury, J. Handwriting cogen to avoid problems with static typing. Working paper, 1992.
IEEE. Standard for the Scheme programming language. IEEE Std 1178-1990, Institute of Electrical and Electronics Engineers, 1991.
Jones, N.D. (Ed.). Semantics-Directed Compiler Generation Proceedings, Springer-Verlag, Lecture Notes in Computer Science, vol. 94, 1980.
Jones, N.D., Sestoft, P., and Søndergaard, H. An experiment in partial evaluation: the generation of a compiler generator. In Rewriting Techniques and Applications, J.-P. Jouannaud (Ed.). Springer-Verlag, Lecture Notes in Computer Science, vol. 202, pp. 124–140, 1985.
Jones, N.D., Sestoft, P., and Søndergaard, H. Mix: A self-applicable partial evaluator for experiments in compiler generation. Lisp and Symbolic Computation, 2(1):9–50, 1989.
Jones, N.D., Gomard, C.K., and Sestoft, P. Partial Evaluation and Automatic Program Generation. Prentice Hall International Series in Computer Science, Prentice-Hall, 1993.
Jørgensen, J. and Leuschel, M. Efficiently generating efficient generating extensions in Prolog. In [18], pp. 238–262, 1996.
Jørring, U. and Scherlis, W. Compilers and staging transformations. In Conference Record of the Thirteenth ACM Symposium on Principles of Programming Languages. ACM, pp. 86–95, 1986.
Lawall, J. and Danvy, O. Continuation-based partial evaluation. In ACM Conference on Lisp and Functional Programming, ACM Press. pp. 227-238, 1994.
Mogensen, T.Æ . Partially static structures in a self-applicable partial evaluator. In [8], pp. 325–347, 1988.
Nielson, F. and Nielson, H.R. Two-Level Functional Languages, Cambridge Tracts in Theoretical Computer Science. Cambridge University Press, Vol. 34, 1992.
Nielson, F. and Nielson, H.R. Multi-level lambda-calculus: An algebraic description. In [18], pp. 338–354, 1996.
Romanenko, S.A. A compiler generator produced by a self-applicable specializer can have a surprisingly natural and understandable structure. In [8], pp. 445–463, 1988.
Schmidt, David A. Denotational Semantics, a Methodology for Language Development. Allyn and Bacon, 1986.
Sørensen, M.H., Glück, R., and Jones, N.D. A positive supercompiler. Journal of Functional Programming, 1996 (to appear).
Taha, W. and Sheard, T. Multi-stage programming with explicit annotations. In ACM SIGPLAN Symposium on Partial Evaluation and Semantics-Based Program Manipiulation. ACP Press, 1997 (to appear).
Tennent, R.D. Principles of Programming Languages. Prentice Hall International Series in Computer Science. Prentice Hall, 1981.
Thiemann, P. Cogen in six lines. In International Conference on Functional Programming. ACM Press, 1996, pp. 180–189.
Thiemann, P. Towards partial evaluation of full Scheme. In Reflection'96, G. Kiczales (Ed.), pp. 105–116, 1996.
Turchin, V.F. Refal-5, Programming Guide and Reference Manual. New England Publishing Co., Holyoke, Massachusetts, 1989.
Wand, M. Specifying the correctness of binding-time analysis. Journal of Functional Programming, 3(3):365–387, 1993.
Author information
Authors and Affiliations
Rights and permissions
About this article
Cite this article
Glück, R., Jørgensen, J. An Automatic Program Generator for Multi-Level Specialization. Higher-Order and Symbolic Computation 10, 113–158 (1997). https://doi.org/10.1023/A:1007763000430
Issue Date:
DOI: https://doi.org/10.1023/A:1007763000430