翻译正在进行中。

SIMD.js已经从TC39的发展中主动脱离出来了,在第三阶段移除。web浏览器不再追求它的实现。SIMD操作暴露在web上,在WebAssembly中处于积极的开发状态,操作基于SIMD.js操作。

注意:Bool64x2类型目前不是SIMD规范草案的一部分。

SIMD.Bool64x2数据类型是一个128位的矢量数值,分为两个存储布尔值的通道

Syntax

SIMD.Bool64x2(x, y);

Parameters

x 可选
一个布尔值,指定第一个参数的值。默认值为false。
y 可选
一个布尔值,指定第二个参数的值。默认值为 false.
  • 构造函数

除了简单的函数之外,SIMD API还提供了以下构造函数:

SIMD.Bool64x2.splat()
创建一个Bool64x2,所有的通道都设置为给定的值。

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

Instead, you just write:

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

Operations

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

Checking SIMD types

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

Accessing and mutating lanes

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

Boolean operations

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

Bitwise logical operations

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

SIMD prototype

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

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

Examples

Constructing a Bool64x2

SIMD.Bool64x2(true, false); // Bool64x2[true, false]
SIMD.Bool64x2(1);           // Bool64x2[true, false]
SIMD.Bool64x2();            // Bool64x2[false, false]

Specifications

The Bool64x2 type is currently not part of the SIMD specification draft.

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support 未实现 Nightly build 未实现 未实现 未实现
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support 未实现 未实现 Nightly build 未实现 未实现 未实现

See also

文档标签和贡献者

 此页面的贡献者: fanbaobao
 最后编辑者: fanbaobao,