29.1 Memory Model Fundamentals

Shared memory accesses (reads and writes) are divided into two groups, atomic accesses and data accesses, defined below. Atomic accesses are sequentially consistent, i.e., there is a strict total ordering of events agreed upon by all agents in an agent cluster. Non-atomic accesses do not have a strict total ordering agreed upon by all agents, i.e., unordered.

Note 1

No orderings weaker than sequentially consistent and stronger than unordered, such as release-acquire, are supported.

A Shared Data Block event is either a ReadSharedMemory, WriteSharedMemory, or ReadModifyWriteSharedMemory Record.

Table 89: ReadSharedMemory Event Fields
Field Name Value Meaning
[[Order]] SeqCst | Unordered The weakest ordering guaranteed by the memory model for the event.
[[NoTear]] A Boolean Whether this event is allowed to read from multiple write events on equal range as this event.
[[Block]] A Shared Data Block The block the event operates on.
[[ByteIndex]] A non-negative integer The byte address of the read in [[Block]].
[[ElementSize]] A non-negative integer The size of the read.
Table 90: WriteSharedMemory Event Fields
Field Name Value Meaning
[[Order]] SeqCst | Unordered | Init The weakest ordering guaranteed by the memory model for the event.
[[NoTear]] A Boolean Whether this event is allowed to be read from multiple read events with equal range as this event.
[[Block]] A Shared Data Block The block the event operates on.
[[ByteIndex]] A non-negative integer The byte address of the write in [[Block]].
[[ElementSize]] A non-negative integer The size of the write.
[[Payload]] A List The List of byte values to be read by other events.
Table 91: ReadModifyWriteSharedMemory Event Fields
Field Name Value Meaning
[[Order]] SeqCst Read-modify-write events are always sequentially consistent.
[[NoTear]] true Read-modify-write events cannot tear.
[[Block]] A Shared Data Block The block the event operates on.
[[ByteIndex]] A non-negative integer The byte address of the read-modify-write in [[Block]].
[[ElementSize]] A non-negative integer The size of the read-modify-write.
[[Payload]] A List The List of byte values to be passed to [[ModifyOp]].
[[ModifyOp]] A read-modify-write modification function An abstract closure that returns a modified List of byte values from a read List of byte values and [[Payload]].

These events are introduced by abstract operations or by methods on the Atomics object.

Some operations may also introduce Synchronize events. A Synchronize event has no fields, and exists purely to directly constrain the permitted orderings of other events.

In addition to Shared Data Block and Synchronize events, there are host-specific events.

Let the range of a ReadSharedMemory, WriteSharedMemory, or ReadModifyWriteSharedMemory event be the Set of contiguous integers from its [[ByteIndex]] to [[ByteIndex]] + [[ElementSize]] - 1. Two events' ranges are equal when the events have the same [[Block]], and the ranges are element-wise equal. Two events' ranges are overlapping when the events have the same [[Block]], the ranges are not equal and their intersection is non-empty. Two events' ranges are disjoint when the events do not have the same [[Block]] or their ranges are neither equal nor overlapping.

Note 2

Examples of host-specific synchronizing events that should be accounted for are: sending a SharedArrayBuffer from one agent to another (e.g., by postMessage in a browser), starting and stopping agents, and communicating within the agent cluster via channels other than shared memory. It is assumed those events are appended to agent-order during evaluation like the other SharedArrayBuffer events.

Events are ordered within candidate executions by the relations defined below.