W3cubDocs

/JavaScript

SIMD.Uint16x8

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.Uint16x8 data type is a 128-bit vector divided into 8 lanes storing 16-bit unsigned integer values.

Syntax

SIMD.Uint16x8(s0, s1, s2, s3, s4, s5, s6, s7);

Parameters

s[0-7] Optional
An integer specifying the value of the lane. Defaults to 0.

Constructor functions

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

SIMD.Uint16x8.splat()
Creates a Uint16x8 with all lanes set to a given value.

You can also convert from another SIMD data type to Uint16x8.

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.Uint16x8(1, 2, 3, 4, 5, 6, 7, 8); 
// TypeError: SIMD.Uint16x8 is not a constructor
var w = new SIMD.Uint16x8.splat(3); 
// TypeError: SIMD.Uint16x8.splat is not a constructor

Instead, you just write:

var v = SIMD.Uint16x8(1, 2, 3, 4, 5, 6, 7, 8);
var w = SIMD.Uint16x8.splat(3);

Operations

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

Checking SIMD types

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

Accessing and mutating lanes

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

Loading from and storing into typed arrays

SIMD.Uint16x8.load()
Returns a new Uint16x8 with the lane values loaded from a typed array.
SIMD.Uint16x8.store()
Stores an Uint16x8 into a typed array.

Arithmetic operations

SIMD.Uint16x8.add()
Returns a new Uint16x8 with the lane values added (a + b).
SIMD.Uint16x8.addSaturate()
Returns a new Uint16x8 with the lane values added (a + b) and saturating behavior on overflow.
SIMD.Uint16x8.mul()
Returns a new Uint16x8 with the lane values multiplied (a * b).
SIMD.Uint16x8.neg()
Returns a new Uint16x8 with the negated lane values.
SIMD.Uint16x8.sub()
Returns a new Uint16x8 with the lane values subtracted (a - b).
SIMD.Uint16x8.subSaturate()
Returns a new Uint16x8 with the lane values subtracted (a - b) and saturating behavior on overflow.

Shuffling and swizzling

SIMD.Uint16x8.shuffle()
Returns a new Uint16x8 with the lane values shuffled.
SIMD.Uint16x8.swizzle()
Returns a new Uint16x8 with the lane values swizzled.

Selections

SIMD.Uint16x8.select()
Returns a new Uint16x8 with the lane values being a mix of the lanes depending on the selector mask.

Comparisons

SIMD.Uint16x8.equal()
Returns a selection mask depending on a == b.
SIMD.Uint16x8.notEqual()
Returns a selection mask depending on a != b.
SIMD.Uint16x8.lessThan()
Returns a selection mask depending on a < b.
SIMD.Uint16x8.lessThanOrEqual()
Returns a selection mask depending on a <= b.
SIMD.Uint16x8.greaterThan()
Returns a selection mask depending on a > b.
SIMD.Uint16x8.greaterThanOrEqual()
Returns a selection mask depending on a >= b.

Bitwise logical operations

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

Bitwise shift operations

SIMD.Uint16x8.shiftLeftByScalar()
Returns a new Uint16x8 with the lane values shifted left by a given bit count (a << bits).
SIMD.Uint16x8.shiftRightByScalar()
Returns a new Uint16x8 with the lane values shifted right.

Data conversions

SIMD.Uint16x8.fromFloat32x4Bits()
Creates a new Uint16x8 data type with a bit-wise copy from a Float32x4.
SIMD.Uint16x8.fromFloat64x2Bits()
Creates a new Uint16x8 data type with a bit-wise copy from a Float64x2.
SIMD.Uint16x8.fromInt32x4Bits()
Creates a new Uint16x8 data type with a bit-wise copy from an Int32x4.
SIMD.Uint16x8.fromInt16x8Bits()
Creates a new Uint16x8 data type with a bit-wise copy from an Int16x8.
SIMD.Uint16x8.fromInt8x16Bits()
Creates a new Uint16x8 data type with a bit-wise copy from an Int8x16.
SIMD.Uint16x8.fromUint32x4Bits()
Creates a new Uint16x8 data type with a bit-wise copy from a Uint32x4.
SIMD.Uint16x8.fromUint8x16Bits()
Creates a new Uint16x8 data type with a bit-wise copy from a Uint8x16.

SIMD prototype

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

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

Examples

Constructing a Uint16x8

SIMD.Uint16x8(1, 2, 3, 4, 5, 6, 7, 8); // Int16x8[1, 2, 3, 4, 5, 6, 7, 8]
SIMD.Uint16x8(1, 2);                   // Int16x8[1, 2, 0, 0, 0, 0, 0, 0]
SIMD.Uint16x8();                       // Int16x8[0, 0, 0, 0, 0, 0, 0, 0]

Specifications

Specification Status Comment
SIMD
The definition of 'Uint16x8' 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

© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint16x8