Os nossos voluntários ainda não traduziram este artigo para Português (Europeu). Ajude-nos a concluir o trabalho!
Pode também ler o artigo em 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.Bool8x16 data type is a 128-bit vector divided into 16 lanes storing boolean values.

Syntax

SIMD.Bool8x16(s0,s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,s11,s12,s13,s14,s15);

Parameters

s[0-15] Optional
A boolean specifying the value of the lane. Defaults to false.

Constructor functions

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

SIMD.Bool8x16.splat()
Creates an Bool8x16 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.Bool8x16(true, true, true, true, true, true, true, true, false, false, false, false, false, false, false, false); 
// TypeError: SIMD.Bool8x16 is not a constructor
var w = new SIMD.Bool8x16.splat(true); 
// TypeError: SIMD.Bool8x16.splat is not a constructor

Instead, you just write:

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

Operations

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

Checking SIMD types

SIMD.Bool8x16.check()
Returns a new Bool8x16 if the parameter is a valid Bool8x16 data type. Throws a TypeError otherwise.

Accessing and mutating lanes

SIMD.Bool8x16.extractLane()
Returns the value of the given lane.
SIMD.Bool8x16.replaceLane()
Returns a new Bool8x16 with the given lane value replaced.

Boolean operations

SIMD.Bool8x16.allTrue()
Checks if all lanes hold a true value.
SIMD.Bool8x16.anyTrue()
Checks if any of the lanes hold a true value.

Bitwise logical operations

SIMD.Bool8x16.and()
Returns a new Bool8x16 with the logical AND of the lane values (a & b).
SIMD.Bool8x16.or()
Returns a new Bool8x16 with the logical OR of the lane values (a | b).
SIMD.Bool8x16.xor()
Returns a new Bool8x16 with the logical XOR of the lane values (a ^ b).
SIMD.Bool8x16.not()
Returns a new Bool8x16 with lane with the logical NOT of the lane values (~a).

SIMD prototype

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

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

Examples

Constructing a Bool8x16

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

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

SIMD.Bool8x16();
// Bool8x16[false, false, false, false, false, false, false, false, false, false, false, false, false, false, false]

Specifications

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

Browser compatibility

Feature Chrome Edge Firefox (Gecko) Internet Explorer Opera Safari
Basic support No support Nightly build Nightly build No support No support No support
Feature Android Chrome for Android Edge Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support No support No support Nightly build Nightly build No support No support No support

See also

Etiquetas do documento e contribuidores

 Contribuidores para esta página: fscholz, jameshkramer, nmve
 Última atualização por: fscholz,