Repairing and mechanising the JavaScript relaxed memory model
Conrad Watt, Christopher Pulte, Anton Podkopaev, Guillaume Barbier, Stephen Dolan, Shaked Flur, Jean Pichon-Pharabod, Shu-yu Guo
Abstract
Modern JavaScript includes the SharedArrayBuffer feature, which provides access to true shared memory concurrency. SharedArrayBuffers are simple linear buffers of bytes, and the JavaScript specification defines an axiomatic relaxed memory model to describe their behaviour. While this model is heavily based on the C/C++11 model, it diverges in some key areas. JavaScript chooses to give a well-defined semantics to data-races, unlike the "undefined behaviour" of C/C++11. Moreover, the JavaScript model is mixed-size. This means that its accesses are not to discrete locations, but to (possibly overlapping) ranges of bytes.
We show that the model, in violation of the design intention, does not support a compilation scheme to ARMv8 which is used in practice. We propose a correction, which also incorporates a previously proposed fix for a failure of the model to provide Sequential Consistency of Data-Race-Free programs (SC-DRF), an important correctness condition. We use model checking, in Alloy, to generate small counter-examples for these deficiencies, and investigate our correction. To accomplish this, we also develop a mixed-size extension to the existing ARMv8 axiomatic model.
Guided by our Alloy experimentation, we mechanise (in Coq) the JavaScript model (corrected and uncorrected), our ARMv8 model, and, for the corrected JavaScript model, a "model-internal" SC-DRF proof and a compilation scheme correctness proof to ARMv8. In addition, we investigate a non-mixed-size subset of the corrected JavaScript model, and give proofs of compilation correctness for this subset to x86-TSO, Power, RISC-V, ARMv7, and (again) ARMv8, via the Intermediate Memory Model (IMM).
As a result of our work, the JavaScript standards body (ECMA TC39) will include fixes for both issues in an upcoming edition of the specification.
Ask about this paper
Your agent reads all of it.
Lune indexed this paper to the last equation, along with the top-tier papers that cite it. Ask a question and the answer quotes them.
Your agent calls
Luneget_paper_fulltext
Free to start. No credit card required.
Terminal
Install the CLIlune papers fulltext 47d6d92a-b850-415e-ba15-505d59c9c69eCited by top-tier papers5
- Pomsets with preconditions: a simple model of relaxed memoryRadha Jagadeesan, Alan Jeffrey, James RielyOOPSLA 2020 · 28 citations
- Making weak memory models fairOri Lahav, Egor Namakonov, Jonas Oberhauser, Anton Podkopaev et al.OOPSLA 2021 · 21 citations
- The leaky semicolon: compositional semantic dependencies for relaxed-memory concurrencyAlan Jeffrey, James Riely, Mark Batty, Simon Cooksey et al.POPL 2022 · 21 citations
- Compass: strong and compositional library specifications in relaxed memory separation logicHoang-Hai Dang, Jaehwang Jung, Jaemin Choi, Duc-Than Nguyen et al.PLDI 2022 · 19 citations
- Foundations of empirical memory consistency testingJake Kirkham, Tyler Sorensen, Esin Tureci, Margaret MartonosiOOPSLA 2020 · 7 citations
Builds on1
Related papers
- A Formal Account of the Wasm 3.0 Concurrency ModelAzalea Raad, Michalis Kokologiannakis, Viktor Vafeiadis, Conrad WattOOPSLA 2026
- Putting Weak Memory in Order via a Promising Intermediate RepresentationSung-Hwan Lee, Minki Cho, Roy David Margalit, Chung-Kil Hur et al.PLDI 2023 · 5 citations
- Rely/Guarantee Reasoning for Multicopy Atomic Weak Memory ModelsNicholas Coughlin, Kirsten Winter, Graeme SmithFM 2021 · 16 citations
- SafeRace: Assessing and Addressing WebGPU Memory Safety in the Presence of Data RacesReese Levine, Ashley Lee, Neha Abbas, Kyle Little et al.OOPSLA 2025 · 3 citations
- Uniformity Analysis in the WebGPU Shading LanguageJames Lee-Jones, John Wickerson, Alastair F. DonaldsonPLDI 2026 · 1 citation
