skip to main content
research-article

Plan B: a buffered memory model for Java

Published:23 January 2013Publication History
Skip Abstract Section

Abstract

Recent advances in verification have made it possible to envision trusted implementations of real-world languages. Java with its type-safety and fully specified semantics would appear to be an ideal candidate; yet, the complexity of the translation steps used in production virtual machines have made it a challenging target for verifying compiler technology. One of Java's key innovations, its memory model, poses significant obstacles to such an endeavor. The Java Memory Model is an ambitious attempt at specifying the behavior of multithreaded programs in a portable, hardware agnostic, way. While experts have an intuitive grasp of the properties that the model should enjoy, the specification is complex and not well-suited for integration within a verifying compiler infrastructure. Moreover, the specification is given in an axiomatic style that is distant from the intuitive reordering-based reasonings traditionally used to justify or rule out behaviors, and ill suited to the kind of operational reasoning one would expect to employ in a compiler. This paper takes a step back, and introduces a Buffered Memory Model (BMM) for Java. We choose a pragmatic point in the design space sacrificing generality in favor of a model that is fully characterized in terms of the reorderings it allows, amenable to formal reasoning, and which can be efficiently applied to a specific hardware family, namely x86 multiprocessors. Although the BMM restricts the reorderings compilers are allowed to perform, it serves as the key enabling device to achieving a verification pathway from bytecode to machine instructions. Despite its restrictions, we show that it is backwards compatible with the Java Memory Model and that it does not cripple performance on TSO architectures.

Skip Supplemental Material Section

Supplemental Material

r1d2_talk8.mp4

References

  1. S. V. Adve and K. Gharachorloo. Shared memory consistency models: A tutorial. Computer, 29(12), 1996. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. S. V. Adve and M. Hill. A Unified Formalization of Four Shared-Memory Models. Par. and Distr. Systems, IEEE Transactions on, 1993. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. J. Alglave, L. Maranget, S. Sarkar, and P. Sewell. Fences in Weak Memory Models. In Proc. of CAV, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. D. Aspinall and J. Sevc1k. Java Memory Model Examples: Good, Bad and Ugly. In Proc. of VAMP, 2007.Google ScholarGoogle Scholar
  5. D. Aspinall and J. Sevc1k. Formalising Java's Data Race Free Guarantee. In Proc. of TPHOLs, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. H.-J. Boehm and S. V. Adve. Foundations of the C++ concurrency memory model. SIGPLAN Not., 43, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. G. Boudol and G. Petri. Relaxed Memory Models: an Operational Approach. In Proc. of POPL, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. G. Boudol and G. Petri. A Theory of Speculative Computation. In Proc. of ESOP, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. S. Burckhardt, M. Musuvathi, and V. Singh. Verifying Local Transformations on Relaxed Memory Models. In Proc. of CC, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. P. Cenciarelli, A. Knapp, and E. Sibilio. The Java Memory Model: Operationally, denotationally, axiomatically. In Proc. of ESOP, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. B. Goetz, T. Peierls, J. Bloch, J. Bowbeer, D. Holmes, and D. Lea. Java Concurrency in Practice. Addison-Wesley Longman, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. T. Henties, J. Hunt, D. Locke, K. Nilsen, M. Schoeberl, and J. Vitek. Java for safety-critical applications. In SafeCert, 2009.Google ScholarGoogle Scholar
  13. L. Higham, J. Kawash, and N. Verwaaland. Defining and Comparing Memory Consistency Models. In Proc. of PDCS, 1997.Google ScholarGoogle Scholar
  14. L. Hubert, T. Jensen, V. Monfort, and D. Pichardie. Enforcing Secure Object Initialization in Java. In Proc. of ESORICS, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. M. Huisman and G. Petri. The Java Memory Model: a Formal Explanation. In Proc. of VAMP, 2007.Google ScholarGoogle Scholar
  16. R. Jagadeesan, C. Pitcher, and J. Riely. Generative Operational Semantics for Relaxed Memory Models. In Proc. of ESOP, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. K. Kawachiya, A. Koseki, and T. Onodera. Lock Reservation: Java Locks can Mostly doWithout Atomic Operations. In Proc. of OOPSLA, 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. G. Klein and T. Nipkow. A Machine-Checked Model for a Java-like Language, Virtual Machine, and Compiler. ACM Trans. Program. Lang. Syst., 28(4), 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. L. Lamport. Time, Clocks, and the Ordering of Events in a Distributed System. Commun. ACM, 21(7), 1978. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. X. Leroy. A Formally Verified Compiler Back-end. J. Autom. Reasoning, 43(4), 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. A. Lochbihler. Java and the Java memory Model -- a Unified, Machine-Checked Formalisation. In Proc. of ESOP, 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. J. Manson, W. Pugh, and S. V. Adve. The Java Memory Model. In Proc. of POPL, 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. D. Marino, A. Singh, T. D. Millstein, M. Musuvathi, and S. Narayanasamy. A Case for an SC-Preserving Compiler. In Proc. of PLDI, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. A. Mine. Static Analysis of Run-Time Errors in Embedded Critical Parallel C Programs. In Proc. of ESOP, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. S. Owens, S. Sarkar, and P. Sewell. A Better x86 Memory Model: x86-TSO. In Proc. of TPHOLs, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. F. Pizlo, L. Ziarek, E. Blanton, P. Maj, and J. Vitek. High-level Programming of Embedded Hard Real-Time Devices. In Proc. of EuroSys, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. W. Pugh. The Initialization On Demand Holder idiom, 2004. http://www.cs.umd.edu/~pugh/java/memoryModel/jsr-133-faq.html#dcl.Google ScholarGoogle Scholar
  28. W. Pugh. Causality test cases for the Java Memory Model, 2004. http://www.cs.umd.edu/~pugh/java/memoryModel/CausalityTestCases.html.Google ScholarGoogle Scholar
  29. K. Russell and D. Detlefs. Eliminating Synchronization-Related Atomic Operations with Biased Locking and Bulk Rebiasing. In Proc. of OOPSLA, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. S. Sarkar, P. Sewell, F. Z. Nardelli, S. Owens, T. Ridge, T. Braibant, M. O. Myreen, and J. Alglave. The Semantics of x86-CC Multiprocessor Machine Code. In Proc. of POPL, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. S. Sarkar, P. Sewell, J. Alglave, L. Maranget, and D. Williams. Understanding Power Multiprocessors. In Proc. of PLDI, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. J. Sevc1k. Program Transformations in Weak Memory Models. PhD thesis, The University of Edinburgh, 2009.Google ScholarGoogle Scholar
  33. J. Sevc1k. Safe optimisations for shared-memory concurrent programs. In Proc. of PLDI, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  34. J. Sevc1k and D. Aspinall. On Validity of Program Transformations in the Java Memory Model. In Proc. of ECOOP, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  35. J. Sevc1k, V. Vafeiadis, F. Z. Nardelli, S. Jagannathan, and P. Sewell. Relaxed-memory Concurrency and Verified Compilation. In Proc. of POPL, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  36. P. Sewell, S. Sarkar, S. Owens, F. Z. Nardelli, and M. O. Myreen. x86-TSO: A rigorous and usable programmer's model for x86 multiprocessors. Commun. ACM, 53(7), 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  37. E. Torlak, M. Vaziri, and J. Dolby. MemSAT: Checking Axiomatic Specifications of Memory Models. In Proc. of PLDI, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  38. V. Vafeiadis and F. Z. Nardelli. Verifying fence elimination optimisations. In Proc. of SAS, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Plan B: a buffered memory model 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

      Full Access

      • Published in

        cover image ACM SIGPLAN Notices
        ACM SIGPLAN Notices  Volume 48, Issue 1
        POPL '13
        January 2013
        561 pages
        ISSN:0362-1340
        EISSN:1558-1160
        DOI:10.1145/2480359
        Issue’s Table of Contents
        • cover image ACM Conferences
          POPL '13: Proceedings of the 40th annual ACM SIGPLAN-SIGACT symposium on Principles of programming languages
          January 2013
          586 pages
          ISBN:9781450318327
          DOI:10.1145/2429069

        Copyright © 2013 ACM

        Publisher

        Association for Computing Machinery

        New York, NY, United States

        Publication History

        • Published: 23 January 2013

        Check for updates

        Qualifiers

        • research-article

      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!