Open Bug 1442534 Opened 6 years ago Updated 1 year ago

ARM64: Improve code generation for atomics by avoiding fences

Categories

(Core :: JavaScript: WebAssembly, enhancement, P3)

ARM64
All
enhancement

Tracking

()

People

(Reporter: lth, Unassigned)

References

(Blocks 1 open bug)

Details

(Whiteboard: [arm64:m3])

Currently we generate an ARM-like fence + op + fence instruction sequence for ARM64 seq_cst atomics; this is safe, but we can do better.  Specifically, the canonical reference [1] has optimized sequences that avoid fences by using only the acquire and release operations, even for seq_cst operation.

[1] http://www.cl.cam.ac.uk/~pes20/cpp/cpp0xmappings.html
Priority: -- → P3
Whiteboard: [arm64:m3]

The optimized atomics are now about to become legal following an update to the memory model: https://github.com/tc39/ecma262/pull/1511. The executive summary is that the old memory model disallowed the use of release-acquire atomic ops for seq_cst operation in JS; the new model is slightly weaker and allows them, and the change is motivated by the desire to allow them on ARM64. (Apparently Chrome already uses weaker atomics here.)

ARMv8.1 has CAS primitives, which will help.

Also see https://github.com/WebAssembly/threads/blob/master/papers/oopsla2019.pdf for up-to-date guidance.

Blocks: 1687630
Component: JavaScript Engine: JIT → Javascript: WebAssembly

Note that if we update the JIT here we must also update the generated JS atomic operations, see jit/GenerateAtomicOperations.py.

Severity: normal → S3
See Also: → 1809189
You need to log in before you can comment on or make changes to this bug.