Skip to main content

Generating efficient code for lazy functional languages

  • Conference paper
  • First Online:
Functional Programming Languages and Computer Architecture (FPCA 1991)

Part of the book series: Lecture Notes in Computer Science ((LNCS,volume 523))

Abstract

In this paper we will discuss how a good code generator can be built for (lazy) functional languages. Starting from Concurrent Clean, an experimental lazy functional programming language, code is generated for an intermediate abstract machine: the ABC machine. In this first pass many well-known optimisation techniques are included. However, we will also present some new ideas in this area, like the way in which strictness can be incorporated, and the implementation of higher order functions. In a second pass, the ABC code is translated to concrete target code for the Motorola MC680x0 processor. Again many optimisation methods appear to be applicable. Some of them (for example register allocation algorithms) are common for the implementation of other types of languages, but have to be adapted because of the specific properties of both source language and target machine. Other optimisations are specific for lazy functional languages, e.g. the implementation of higher order functions, efficient memory management and the optimised graph reduction. Measurements demonstrate that due to the optimisations of both passes very fast code can be generated. We have compared Concurrent Clean with two other functional languages, namely Lml and Hope, and also with the imperative language C. With respect to both functional languages this comparison clearly goes in favour of Concurrent Clean. Furthermore, we can conclude that, when using the presented compilation techniques, a lazy functional language is able to compete even with an imperative language such as C.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  • Aho A.V., Sethi R., Ullman J.D. (1986), ‘Compilers, Principles, Techniques and Tools', Bell Telephone Laboratories, Incorporated, Addison-Wesley.

    Google Scholar 

  • Augustsson L., Johnsson T. (1989), ‘The Chalmers Lazy-ML Compiler', The Computer Journal, Vol. 32, No. 2 1989.

    Google Scholar 

  • Barendregt, H.P., Eekelen, M.C.J.D. van, Glauert, J.R.W., Kennaway, J.R., Plasmeijer, M.J., Sleep, M.R. (1987), ‘Term Graph Reduction', Proceedings of Parallel Architectures and Languages Europe (PARLE), part II, Eindhoven, The Netherlands, LNCS Vol. 259, pp. 141–158, June 1987.

    Google Scholar 

  • Brus T., Eekelen M.C.J.D. van, Leer M. van, Plasmeijer M.J. (1987), ‘Clean — a Language for Functional Graph Rewriting', Proc. of the third International Conference on Functional Programming Languages and Computer Architecture (FPCA '87), Portland, Oregon, USA, Springer Lecture Notes on Computer Science 274, pp. 346–384.

    Google Scholar 

  • Burstall, R.M., MacQueen, D.B., and Sanella, D.T. (1980), ‘Hope: An Experimental Applicative Language', Proceedings of the 1980 LISP Conference, 136–143.

    Google Scholar 

  • Eekelen, M.C.J.D. van (1988), ‘Parallel Graph Rewriting, Some Contributions to its Theory, its Implementation and its Application', Ph.D. Thesis, University of Nijmegen, December 1988.

    Google Scholar 

  • Eekelen M.C.J.D. van, Nöcker E.G.J.M.H., Plasmeijer M.J., Smetsers J.E.W. (1990), ‘Concurrent Clean, version 0.6', Technical Report 90-21, University of Nijmegen, December 1990.

    Google Scholar 

  • Eekelen, M.C.J.D. van, Plasmeijer, M.J., Smetsers, J.E.W. (1991). ‘Parallel Graph Rewriting on Loosely Coupled Machine Architectures’ proceedings of the workshop on CTRS'90. Montreal Canada. To appear in 1991.

    Google Scholar 

  • Groningen J.H.G. van. (1990), ‘Implementing the ABC-machine on M680x0 based architectures'. Master Thesis, University of Nijmegen, November 1990.

    Google Scholar 

  • Johnsson Th. (1987), ‘Compiling Lazy Functional Programming languages'. Dissertation at Chalmers University, Göteborg, Sweden. ISBN 91-7032-280-5.

    Google Scholar 

  • Kesseler M.H.G., (1990), ‘Concurrent Clean on Transputers', Master Thesis, University of Nijmegen, November 1990.

    Google Scholar 

  • Koopman P.W.M., Eekelen M.C.J.D. van, Nöcker E.G.J.M.H., Smetsers J.E.W., Plasmeijer M.J. (1990). ‘The ABC-machine: A Sequential Stack-based Abstract Machine For Graph Rewriting'. Technical Report no. 90-22, December 1990, University of Nijmegen.

    Google Scholar 

  • McBurney D. and Sleep R. (1990), ‘Concurrent Clean on Zapp', Proceedings of the Second International Workshop on Implementations of Functional Languages on Distributed Architectures, University of Nijmegen, November 1990.

    Google Scholar 

  • Milner R.A. (1978). Theory of Type Polymorphism in Programming. Journal of Computer and System Sciences, Vol. 17, no. 3, 348–375.

    Google Scholar 

  • Motorola, (1985, 1984), ‘MC68020 32-Bit Microprocessor User's Manual', Second Edition, Motorola, Prentice Hall.

    Google Scholar 

  • Mycroft A. (1984). Polymorphic type schemes and recursive definitions. Proc. of the 6th Int. Conf. on Programming, Spriger Lec. Notes Comp. Sci. 167, 217–228.

    Google Scholar 

  • Nöcker E.G.J.M.H., (1989). ‘The PABC Simulator, v0.5. Implementation Manual'. University of Nijmegen, Technical Report 89-19.

    Google Scholar 

  • Nöcker E.G.J.M.H. (1990). 'strictness Analysis based on Abstract Reduction', in Proceedings of the Second International Workshop on Implementation of Functional Languages on Parallel Architectures, pp. 297–321, Technical Report no. 90-16, October 1990, University of Nijmegen.

    Google Scholar 

  • Nöcker E.G.J.M.H., Smetsers J.E.W., (1990). ‘Partially Strict Data Types', in Proceedings of the Second International Workshop on Implementation of Functional Languages on Parallel Architectures, pp. 237–255, Technical Report no. 90-16, October 1990, University of Nijmegen.

    Google Scholar 

  • Nöcker E.G.J.M.H., Smetsers J.E.W., Eekelen, M.C.J.D. van, Plasmeijer (1991). ‘Concurrent Clean', Proceedings of the Conference on Parallel Architectures and Languages Europe (PARLE '91), Eindhoven, The Netherlands, Lecture Notes on Computer Science, Springer Verlag, to appear in June 1991.

    Google Scholar 

  • Peyton Jones S.L, Salkild J. (1989). ‘The Spineless Tagless G-machine'. Proceedings of the Conference on Functional Programming Languages and Computer Architectures, Addison Wesley, pp 184–201.

    Google Scholar 

  • Plasmeijer M.J., Eekelen M.C.J.D. van (1991). Functional Programming and Parallel Graph Rewriting. Lecture notes, University of Nijmegen, to appear at Addison Wesley 1991.

    Google Scholar 

  • Smetsers J.E.W., (1989). ‘Compiling Clean to Abstract ABC-Machine Code', University of Nijmegen, Technical Report 89-20, October 1989.

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

John Hughes

Rights and permissions

Reprints and permissions

Copyright information

© 1991 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Smetsers, S., Nöcker, E., van Groningen, J., Plasmeijer, R. (1991). Generating efficient code for lazy functional languages. In: Hughes, J. (eds) Functional Programming Languages and Computer Architecture. FPCA 1991. Lecture Notes in Computer Science, vol 523. Springer, Berlin, Heidelberg. https://doi.org/10.1007/3540543961_28

Download citation

  • DOI: https://doi.org/10.1007/3540543961_28

  • Published:

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-540-54396-1

  • Online ISBN: 978-3-540-47599-6

  • eBook Packages: Springer Book Archive

Publish with us

Policies and ethics