{{JSRef}} {{es7}}
The SIMD.Uint8x16
data type is a 128-bit vector divided into 16 lanes storing 8-bit unsigned integer values.
Syntax
SIMD.Uint8x16(s0,s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,s11,s12,s13,s14,s15);
Parameters
s[0-15]
{{optional_inline}}- An integer specifying the value of the lane. Defaults to 0.
Constructor functions
In addition to the simple creator functions, the SIMD API provides the following constructor functions:
- {{jsxref("SIMD.splat", "SIMD.Int8x16.splat()")}}
- Creates a Uint8x16 with all lanes set to a given value.
Note that you can also convert from another SIMD data type to Uint8x16.
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.Uint8x16(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16); // TypeError: SIMD.Uint8x16 is not a constructor var w = new SIMD.Uint8x16.splat(3); // TypeError: SIMD.Uint8x16.splat is not a constructor
Instead, you just write:
var v = SIMD.Uint8x16(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16); var w = SIMD.Uint8x16.splat(3);
Operations
To actually do something with SIMD types, SIMD operations are needed that work on SIMD data types.
Checking SIMD types
- {{jsxref("SIMD.check", "SIMD.Uint8x16.check()")}}
- Returns a new Uint8x16 if the parameter is a valid Int8x16 data type. Throws a {{jsxref("TypeError")}} otherwise.
Accessing and mutating lanes
- {{jsxref("SIMD.extractLane", "SIMD.Uint8x16.extractLane()")}}
- Returns the value of the given lane.
- {{jsxref("SIMD.replaceLane", "SIMD.Uint8x16.replaceLane()")}}
- Returns a new Uint8x16 with the given lane value replaced.
Loading from and storing into typed arrays
- {{jsxref("SIMD.load", "SIMD.Uint8x16.load()")}}
- Returns a new Uint8x16 with the lane values loaded from a typed array.
- {{jsxref("SIMD.store", "SIMD.Uint8x16.store()")}}
- Stores a Uint8x16 into a typed array.
Arithmetic operations
- {{jsxref("SIMD.add", "SIMD.Uint8x16.add()")}}
- Returns a new Uint8x16 with the lane values added (
a + b
). - {{jsxref("SIMD.addSaturate", "SIMD.Uint8x16.addSaturate()")}}
- Returns a new Uint8x16 with the lane values added (
a + b
) and saturating behavior on overflow. - {{jsxref("SIMD.mul", "SIMD.Uint8x16.mul()")}}
- Returns a new Uint8x16 with the lane values multiplied (
a * b
). - {{jsxref("SIMD.neg", "SIMD.Uint8x16.neg()")}}
- Returns a new Uint8x16 with the negated lane values.
- {{jsxref("SIMD.sub", "SIMD.Uint8x16.sub()")}}
- Returns a new Uint8x16 with the lane values subtracted (
a - b
). - {{jsxref("SIMD.subSaturate", "SIMD.Uint8x16.subSaturate()")}}
- Returns a Uint8x16 instance with the lane values subtracted (
a - b
) and saturating behavior on overflow.
Shuffling and swizzling
- {{jsxref("SIMD.shuffle", "SIMD.Uint8x16.shuffle()")}}
- Returns a new Uint8x16 with the lane values shuffled.
- {{jsxref("SIMD.swizzle", "SIMD.Uint8x16.swizzle()")}}
- Returns a new Uint8x16 with the lane values swizzled.
Selections
- {{jsxref("SIMD.select", "SIMD.Uint8x16.select()")}}
- Returns a new Uint8x16 with the lane values being a mix of the lanes depending on the selector mask.
Comparisons
- {{jsxref("SIMD.equal", "SIMD.Uint8x16.equal()")}}
- Returns a selection mask depending on
a == b
. - {{jsxref("SIMD.notEqual", "SIMD.Uint8x16.notEqual()")}}
- Returns a selection mask depending on
a != b
. - {{jsxref("SIMD.lessThan", "SIMD.Uint8x16.lessThan()")}}
- Returns a selection mask depending on
a < b
. - {{jsxref("SIMD.lessThanOrEqual", "SIMD.Uint8x16.lessThanOrEqual()")}}
- Returns a selection mask depending on
a <= b
. - {{jsxref("SIMD.greaterThan", "SIMD.Uint8x16.greaterThan()")}}
- Returns a selection mask depending on
a > b
. - {{jsxref("SIMD.greaterThanOrEqual", "SIMD.Uint8x16.greaterThanOrEqual()")}}
- Returns a selection mask depending on
a >= b
.
Bitwise logical operations
- {{jsxref("SIMD.and", "SIMD.Uint8x16.and()")}}
- Returns a new Uint8x16 with the logical AND of the lane values (
a & b
). - {{jsxref("SIMD.or", "SIMD.Uint8x16.or()")}}
- Returns a new Uint8x16 with the logical OR of the lane values (
a | b
). - {{jsxref("SIMD.xor", "SIMD.Uint8x16.xor()")}}
- Returns a new Uint8x16 with the logical XOR of the lane values (
a ^ b
). - {{jsxref("SIMD.not", "SIMD.Uint8x16.not()")}}
- Returns a new Uint8x16 with lane with the logical NOT of the lane values (
~a
).
Bitwise shift operations
- {{jsxref("SIMD.shiftLeftByScalar", "SIMD.Uint8x16.shiftLeftByScalar()")}}
- Returns a new Uint8x16 with the lane values shifted left by a given bit count (
a << bits
). - {{jsxref("SIMD.shiftRightByScalar", "SIMD.Uint8x16.shiftRightByScalar()")}}
- Returns a new Uint8x16 with the lane values shifted right.
- {{jsxref("SIMD.shiftRightArithmeticByScalar", "SIMD.Uint8x16.shiftRightArithmeticByScalar()")}}
- Returns a new Uint8x16 with the lane values shifted right (arithmetic) by a given bit count (
a >> bits
). - {{jsxref("SIMD.shiftRightLogicalByScalar", "SIMD.Uint8x16.shiftRightLogicalByScalar()")}}
- Returns a new Uint8x16 with the lane values shifted right (logical) by a given bit count (
a >>> bits
).
Data conversions
- {{jsxref("SIMD.fromFloat32x4Bits", "SIMD.Uint8x16.fromFloat32x4Bits()")}}
- Creates a new Uint8x16 data type with a bit-wise copy from a Float32x4.
- {{jsxref("SIMD.fromFloat64x2Bits", "SIMD.Uint8x16.fromFloat64x2Bits()")}}
- Creates a new Uint8x16 data type with a bit-wise copy from a Float64x2.
- {{jsxref("SIMD.fromInt32x4Bits", "SIMD.Uint8x16.fromInt32x4Bits()")}}
- Creates a new Uint8x16 data type with a bit-wise copy from an Int32x4.
- {{jsxref("SIMD.fromInt16x8Bits", "SIMD.Uint8x16.fromInt16x8Bits()")}}
- Creates a new Uint8x16 data type with a bit-wise copy from an Int16x8.
- {{jsxref("SIMD.fromInt8x16Bits", "SIMD.Uint8x16.fromInt8x16Bits()")}}
- Creates a new Uint8x16 data type with a bit-wise copy from an Int8x16.
- {{jsxref("SIMD.fromUint32x4Bits", "SIMD.Uint8x16.fromUint32x4Bits()")}}
- Creates a new Uint8x16 data type with a bit-wise copy from a Uint32x4.
- {{jsxref("SIMD.fromUint16x8Bits", "SIMD.Uint8x16.fromUint16x8Bits()")}}
- Creates a new Uint8x16 data type with a bit-wise copy from a Uint16x8.
SIMD prototype
The following methods and properties are installed on the SIMD.Uint8x16.prototype
.
SIMD.Uint8x16.prototype.constructor
- Specifies the function that creates a SIMD object's prototype.
- {{jsxref("SIMD.toLocaleString", "SIMD.Uint8x16.prototype.toLocaleString()")}}
- Returns a localized string representing the SIMD type and its elements. Overrides the {{jsxref("Object.prototype.toLocaleString()")}} method.
- {{jsxref("SIMD.toString", "SIMD.Uint8x16.prototype.toString()")}}
- Returns a string representing the SIMD type and its elements. Overrides the {{jsxref("Object.prototype.toString()")}} method.
- {{jsxref("SIMD.valueOf", "SIMD.Uint8x16.prototype.valueOf()")}}
- Returns the primitive value of a SIMD object.
- {{jsxref("SIMD.toSource", "SIMD.Uint8x16.prototype.toSource()")}} {{non-standard_inline}}
- Returns a string representing the source code of the object. Overrides the {{jsxref("Object.prototype.toSource()")}} method.
Examples
Constructing a Uint8x16
SIMD.Uint8x16(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16); // Uint8x16[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16] SIMD.Uint8x16(1,2); // Uint8x16[1,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0] SIMD.Uint8x16(); // Uint8x16[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
Specifications
Specification | Status | Comment |
---|---|---|
{{SpecName('SIMD', '#uint8x16', 'Uint8x16')}} | {{Spec2('SIMD')}} | Initial definition. |
Browser compatibility
{{CompatibilityTable}}
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|
Basic support | {{CompatNo}} | {{CompatNightly("firefox")}} | {{CompatNo}} | {{CompatNo}} | {{CompatNo}} |
Feature | Android | Chrome for Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|
Basic support | {{CompatNo}} | {{CompatNo}} | {{CompatNightly("firefox")}} | {{CompatNo}} | {{CompatNo}} | {{CompatNo}} |
See also
- {{jsxref("SIMD")}}