skip to main content

A formalization of Java’s concurrent access modes

Published:10 October 2019Publication History
Skip Abstract Section

Abstract

Java's memory model was recently updated and expanded with new access modes. The accompanying documentation for these access modes is intended to make strong guarantees about program behavior that the Java compiler must enforce, yet the documentation is frequently unclear. This makes the intended program behavior ambiguous, impedes discussion of key design decisions, and makes it impossible to prove general properties about the semantics of the access modes.

In this paper we present the first formalization of Java's access modes. We have constructed an axiomatic model for all of the modes using the Herd modeling tool. This allows us to give precise answers to questions about the behavior of example programs, called litmus tests. We have validated our model using a large suite of litmus tests from existing research which helps to shed light on the relationship with other memory models. We have also modeled the semantics in Coq and proven several general theorems including a DRF guarantee, which says that if a program is properly synchronized then it will exhibit sequentially consistent behavior. Finally, we use our model to prove that the unusual design choice of a partial order among writes to the same location is unobservable in any program.

Skip Supplemental Material Section

Supplemental Material

a142-bender

Presentation at OOPSLA '19

References

  1. 2010. Programming Languages-C++(final committee draft). C++ standards committee paper WG21/N3092= J16/10-0082.Google ScholarGoogle Scholar
  2. Jade Alglave, Anthony Fox, Samin Ishtiaq, Magnus O. Myreen, Susmit Sarkar, Peter Sewell, and Francesco Zappa Nardelli. 2008. The Semantics of Power and ARM Multiprocessor Machine Code. In Proceedings of the 4th Workshop on Declarative Aspects of Multicore Programming (DAMP ’09). ACM, New York, NY, USA, 13–24. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. Jade Alglave, Luc Maranget, and Michael Tautschnig. 2014. Herding Cats: Modelling, Simulation, Testing, and Data Mining for Weak Memory. ACM Trans. Program. Lang. Syst. 36, 2, Article 7 (July 2014), 74 pages. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. David Aspinall and Jaroslav Ševčík. 2007. Formalising Java’s Data Race Free Guarantee. In Proceedings of the 20th International Conference on Theorem Proving in Higher Order Logics (TPHOLs’07). Springer-Verlag, Berlin, Heidelberg, 22–37.Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Mark Batty, Scott Owens, Susmit Sarkar, Peter Sewell, and Tjark Weber. 2011. Mathematizing C++ Concurrency. SIGPLAN Not. 46, 1 (Jan. 2011), 55–66. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Mark Batty and Peter Sewell. 2014. The Thin-air Problem. http://www.cl.cam.ac.uk/~pes20/cpp/notes42.html . [Dec. 2018].Google ScholarGoogle Scholar
  7. John Bender, Mohsen Lesani, and Jens Palsberg. 2015. Declarative Fence Insertion. In Proceedings of the 2015 ACM SIGPLAN International Conference on Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA 2015). ACM, New York, NY, USA, 367–385. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Hans-J. Boehm and Sarita V. Adve. 2008. Foundations of the C++ Concurrency Memory Model. In Proceedings of the 29th ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI ’08). ACM, New York, NY, USA, 68–78. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. Hans J Boehm, Olivier Giroux, and Viktor Vafeiades. 2018. P0982R1: Weaken Release Sequences. http://www.openstd.org/jtc1/sc22/wg21/docs/papers/2018/p0982r1.html . [Aug. 2019].Google ScholarGoogle Scholar
  10. Jon Corbet. 2012. ACCESS_ONCE(). https://lwn.net/Articles/508991/ . [Dec 2018].Google ScholarGoogle Scholar
  11. Karl Crary and Michael Sullivan. 2015. A Calculus for Relaxed Memory. In Proceedings of POPL’15, ACM Symposium on Principles of Programming Languages.Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. Marieke Huisman and Gustavo Petri. 2007. The Java memory model: a formal explanation. VAMP 7 (2007), 81–96.Google ScholarGoogle Scholar
  13. JDK9. 2017. VarHandle API Docs. https://docs.oracle.com/javase/9/docs/api/java/lang/invoke/VarHandle.html . [Mar. 2019].Google ScholarGoogle Scholar
  14. Jeehoon Kang, Chung-Kil Hur, Ori Lahav, Viktor Vafeiadis, and Derek Dreyer. 2017. A Promising Semantics for Relaxedmemory Concurrency. In Proceedings of POPL’17, SIGPLAN–SIGACT Symposium on Principles of Programming Languages.Google ScholarGoogle Scholar
  15. Ori Lahav. 2019. personal communication.Google ScholarGoogle Scholar
  16. Ori Lahav, Viktor Vafeiadis, Jeehoon Kang, Chung-Kil Hur, and Derek Dreyer. 2017. Repairing Sequential Consistency in C/C++11. In Proceedings of the 38th ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI 2017). ACM, New York, NY, USA, 618–632. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. Doug Lea. 2017. JEP 193. http://openjdk.java.net/jeps/193 . [Mar. 2019].Google ScholarGoogle Scholar
  18. Doug Lea. 2018. Using JDK 9 Memory Order Modes. http://gee.cs.oswego.edu/dl/html/j9mm.html . [Online, March 2019].Google ScholarGoogle Scholar
  19. Doug Lea. 2019. personal communication.Google ScholarGoogle Scholar
  20. Jeremy Manson, William Pugh, and Sarita V. Adve. 2005. The Java Memory Model. In Proceedings of the 32Nd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL ’05). ACM, New York, NY, USA, 378–391.Google ScholarGoogle Scholar
  21. Robin Morisset, Pankaj Pawan, and Francesco Zappa Nardelli. 2013. Compiler testing via a theory of sound optimisations in the C11/C++ 11 memory model. In ACM SIGPLAN Notices, Vol. 48. ACM, 187–196.Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. Peizhao Ou and Brian Demsky. 2018. Towards Understanding the Costs of Avoiding Out-of-thin-air Results. Proc. ACM Program. Lang. 2, OOPSLA, Article 136 (Oct. 2018), 29 pages. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. Scott Owens, Susmit Sarkar, and Peter Sewell. 2009. A Better x86 Memory Model: X86-TSO. In Proceedings of the 22Nd International Conference on Theorem Proving in Higher Order Logics (TPHOLs ’09). Springer-Verlag, Berlin, Heidelberg, 391–407. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. Jean Pichon-Pharabod and Peter Sewell. 2016. A Concurrency Semantics for Relaxed Atomics That Permits Optimisation and Avoids Thin-air Executions. SIGPLAN Not. 51, 1 (Jan. 2016), 622–633. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. Christopher Pulte, Shaked Flur, Will Deacon, Jon French, Susmit Sarkar, and Peter Sewell. 2017. Simplifying ARM Concurrency: Multicopy-atomic Axiomatic and Operational Models for ARMv8. Proc. ACM Program. Lang. 2, POPL, Article 19 (Dec. 2017), 29 pages. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. Susmit Sarkar, Kayvan Memarian, Scott Owens, Mark Batty, Peter Sewell, Luc Maranget, Jade Alglave, and Derek Williams. 2012. Synchronising c/c++ and power. Acm Sigplan Notices 47, 6 (2012), 311–322.Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. Jaroslav Ševčík and David Aspinall. 2008. On Validity of Program Transformations in the Java Memory Model. In ECOOP 2008 – Object-Oriented Programming: 22nd European Conference Paphos, Cyprus, July 7-11, 2008 Proceedings, Jan Vitek (Ed.). Springer Berlin Heidelberg, Berlin, Heidelberg, 27–51. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. Dennis Shasha and Marc Snir. 1988. Efficient and Correct Execution of Parallel Programs That Share Memory. ACM Trans. Program. Lang. Syst. 10, 2 (April 1988), 282–312. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. Michael J. Sullivan. 2015. Low-level Concurrent Programming Using the Relaxed Memory Calculus. https://www.msully. net/stuff/thesprop.pdf . PhD. Dissertation [Online, accessed July 2017].Google ScholarGoogle Scholar
  30. Viktor Vafeiadis, Thibaut Balabonski, Soham Chakraborty, Robin Morisset, and Francesco Zappa Nardelli. 2015. Common Compiler Optimisations Are Invalid in the C11 Memory Model and What We Can Do About It. In Proceedings of the 42Nd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL ’15). ACM, New York, NY, USA, 209–220. Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. John Wickerson and Mark Batty. 2015. Taming the complexities of the C11 and OpenCL memory models. arXiv preprint arXiv:1503.07073 (2015).Google ScholarGoogle Scholar

Index Terms

  1. A formalization of Java’s concurrent access modes

      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

      Full Access

      PDF Format

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader
      About Cookies On This Site

      We use cookies to ensure that we give you the best experience on our website.

      Learn more

      Got it!