skip to main content
10.1145/2544137.2544157acmconferencesArticle/Chapter ViewAbstractPublication PagescgoConference Proceedingsconference-collections
tutorial

Partial Escape Analysis and Scalar Replacement for Java

Published:16 October 2018Publication History

ABSTRACT

Escape Analysis allows a compiler to determine whether an object is accessible outside the allocating method or thread. This information is used to perform optimizations such as Scalar Replacement, Stack Allocation and Lock Elision, allowing modern dynamic compilers to remove some of the abstractions introduced by advanced programming models.

The all-or-nothing approach taken by most Escape Analysis algorithms prevents all these optimizations as soon as there is one branch where the object escapes, no matter how unlikely this branch is at runtime.

This paper presents a new, practical algorithm that performs control flow sensitive Partial Escape Analysis in a dynamic Java compiler. It allows Escape Analysis, Scalar Replacement and Lock Elision to be performed on individual branches. We implemented the algorithm on top of Graal, an open-source Java just-in-time compiler, and it performs well on a diverse set of benchmarks.

In this paper, we evaluate the effect of Partial Escape Analysis on the DaCapo, ScalaDaCapo and SpecJBB2005 benchmarks, in terms of run-time, number and size of allocations and number of monitor operations. It performs particularly well in situations with additional levels of abstraction, such as code generated by the Scala compiler. It reduces the amount of allocated memory by up to 58.5%, and improves performance by up to 33%.

References

  1. S. M. Blackburn, R. Garner, C. Hoffman, A. M. Khan, K. S. McKinley, R. Bentzur, A. Diwan, D. Feinberg, D. Frampton, S. Z. Guyer, M. Hirzel, A. Hosking, M. Jump, H. Lee, J. E. B. Moss, A. Phansalkar, D. Stefanović, T. VanDrunen, D. von Dincklage, and B. Wiedermann. The DaCapo benchmarks: Java benchmarking development and analysis. In Proceedings of the ACM SIGPLAN Conference on Object-Oriented Programming Systems, Languages, and Applications, pages 169--190. ACM Press, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. B. Blanchet. Escape analysis for object-oriented languages: application to Java. In Proceedings of the ACM SIGPLAN Conference on Object-Oriented Programming Systems, Languages, and Applications, pages 20--34. ACM Press, 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. B. Blanchet. Escape analysis for Java#8482;: Theory and practice. ACM Transactions on Programming Languages and Systems, 25(6):713--775, ACM Press, 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. J.-D. Choi, M. Gupta, M. Serrano, V. C. Sreedhar, and S. Midkiff. Escape analysis for Java. In Proceedings of the ACM SIGPLAN Conference on Object-Oriented Programming Systems, Languages, and Applications, pages 1--19. ACM Press, 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. G. Duboscq, L. Stadler, T. Würthinger, D. Simon, C. Wimmer, and H. Mössenböck. Graal IR: An extensible declarative intermediate representation. In Proceedings of the Asia-Pacific Programming Languages and Compilers Workshop, 2013.Google ScholarGoogle Scholar
  6. Google. The v8 JavaScript engine, 2013.Google ScholarGoogle Scholar
  7. U. Hölzle, C. Chambers, and D. Ungar. Debugging optimized code with dynamic deoptimization. In Proceedings of the ACM SIGPLAN Conference on Programming Language Design and Implementation, pages 32--43. ACM Press, 1992. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. T. Kotzmann and H. Mössenböck. Escape analysis in the context of dynamic compilation and deoptimization. In Proceedings of the International Conference on Virtual Execution Environments, pages 111--120. ACM Press, 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. T. Kotzmann and H. Mössenböck. Run-time support for optimizations based on escape analysis. In Proceedings of the International Symposium on Code Generation and Optimization, pages 49--60. IEEE Computer Society, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. P. Molnar, A. Krall, and F. Brandner. Stack allocation of objects in the CACAO virtual machine. In Proceedings of the International Conference on the Principles and Practice of Programming in Java, pages 153--161. ACM Press, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. OpenJDK Community. Graal Project, 2013.Google ScholarGoogle Scholar
  12. M. Paleczny, C. Vick, and C. Click. The Java HotSpot#8482; server compiler. In Proceedings of the Symposium on Java Virtual Machine Research and Technology, pages 1--12. USENIX, 2001. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. M. Pall. Allocation sinking optimization for the LuaJIT compiler, 2013.Google ScholarGoogle Scholar
  14. A. Sewe, M. Mezini, A. Sarimbekov, and W. Binder. Da Capo con Scala: design and analysis of a scala benchmark suite for the java virtual machine. In Proceedings of the ACM SIGPLAN Conference on Object-Oriented Programming Systems, Languages, and Applications, pages 657--676. ACM Press, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. A. Shankar, M. Arnold, and R. Bodik. Jolt: lightweight dynamic analysis and removal of object churn. In Proceedings of the ACM SIGPLAN Conference on Object-Oriented Programming Systems, Languages, and Applications, pages 127--142. ACM Press, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Partial Escape Analysis and Scalar Replacement for Java

    Recommendations

    Comments

    Login options

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

    Sign in

    PDF Format

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader