Empirical and analytic study of stack versus heap cost for languages with closures
- 1 January 1996
- journal article
- research article
- Published by Cambridge University Press (CUP) in Journal of Functional Programming
- Vol. 6 (1) , 47-74
- https://doi.org/10.1017/s095679680000157x
Abstract
We present a comprehensive analysis of all the components of creation, access and disposal of heap-allocated and stack-allocated activation records. Among our results are:•Although stack frames are known to have a better cache read-miss rate than heap frames, our simple analytical model (backed up by simulation results) shows that the difference is too trivial to matter.•The cache write-miss rate of heap frames is very high; we show that a variety of miss-handling strategies (exemplified by specific modern machines) can give good performance, but not all can.•Stacks restrict the flexibility of closure representations (for higher-order functions) in important (and costly) ways.•The extra load placed on the garbage collector by heap-allocated frames is small.•The demands of modern programming languages make stacks complicated to implement efficiently and correctly.Overall, the execution cost of stack-allocated and heap-allocated frames is similar; but heap frames are simpler to implement and allow very efficient first-class continuations.Keywords
This publication has 27 references indexed in Scilit:
- Heap profiling of lazy functional programsJournal of Functional Programming, 1993
- Callee-save registers in continuation-passing styleHigher-Order and Symbolic Computation, 1992
- Polymorphic type, region and effect inferenceJournal of Functional Programming, 1992
- Tail recursion without space leaksJournal of Functional Programming, 1992
- Some issues and strategies in heap management and memory hierarchiesACM SIGPLAN Notices, 1991
- Simple generational garbage collection and fast allocationSoftware: Practice and Experience, 1989
- Garbage collection can be faster than stack allocationInformation Processing Letters, 1987
- Revised 3 report on the algorithmic language schemeACM SIGPLAN Notices, 1986
- ORBIT: an optimizing compiler for schemeACM SIGPLAN Notices, 1986
- A portable storage management system for the icon programming languageSoftware: Practice and Experience, 1980