Revised: 2016-01-22
This document defines the changes and amendments to asm.js semantics to support the proposal for ECMAScript shared memory and atomics. Please refer to that document for full information about the semantics.
This specification is a restatement of an earlier work, along with later bug fixes. The earlier work is obsolete.
Changelog:
An "integer-typed array" is one of the
A "float-typed array" is one of the TypedArray views
The heap memory passed to the asm.js module at link time must be
a
There is a new known stdlib object
The following Atomics names are not available as intrinsics in asm.js:
The futex methods can be accessed through the FFI (with the heap passed implicitly) and the operation result values can be expanded into constant values, as they have known values.
The view must name an integer-typed array mapped onto shared memory.
The index must be an expression of static type Intish. If the element byte size of view is not 1 then index must have the form C, where C is a constant, or the form E>>K, where E is some expression and K is a constant that is the log-base-2 of the element byte size of view.
The result type of Atomics.load is Int.
Treating atomic accesses as "syntax" rather than as "calls" -- ie, requiring a shift for the index expression -- fits in with how they will be used and allows for simplifictions in code generation.
The view and index arguments are constrained as for Atomics.load.
The value must be an expression of static type Intish.
The result type of Atomics.store is the actual type of value.
The view, index, and value arguments are constrained as for Atomics.store.
The result type of Atomics.exchange is Int.
As for Atomics.exchange.
As for Atomics.exchange.
As for Atomics.exchange.
As for Atomics.exchange.
As for Atomics.exchange.
The view and index arguments are constrained as for Atomics.load.
The expected and replacement arguments must be expressions of static type Intish.
The result type of Atomics.compareExchange is Int.
Implements a full memory barrier.
Atomics.fence() is no longer a part of the Shared Memory and Atomics specification and we do not expect to reintroduce it. It is implemented in Firefox, for now, but will likely be removed.
The result type of Atomics.fence is void.
The size argument must be an integer constant.
The result type of Atomics.isLockFree is Int, a boolean value.
Again, treating Atomics.isLockFree as syntax rather than as a call fits in with how it will be used and provides guarantees that it will be resolved at compile time.