Self-applicable online partial evaluation

  • Michael Sperber
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 1110)


We propose a hybrid approach to partial evaluation to achieve self-application of realistic online partial evaluators. Whereas the offline approach to partial evaluation leads to efficient specializers and self-application, online partial evaluators perform better specialization at the price of efficiency. Moreover, no online partial evaluator for a realistic higher-order language has been successfully self-applied. We present a binding-time analysis for an online partial evaluator for a higher-order subset of Scheme. The analysis distinguishes between static, dynamic, and unknown binding times. Thus, it makes some reduce/residualize decisions offline while leaving others to the specializer. We have implemented the binding-time analysis and an online specializer to go with it. After a standard binding-time improvement, our partial evaluator successfully self-applies. Our work confirms the practicality of an idea by Morry Katz.


online partial evaluation offline partial evaluation self-application compiler generation binding-time analysis 


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    ACM. Proc. 1991 ACM Functional Programming Languages and Computer Architecture, Cambridge, September 1991.Google Scholar
  2. 2.
    Anders Bondorf. A self-applicable partial evaluator for term rewriting systems. In J. Diaz and F. Orejas, editors, TAPSOFT '89. Proc. Int. Conf. Theory and Practice of Software Development, Barcelona, Spain. (Lecture Notes in Computer Science, Vol. 352), pages 81–95. Springer-Verlag, March 1989.Google Scholar
  3. 3.
    Anders Bondorf. Self-applicable partial evaluation. PhD thesis, DIKU, University of Copenhagen, 1990. DIKU Report 90/17.Google Scholar
  4. 4.
    Anders Bondorf. Automatic autoprojection of higher order recursive equations. Science of Computer Programming, 17:3–34, 1991.Google Scholar
  5. 5.
    Anders Bondorf and Jesper Jørgensen. Efficient analyses for realistic off-line partial evaluation. Journal of Functional Programming, 3(3):315–346, July 1993.Google Scholar
  6. 6.
    Charles Consel. Polyvariant binding-time analysis for applicative lanuages. In Symp. Partial Evaluation and Semantics-Based Program Manipulation '93, pages 66–77, Copenhagen, Denmark, June 1993. ACM.Google Scholar
  7. 7.
    Olivier Danvy, Robert Glück, and Peter Thiemann, editors. Dagstuhl Seminar on Partial Evaluation 1996. Springer-Verlag, 1996. LNCS.Google Scholar
  8. 8.
    Olivier Danvy, Karoline MalmkjÆr, and Jens Palsberg. The essence of etaexpansion in partial evaluation. Lisp and Symbolic Computation, 8(1):1–19, 1995.Google Scholar
  9. 9.
    Dirk Dussart, Fritz Henglein, and Christian Mossin. Polymorphic recursion and subtype qualifications: Polymorphic binding-time analysis in polynomial time. In Proc. 2nd Int'l Static Analysis Symposium (SAS), Glasgow, Scotland, Lecture Notes in Computer Science. Springer-Verlag, September 1995.Google Scholar
  10. 10.
    Y. Futamura. Partial evaluation of computation process-an approach to a compiler-compiler. Systems, Computers, Controls, 2(5):45–50, 1971.Google Scholar
  11. 11.
    Yoshihiko Futamura, Kenroku Nogi, and Aki Takano. Essence of generalized partial computation. Theoretical Computer Science, 90(1):61–79, 1991.Google Scholar
  12. 12.
    Robert Glück. Towards multiple self-application. In Proc. Partial Evaluation and Semantics-Based Program Manipulation '91, pages 309–320, New Haven, June 1991. ACM. SIGPLAN Notices 26(9).Google Scholar
  13. 13.
    Robert Glück. On the generation of specializers. Journal of Functional Programming, 4(4):499–514, October 1994.Google Scholar
  14. 14.
    Robert Glück and Jesper Jørgensen. Generating optimizing specializers. In IEEE International Conference on Computer Languages, pages 183–194. IEEE Computer Society Press, 1994.Google Scholar
  15. 15.
    Robert Glück and Jesper Jørgensen. Efficient multi-level generating extensions for program specialization. In Programming Language Implementation and Logic Programming 1995. Springer-Verlag, 1995. LNCS.Google Scholar
  16. 16.
    Robert Glück and Andrei V. Klimov. Occam's razor in metacomputation: the notion of a perfect process tree. In Static Analysis, volume 724 of Lecture Notes in Computer Science, pages 112–123. Springer-Verlag, 1993.Google Scholar
  17. 17.
    Robert Glück and Jesper Jørgensen. Generating transformers for deforestation and supercompilation. In B. Le Charlier, editor, Static Analysis, volume 864 of Lecture Notes in Computer Science, pages 432–448. Springer-Verlag, 1994.Google Scholar
  18. 18.
    John Hatcliff and Robert Glück. Reasoning about hierarchies of online program specialization systems. In Danvy et al. [7]. to appear.Google Scholar
  19. 19.
    Fritz Henglein. Efficient type inference for higher-order binding-time analysis. In FPCA1991 [1], pages 448–472.Google Scholar
  20. 20.
    Fritz Henglein and Christian Mossin. Polymorphic binding-time analysis. In Donald Sannella, editor, Proceedings of European Symposium on Programming, volume 788 of Lecture Notes in Computer Science, pages 287–301. Springer-Verlag, April 1994.Google Scholar
  21. 21.
    IEEE. Standard for the Scheme programming language. Technical Report 1178-1990, Institute of Electrical and Electronic Engineers, Inc., New York, 1991.Google Scholar
  22. 22.
    Neil D. Jones. What not to do when writing an interpreter for specialisation. In Danvy et al. [7]. to appear.Google Scholar
  23. 23.
    Neil D. Jones, Carsten K. Gomard, and Peter Sestoft. Partial Evaluation and Automatic Program Generation. Prentice-Hall, 1993.Google Scholar
  24. 24.
    Neil D. Jones, Peter Sestoft, and Harald Søndergaard. An experiment in partial evaluation: The generation of a compiler generator. In J.-P. Jouannaud, editor, Rewriting Techniques and Applications, pages 124–140, Dijon, France, 1985. Springer-Verlag. LNCS 202.Google Scholar
  25. 25.
    Jesper Jørgensen. Compiler generation by partial evaluation. Master's thesis, DIKU, University of Copenhagen, 1991.Google Scholar
  26. 26.
    Torben Æ. Mogensen. Self-applicable online partial evaluation of pure lambda calculus. In Scherlis [32], pages 39–44.Google Scholar
  27. 27.
    Torben Æ. Mogensen, Binding time analysis for polymorphically typed higher order languages. In J. Díaz and F. Orejas, editors, TAPSOFT '89, pages II, 298–312, Barcelona, Spain, March 1989. Springer-Verlag. LNCS 351,352.Google Scholar
  28. 28.
    Andrei P. Nemytykh, Victoria A. Pinchuk, and Valentin P. Turchin. A self-applicable supercompiler. In Danvy et al. [7]. to appear.Google Scholar
  29. 29.
    Sergei A. Romanenko. Arity raiser and its use in program specialization. In Neil D. Jones, editor, European Symposium on Programming 1990, pages 341–360, Copenhagen, Denmark, 1990. Springer-Verlag. LNCS 432.Google Scholar
  30. 30.
    Erik Ruf. Topics in Online Partial Evaluation. PhD thesis, Stanford University, Stanford, CA 94305-4055, March 1993. Technical report CSL-TR-93-563.Google Scholar
  31. 31.
    Erik Ruf and Daniel Weise. On the specialization of online program specializers. Journal of Functional Programming, 3(3):251–281, July 1993.Google Scholar
  32. 32.
    William Scherlis, editor. ACM SIGPLAN Symp. Partial Evaluation and Semantics-Based Program Manipulation '95, La Jolla, CA, June 1995. ACM Press.Google Scholar
  33. 33.
    Michael Sperber, Robert Glück, and Peter Thiemann. Bootstrapping higher-order program transformers from interpreters. In 1996 ACM Symposium on Applied Computing Programming Languages Track, pages 408–413, Philadelphia, 1996.Google Scholar
  34. 34.
    Michael Sperber and Peter Thiemann. The essence of LR parsing. In Scherlis [32], pages 146–155.Google Scholar
  35. 35.
    Michael Sperber and Peter Thiemann. Turning an art into a craft: Automatic binding-time improvement. submitted, 1995.Google Scholar
  36. 36.
    Michael Sperber and Peter Thiemann. Realistic compilation by partial evaluation. In Conference on Programming Language Design and Implementation '96, Philadelphia, May 1996. ACM. to appear.Google Scholar
  37. 37.
    Morten Heine Sørensen, Robert Glück, and Neil D. Jones. Towards unifying partial evaluation, deforestation, supercompilation, and GPC. In Donald Sannella, editor, Proc. 5th European Symposium on Programming, pages 485–500, Edinburgh, UK, April 1994. Springer-Verlag. LNCS 788.Google Scholar
  38. 38.
    Peter Thiemann. Type-based termination analysis for partial evaluation. Technical Report WSI-95-XX, Universität Tübingen, September 1995.Google Scholar
  39. 39.
    Peter Thiemann and Robert Glück. The generation of a higher-order online partial evaluator. In Masato Takeichi, editor, Fuji Workshop on Functional and Logic Programming, pages 239–253, Fuji Susono, Japan, July 1995. World Scientific Press, Singapore.Google Scholar
  40. 40.
    Valentin F. Turchin. The concept of a supercompiler. ACM Transactions on Programming Languages and Systems, 8(3):292–325, July 1986.Google Scholar
  41. 41.
    Daniel Weise, Roland Conybeare, Erik Ruf, and Scott Seligman. Automatic online partial evaluation. In FPCA1991 [1], pages 165–191.Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 1996

Authors and Affiliations

  • Michael Sperber
    • 1
  1. 1.Wilhelm-Schickard-Institut für InformatikUniversität TübingenTübingenGermany

Personalised recommendations