We're looking for a user researcher to understand the needs of developers and designers. Is this you or someone you know? Check out the post: https://mzl.la/2IGzdXS

Наші добровольці ще не переклали статтю цією мовою: Українська. Долучайтеся й допоможіть це зробити!
Ви також можете прочитати цю статтю іншою мовою: English (US).

SIMD.js has been taken out of active development in TC39 and removed from Stage 3. It is not being pursued by web browsers for implementation anymore. SIMD operations exposed to the web are under active development within WebAssembly, with operations based on the SIMD.js operations.

The SIMD.Bool32x4 data type is a 128-bit vector divided into 4 lanes storing boolean values.


SIMD.Bool32x4(x, y, z, w);


x Optional
A boolean specifying the value of the first lane. Defaults to false.
y Optional
A boolean specifying the value of the second lane. Defaults to false.
z Optional
A boolean specifying the value of the third lane. Defaults to false.
w Optional
A boolean specifying the value of the fourth lane. Defaults to false.

Constructor functions

In addition to the simple creator function, the SIMD API provides the following constructor functions.

Creates an Bool32x4 with all lanes set to a given value.

Note: SIMD types don't work with new, as SIMD values are no "boxed" objects (comparable to String(s) vs. new String(s), which creates a String object).

var v = new SIMD.Bool32x4(true, false, true, false); 
// TypeError: SIMD.Bool32x4 is not a constructor
var w = new SIMD.Bool32x4.splat(true); 
// TypeError: SIMD.Bool32x4.splat is not a constructor

Instead, you just write:

var v = SIMD.Bool32x4(true, false, true, false);
var w = SIMD.Bool32x4.splat(true);


To actually do something with SIMD types, SIMD operations are needed that work on SIMD data types.

Checking SIMD types

Returns a new Bool32x4 if the parameter is a valid Bool32x4 data type. Throws a TypeError otherwise.

Accessing and mutating lanes

Returns the value of the given lane.
Returns a new Bool16x8 with the given lane value replaced.

Boolean operations

Checks if all lanes hold a true value.
Checks if any of the lanes hold a true value.

Bitwise logical operations

Returns a new Bool32x4 with the logical AND of the lane values (a & b).
Returns a new Bool32x4 with the logical OR of the lane values (a | b).
Returns a new Bool32x4 with the logical XOR of the lane values (a ^ b).
Returns a new Bool32x4 with lane with the logical NOT of the lane values (~a).

SIMD prototype

The following methods and properties are installed on the SIMD.Bool32x4.prototype.

Specifies the function that creates a SIMD object's prototype.
Returns a localized string representing the SIMD type and its elements. Overrides the Object.prototype.toLocaleString() method.
Returns a string representing the SIMD type and its elements. Overrides the Object.prototype.toString() method.
Returns the primitive value of a SIMD object.
Returns a string representing the source code of the object. Overrides the Object.prototype.toSource() method.


Constructing a Bool32x4

SIMD.Bool32x4(true, false, true, false); // Bool32x4[true, false, true, false]
SIMD.Bool32x4(true, false);              // Bool32x4[true, false, false, false]
SIMD.Bool32x4();                         // Bool32x4[false, false, false, false]


Specification Status Comment
The definition of 'Bool32x4' in that specification.
Obsolete Initial definition.

Browser compatibility

Experimental SIMD.js has been removed from browsers. It's still available in Firefox Nightly, but will be removed in favor of a SIMD implementation in WebAssembly. See also bug 1416723.

See also

Мітки документа й учасники

Зробили внесок у цю сторінку: fscholz, jameshkramer, nmve
Востаннє оновлена: fscholz,