Multiple Specialization of WAM Code

  • Michel Ferreira
  • Luís Damas
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 1551)


Program specialization is normally supported by global analysis of the program. Compilers use the information deduced to generate more efficient, specialized implementations of the program. This specialization can be single or multiple, depending if each procedure of the program is specialized into one or more versions. We present a Prolog compiler that does multiple specialization, using an algorithm that works over the WAM code, deducing the reachable procedure activations based on local analysis. The idea is to use the analysis that is done in the Prolog to WAM compilation, and that generates local specialized instructions, and to propagate this information through the entire program. The creation of multiple versions of predicates allows the propagation to be interprocedural, and to achieve global program specialization. Results from an implementation generating C code as target language are presented, showing a performance comparable to native code Prolog compilers.


Prolog Compilation Code Specialization Program Analysis 


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. [1]
    Hassan Aït-Kaci. Warren’s Abstract Machine — A Tutorial Reconstruction. MIT Press, 1991.Google Scholar
  2. [2]
    M. Bruynooghe and G. Jenssens. An instance of abstract interpretation integrating type and mode inferencing. In Proc. of ICSLP’88, pages 669–683, Seattle, Washington, 1988. MIT Press.Google Scholar
  3. [3]
    Philippe Codognet and Daniel Diaz. wamcc: Compiling Prolog to C. In Proc. of ICLP’95. MIT Press, 1995.Google Scholar
  4. [4]
    P. Cousot and R. Cousot. Abstract interpretation: A unified lattice model for static analysis of programs by construction or approximation of fixpoints. In Proc. of SPPL’77, pages 238–252, Los Angeles, California, 1977.Google Scholar
  5. [5]
    S. K. Debray and D. S. Warren. Automatic mode inference for prolog programs. The Journal of Logic Programming, 5(3):78–88, September 1988.CrossRefMathSciNetGoogle Scholar
  6. [6]
    D. Gudeman, K. De Bosschere, and S. Debray. jc: An efficient and portable sequential implementation of janus. In Joint International Conference and Symposium on Logic Programming, Washington, 1992. “MIT Press”.Google Scholar
  7. [7]
    B. Haussman. Turbo Erlang: Approaching the Speed of C. In Evan Tick, editor, Implementations of Logic Programming Systems. Kluwer, 1994.Google Scholar
  8. [8]
    M. Hermenegildo, R. Warren, and S. K. Debray. Global Flow Analysis as a Practical Compilation Tool. JLP, 13(4):349–367, August 1992.Google Scholar
  9. [9]
    D. Jacobs and A. Langen. Accurate and efficient approximation of variable aliasing in logic programs. In Proc. NACLP’89, pages 154–165. “MIT Press”, 1989.Google Scholar
  10. [10]
    A. Krall and U. Neumerkel. The Vienna Abstract Machine. In Proc. of PLIP”90, number 456 in LNCS, pages 121–135. Sweeden, Springer-Verlag, 1990.Google Scholar
  11. [11]
    C. S. Mellish. Abstract interpretation of prolog programs. In Proc of ICLP’86, number 225 in Lecture Notes in Computer Science. Springer-Verlag, 1986.Google Scholar
  12. [12]
    S. Peyton Jones, T. Nordin, and D. Oliva. C-: a portable assembly language. In [To appear in the proceedings of IFL’97]., St. Andrews, Scotland, 1997.Google Scholar
  13. [13]
    J. Tan and I. Lin. Compiling dataflow analysis of logic programs. In Proc. of PLDI’92, pages 106–115, San Francisco, California, 1992. SIGPLAN.Google Scholar
  14. [14]
    A. Taylor. High Performance Prolog Implementation. PhD thesis, University of Sydney, June 1991.Google Scholar
  15. [15]
    P. Van Roy. Can Logic Programming Execute as Fast as Imperative Programming? PhD thesis, University of California at Berkeley, November 1990.Google Scholar
  16. [16]
    P. Van Roy. 1983–1993: The Wonder Years of Sequential Prolog Implementation. The Journal of Logic Programming, 19/20, May/July 1994.Google Scholar
  17. [17]
    David H. D. Warren. An Abstract Prolog Instruction Set. Technical Note 309, SRI International, 1983.Google Scholar
  18. [18]
    W. H. Winsborough. Path-dependent reachability analysis for multiple specialization. In Proc. of NACLP’89. “MIT Press”, 1989.Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 1998

Authors and Affiliations

  • Michel Ferreira
    • 1
  • Luís Damas
    • 1
  1. 1.DCC-FC & LIACCUniversity of PortoPortoPortugal

Personalised recommendations