Unboxed values as first class citizens in a non-strict functional language
The code compiled from a non-strict functional program usually manipulates heap-allocated boxed numbers. Compilers for such languages often go to considerable trouble to optimise operations on boxed numbers into simpler operations on their unboxed forms. These optimisations are usually handled in an ad hoc manner in the code generator, because earlier phases of the compiler have no way to talk about unboxed values.
We present a new approach, which makes unboxed values into (nearly) first-class citizens. The language, including its type system, is extended to handle unboxed values. The optimisation of boxing and unboxing operations can now be reinterpreted as a set of correctness-preserving program transformations. Indeed the particular transformations required are ones which a compiler would want to implement anyway. The compiler becomes both simpler and more modular.
Two other benefits accrue. Firstly, the results of strictness analysis can be exploited within the same uniform transformational framework. Secondly, new algebraic data types with unboxed components can be declared. Values of these types can be manipulated much more efficiently than the corresponding boxed versions.
Both a static and a dynamic semantics are given for the augmented language. The denotational dynamic semantics is notable for its use of unpointed domains.
KeywordsProgram Transformation Denotational Semantic Type Constructor Dynamic Semantic Recursive Definition
Unable to display preview. Download preview PDF.
- AW Appel , “Runtime tags aren't necessary,” CS-TR-142-88, Department of Computer Science, Princeton University.Google Scholar
- AW Appel & T Jim [Jan 1989], “Continuation-passing, closure-passing, style,” in Proc ACM Conference on Principles of Programming Languages, ACM, 293–302.Google Scholar
- TH Brus, MCJD van Eckelen, MO van Leer & MJ Plasmeijer [Sept 1987], “Clean — a language for functional graph rewriting,” in Functional programming languages and computer architecture, Portland, G Kahn, ed., LNCS 274, Springer Verlag, 364–384.Google Scholar
- LMM Damas & R Milner , “Principal type schemes for functional programs,” in POPL, 207–212.Google Scholar
- P Fradet & D Le Metayer , “Compilation of functional languages by program transformation,” IRISA, Campus de Beaulieu, Rennes.Google Scholar
- P Fradet & D Le Metayer [June 1988], “Compilation of lambda-calculus into functional machine code,” INRIA.Google Scholar
- , in Abstract Interpretation of Declarative Languages, C Hankin & S Abramsky, eds., Ellis Horwood, Chichester, 246–265.Google Scholar
- P Hudak, PL Wadler, Arvind, B Boutel, J Fairbairn, J Fasel, K Hammond, J Hughes, T Johnsson, R Kieburtz, RS Nikhil, SL Peyton Jones, M Reeve, D Wise & J Young [April 1990], “Report on the functional programming language Haskell,” Department of Computing Science, Glasgow University.Google Scholar
- R Kelsey [May 1989], “Compilation by program transformation,” YALEU/DCS/RR-702, PhD thesis, Department of Computer Science, Yale University.Google Scholar
- DA Kranz [May 1988], “ORBIT — an optimising compiler for Scheme,” PhD thesis, Department of Computer Science, Yale University.Google Scholar
- X Leroy [April 1991], “Efficient data representations in polymorphic languages,” INRIA Research Report 1264, Rocquencourt.Google Scholar
- E Moggi [June 1989], “Computational lambda calculus and monads,” in Logic in Computer Science, California, IEEE.Google Scholar
- J Peterson [Sept 1989], “Untagged data in tagged environments: choosing optimal representations at compile time,” in Functional Programming Languages and Computer Architecture, London, Addison Wesley, 89–99.Google Scholar
- SL Peyton Jones , The implementation of functional programming languages, Prentice Hall.Google Scholar
- SL Peyton Jones [Feb 1991], “The Spineless Tagless G-machine: a second attempt,” Department of Computing Science, University of Glasgow.Google Scholar
- SL Peyton Jones & Jon Salkild [Sept 1989], “The Spineless Tagless G-machine,” in Functional Programming Languages and Computer Architecture, D Mac-Queen, ed., Addison Wesley.Google Scholar
- DA Schmidt , Denotational semantics: a methodology for language development, Allyn and Bacon.Google Scholar
- MB Smyth & GD Plotkin [Nov 1982], “The category-theoretic solution of recursive domain equations,” SIAM Journal of Computing 11, 761–783.Google Scholar
- GL Steele , “Rabbit: a compiler for Scheme,” AI-TR-474, MIT Lab for Computer Science.Google Scholar
- SR Thatte , “Coercive type equivalence,” Department of Maths and Computer Science, Clarkson University NY.Google Scholar
- P Wadler , “Deforestation: transforming programs to eliminate trees,” Theoretical Computer Science 73, 231–248.Google Scholar