skip to main content
10.1145/1596655.1596680acmconferencesArticle/Chapter ViewAbstractPublication PagespppjConference Proceedingsconference-collections
research-article

Stack allocation of objects in the CACAO virtual machine

Published:27 August 2009Publication History

ABSTRACT

Stack allocation of objects reduces the cost of object allocation and garbage collection and can thus lead to large reductions in runtime. Escape analysis can statically determine which objects are eligible to stack allocation by examining the escape behavior of allocation sites. If objects created at a particular allocation site do not escape, i.e., are guaranteed not to leave the scope of the allocation site, stack allocation instead of expensive heap allocation can be applied.

We have implemented a lightweight and fast escape analysis within the CACAO Java Virtual Machine to enable stack allocation. The analysis proceeds in two stages: an intraprocedural analysis computes escape information for each allocation site within a single method and builds call-context agnostic summary information for the method. The summary information is then used during interprocedural analysis to capture the escape behavior of method arguments. The computed escape information is finally used to allocate a subset of thread-local Java objects on the call stack.

The implementation has been evaluated using the SPEC JVM98 and the dacapo benchmark suites. For the SPEC benchmarks up to 90% of all objects allocated at runtime can be allocated on the call stack, leading to a speed up of up to 69%. The more complex dacapo benchmarks still show speedups of up to 10%, with up to 20% of all objects being allocated on the stack.

References

  1. Andrew W. Appel. Modern Compiler Implementation in C: Basic Techniques. Cambridge University Press, New York, NY, USA, 1997. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. Bruno Blanchet. Escape analysis for object oriented languages: Application to Java. In Proceedings of the 14th Annual Conference on Object-Oriented Programming Systems, Languages and Applications, pages 20--34, Denver, November 1999. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. Jong-Deok Choi, David Grove, Michael Hind, and Vivek Sarkar. Efficient and precise modeling of exceptions for the analysis of Java programs. SIGSOFT Softw. Eng. Notes, 24(5):21--31, 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. Ron Cytron, Jeanne Ferrante, Barry K. Rosen, Mark N. Wegman, and F. Kenneth Zadeck. Efficiently computing static single assignment form and the control dependence graph. ACM Trans. Program. Lang. Syst., 13(4):451--490, 1991. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Jong-Deok Choi, Manish Gupta, Mauricio Serrano, Vugranam C. Sreedhar, and Sam Midkiff. Escape analysis for Java. In Proceedings of the 14th Annual Conference on Object-Oriented Programming Systems, Languages and Applications, pages 1--19, Denver, November 1999. ACM Press. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Tamar Domani, Gal Goldshtein, Elliot K. Kolodner, Ethan Lewis, Erez Petrank, and Dafna Sheinwald. Thread-local heaps for Java. SIGPLAN Not., 38(2 supplement):76--87, 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. David Gay and Bjarne Steensgaard. Fast escape analysis and stack allocation for object-based programs. In CC '00: Proceedings of the 9th International Conference on Compiler Construction, pages 82--93, London, UK, 2000. Springer-Verlag. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Richard Jones and Andy C. King. A fast analysis for thread-local garbage collection with dynamic class loading. In SCAM '05: Proceedings of the Fifth IEEE International Workshop on Source Code Analysis and Manipulation, pages 129--138, Washington, DC, USA, 2005. IEEE Computer Society. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. Thomas Kotzmann. Escape Analysis in the Context of Dynamic Compilation and Deoptimization. PhD thesis, Johannes Kepler University Linz, 2005.Google ScholarGoogle Scholar
  10. Thomas Kotzmann and Hanspeter Mössenböck. Escape analysis in the context of dynamic compilation and deoptimization. In VEE '05: Proceedings of the 1st ACM/USENIX international conference on Virtual Execution Environments, pages 111--120, New York, NY, USA, 2005. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. Thomas Kotzmann and Hanspeter Mössenböck. Run-time support for optimizations based on escape analysis. In CGO '07: Proceedings of the International Symposium on Code Generation and Optimization, pages 49--60, Washington, DC, USA, 2007. IEEE Computer Society. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. Andreas Krall. Efficient JavaVM just-in-time compilation. In Jean-Luc Gaudiot, editor, International Conference on Parallel Architectures and Compilation Techniques, pages 205--212, Paris, October 1998. IFIP, ACM, IEEE, North-Holland. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Charles Edward McDowell. Reducing garbage in Java. SIGPLAN Notices, 33(9):84--86, 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. Hanspeter Mössenböck. Adding static single assignment form and a graph coloring register allocator to the Java HotSpot#8482; client compiler. Technical report, Johannes Kepler University Linz, 2000.Google ScholarGoogle Scholar
  15. Edwin Steiner, Andreas Krall, and Christian Thalinger. Adaptive inlining and on-stack replacement in the CACAO virtual machine. In International Conference on Principles and Practice of Programming in Java, pages 221--226, Monte de Caparica/Lisbon, Portugal, September 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Stack allocation of objects in the CACAO virtual machine

    Recommendations

    Reviews

    Charles Robert Morgan

    In languages such as Java, all objects are allocated on the heap, creating two types of inefficiency: costly memory allocation and slower access to the data in the object. This paper addresses the inefficiency by performing a series of performance measurements on the SPECjvm98 and DaCapo benchmarks, to measure the situations where the object can be allocated on the program stack rather than on the heap. It measures: which objects are method-local (such as most iterators); which objects are thread-local; which objects are global (referenced in multiple methods and threads); and which objects are returned by a method and only used in calling methods. The paper includes an algorithm to determine some of these local objects. It generalizes the ideas in a Steensgaard alias-analysis algorithm by using a lattice, encoding whether an object escapes a method. The paper deserves to be studied by implementers, but it needs more details. There are two different ways to inline an object into a stack frame. The first method eliminates the pointer to the object and changes all object data into variables in the stack frame. The second method places the whole object in the stack frame. The data can be referenced as variables or by using the pointer. The first method is more limited, but may be faster for access. The paper seems to describe the first technique. The description of the algorithm disqualifies local allocation for null (and other) comparisons, and the paper alludes later to the second method. I would like to see a complete paper or thesis (rather than a conference paper) that more fully describes the algorithm. The paper includes an excellent bibliography on the topic of escape analysis. Online Computing Reviews Service

    Access critical reviews of Computing literature here

    Become a reviewer for Computing Reviews.

    Comments

    Login options

    Check if you have access through your login credentials or your institution to get full access on this article.

    Sign in
    • Published in

      cover image ACM Conferences
      PPPJ '09: Proceedings of the 7th International Conference on Principles and Practice of Programming in Java
      August 2009
      200 pages
      ISBN:9781605585987
      DOI:10.1145/1596655

      Copyright © 2009 ACM

      Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

      Publisher

      Association for Computing Machinery

      New York, NY, United States

      Publication History

      • Published: 27 August 2009

      Permissions

      Request permissions about this article.

      Request Permissions

      Check for updates

      Qualifiers

      • research-article

      Acceptance Rates

      Overall Acceptance Rate29of58submissions,50%

    PDF Format

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader