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.
- Andrew W. Appel. Modern Compiler Implementation in C: Basic Techniques. Cambridge University Press, New York, NY, USA, 1997. Google ScholarDigital Library
- 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 ScholarDigital Library
- 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 ScholarDigital Library
- 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 ScholarDigital Library
- 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 ScholarDigital Library
- 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 ScholarDigital Library
- 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 ScholarDigital Library
- 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 ScholarDigital Library
- Thomas Kotzmann. Escape Analysis in the Context of Dynamic Compilation and Deoptimization. PhD thesis, Johannes Kepler University Linz, 2005.Google Scholar
- 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 ScholarDigital Library
- 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 ScholarDigital Library
- 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 ScholarDigital Library
- Charles Edward McDowell. Reducing garbage in Java. SIGPLAN Notices, 33(9):84--86, 1998. Google ScholarDigital Library
- 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 Scholar
- 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 ScholarDigital Library
Index Terms
- Stack allocation of objects in the CACAO virtual machine
Recommendations
Adaptive inlining and on-stack replacement in the CACAO virtual machine
PPPJ '07: Proceedings of the 5th international symposium on Principles and practice of programming in JavaMethod inlining is a well-known and effective optimization technique for object-oriented programs. In the context of dynamic compilation, method inlining can be used as an adaptive optimization in order to eliminate the overhead of frequently executed ...
Side-effect analysis with fast escape filter
SOAP '12: Proceedings of the ACM SIGPLAN International Workshop on State of the Art in Java Program analysisSide-effect analysis is a fundamental static analysis used to determine the memory locations modified or used by each program entity. For the programs with pointers, the analysis can be very imprecise. To improve the precision of side-effect analysis, ...
Fast and precise points-to analysis
Many software engineering applications require points-to analysis. These client applications range from optimizing compilers to integrated program development environments (IDEs) and from testing environments to reverse-engineering tools. Moreover, ...
Comments