The ECMAScript Language Specification states:
Atomics are carved in stone: Program transformations must not cause any Shared Data Block events whose [[Order]] is seq-cst to be removed from the is-agent-order-before Relation, nor to be reordered with respect to each other, nor to be reordered inside an agent-order slice with respect to events whose [[Order]] is unordered.
Does this (or another part of the specification) mean that the use of an atomic operation like Atomics.load or Atomics.store guarantees that all prior operations on SharedArrayBuffer objects will be completed first, even those on buffer objects other than one passed as an argument?
For example, in the code snippets below, does the reader agent observing the atomic update to i32View guarantee that the non-atomic update to f32View has also been completed, despite them being views of different SharedArrayBuffer objects?
const i32Buffer = new SharedArrayBuffer(4);
const f32Buffer = new SharedArrayBuffer(4);
// Writer agent
const i32View = new Int32Array(i32Buffer);
const f32View = new Float32Array(f32Buffer);
function setValue(value) {
f32View[0] = value;
Atomics.store(i32View, 0, 1);
}
// Reader agent
const i32View = new Int32Array(i32Buffer);
const f32View = new Float32Array(f32Buffer);
function getValue() {
while (Atomics.load(i32View, 0) === 0) Atomics.pause();
return f32View[0];
}