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.
Supplemental Material
- 2010. Programming Languages-C++(final committee draft). C++ standards committee paper WG21/N3092= J16/10-0082.Google Scholar
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- Mark Batty, Scott Owens, Susmit Sarkar, Peter Sewell, and Tjark Weber. 2011. Mathematizing C++ Concurrency. SIGPLAN Not. 46, 1 (Jan. 2011), 55–66. Google Scholar
Digital Library
- Mark Batty and Peter Sewell. 2014. The Thin-air Problem. http://www.cl.cam.ac.uk/~pes20/cpp/notes42.html . [Dec. 2018].Google Scholar
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
- Jon Corbet. 2012. ACCESS_ONCE(). https://lwn.net/Articles/508991/ . [Dec 2018].Google Scholar
- Karl Crary and Michael Sullivan. 2015. A Calculus for Relaxed Memory. In Proceedings of POPL’15, ACM Symposium on Principles of Programming Languages.Google Scholar
Digital Library
- Marieke Huisman and Gustavo Petri. 2007. The Java memory model: a formal explanation. VAMP 7 (2007), 81–96.Google Scholar
- JDK9. 2017. VarHandle API Docs. https://docs.oracle.com/javase/9/docs/api/java/lang/invoke/VarHandle.html . [Mar. 2019].Google Scholar
- 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 Scholar
- Ori Lahav. 2019. personal communication.Google Scholar
- 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 Scholar
Digital Library
- Doug Lea. 2017. JEP 193. http://openjdk.java.net/jeps/193 . [Mar. 2019].Google Scholar
- Doug Lea. 2018. Using JDK 9 Memory Order Modes. http://gee.cs.oswego.edu/dl/html/j9mm.html . [Online, March 2019].Google Scholar
- Doug Lea. 2019. personal communication.Google Scholar
- 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 Scholar
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
- 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 Scholar
Digital Library
- John Wickerson and Mark Batty. 2015. Taming the complexities of the C11 and OpenCL memory models. arXiv preprint arXiv:1503.07073 (2015).Google Scholar
Index Terms
A formalization of Java’s concurrent access modes
Recommendations
Address-aware fences
ICS '13: Proceedings of the 27th international ACM conference on International conference on supercomputingMany modern multicore architectures support shared memory for ease of programming and relaxed memory models to deliver high performance. With relaxed memory models, memory accesses can be reordered dynamically and seen by other processors. Therefore, ...
Specifying Java thread semantics using a uniform memory model
JGI '02: Proceedings of the 2002 joint ACM-ISCOPE conference on Java GrandeStandardized language level support for threads is one of the most important features of Java. However, defining the Java Memory Model (JMM) has turned out to be a major challenge. Several models produced to date are not as easily comprehensible and ...






Comments