Abstract
Safe is a first-order functional language with an implicit region-based memory system and explicit destruction of heap cells. Its static analysis for inferring regions, and a type system guaranteeing the absence of dangling pointers have been presented elsewhere.
In this paper we present a new analysis aimed at inferring upper bounds for heap and stack consumption. It is based on abstract interpretation, being the abstract domain the set of all n-ary monotonic functions from real non-negative numbers to a real non-negative result. This domain turns out to be a complete lattice under the usual \(\sqsubseteq\) relation on functions. Our interpretation is monotonic in this domain and the solution we seek is the least fixpoint of the interpretation.
We first explain the abstract domain and some correctness properties of the interpretation rules with respect to the language semantics, then present the inference algorithms for recursive functions, and finally illustrate the approach with the upper bounds obtained by our implementation for some case studies.
Work partially funded by the projects TIN2008-06622-C03-01/TIN (STAMP), S-0505/ TIC/ 0407 (PROMESAS) and the MEC FPU grant AP2006-02154.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
Similar content being viewed by others
References
Albert, E., Arenas, P., Genaim, S., Puebla, G.: Automatic Inference of Upper Bounds for Recurrence Relations in Cost Analysis. In: Alpuente, M., Vidal, G. (eds.) SAS 2008. LNCS, vol. 5079, pp. 221–237. Springer, Heidelberg (2008)
Albert, E., Genaim, S., Gómez-Zamalloa, M.: Heap Space Analysis for Java Bytecode. In: Proc. Int. Symp. on Memory Management, ISMM’07, Montreal, Canada, pp. 105–116. ACM, New York (2007)
Albert, E., Genaim, S., Gómez-Zamalloa, M.: Live Heap Space Analysis for Languages with Garbage Collection. In: Proc. Int. Symp. on Memory Management, ISMM’09, Dublin, Ireland, pp. 129–138. ACM, New York (2009)
de Dios, J., Peña, R.: A Certified Implementation on top of the Java Virtual Machine. In: Alpuente, M. (ed.) FMICS 2009. LNCS, vol. 5825, pp. 181–196. Springer, Heidelberg (2009)
de Dios, J., Peña, R.: Formal Certification of a Resource-Aware Language Implementation. In: Berghofer, S., Nipkow, T., Urban, C., Wenzel, M. (eds.) TPHOLs 2009. LNCS, vol. 5674, pp. 196–211. Springer, Heidelberg (2009)
Hofmann, M., Jost, S.: Static prediction of heap space usage for first-order functional programs. In: Proc. 30th ACM Symp. on Principles of Programming Languages, POPL’03, pp. 185–197. ACM Press, New York (2003)
Hughes, R.J.M., Pareto, L.: Recursion and Dynamic Data-Structures in Bounded Space; Towards Embedded ML Programming. In: Proc. Int. Conf. on Functional Programming, ICFP’99, Paris, pp. 70–81. ACM Press, New York (September 1999)
Hughes, R.J.M., Pareto, L., Sabry, A.: Proving the Correctness of Reactive Systems Using Sized Types. In: Conference Record of POPL ’96: The 23rd ACM SIGPLAN-SIGACT, pp. 410–423 (1996)
Lindholm, T., Yellin, F.: The Java Virtual Machine Sepecification, 2nd edn. The Java Series. Addison-Wesley, Reading (1999)
Lucas, S., Peña, R.: Rewriting Techniques for Analysing Termination and Complexity Bounds of SAFE Programs. In: Hanus, M. (ed.) LOPSTR 2008. LNCS, vol. 5438, pp. 43–57. Springer, Heidelberg (2009)
Montenegro, M., Peña, R., Segura, C.: A Resource-Aware Semantics and Abstract Machine for a Functional Language with Explicit Deallocation. In: Workshop on Functional and (Constraint) Logic Programming, WFLP’08, Siena, Italy. ENTCS, pp. 47–61 (July 2008)
Montenegro, M., Peña, R., Segura, C.: A Type System for Safe Memory Management and its Proof of Correctness. In: ACM Principles and Practice of Declarative Programming, PPDP’08, Valencia, Spain, pp. 152–162 (July 2008)
Montenegro, M., Peña, R., Segura, C.: A simple region inference algorithm for a first-order functional language. In: Escobar, S. (ed.) Functional and Constraint Logic Programming. LNCS, vol. 5979, pp. 145–161. Springer, Heidelberg (2010)
Montenegro, M., Peña, R., Segura, C.: A space consumption analysis by abstract interpretation, extended version (2009), http://dalila.sip.ucm.es/safe
Tamalet, A., Shkaravska, O., van Eekelen, M.: Size Analysis of Algebraic Data Types. In: Achten, P., Koopman, P., Morazán, M.T. (eds.) Trends in Functional Programming (TFP’08), vol. 9, pp. 33–48. Intellect (2009)
van Eekelen, M., Shkaravska, O., van Kesteren, R., Jacobs, B., Poll, E., Smetsers, S.: AHA: Amortized Space Usage Analysis. Selected Papers Trends in Functional Programming, TFP’07, New York, pp. 36–53. Intellect (2008)
van Kesteren, R., Shkaravska, O., van Eekelen, M.: Inferring static non-monotonically sized types through testing. In: Proc. Work. on Functional and (Constraint) Logic Programming, WFLP’07, Paris, France. ENTCS. Elsevier, Amsterdam (2007)
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2010 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Montenegro, M., Peña, R., Segura, C. (2010). A Space Consumption Analysis by Abstract Interpretation. In: van Eekelen, M., Shkaravska, O. (eds) Foundational and Practical Aspects of Resource Analysis. FOPARA 2009. Lecture Notes in Computer Science, vol 6324. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-642-15331-0_3
Download citation
DOI: https://doi.org/10.1007/978-3-642-15331-0_3
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-642-15330-3
Online ISBN: 978-3-642-15331-0
eBook Packages: Computer ScienceComputer Science (R0)