SIMD.store
SIMD.js已经从TC39中取消了积极的开发,并从第三阶段中删除了。它不再被网页浏览器所追求。暴露在 web 上的SIMD 操作在 WebAssembly 中正处于积极的发展之中, 其操作基于 SIMD. js 操作。
静态SIMD.%type%.store()方法将SIMD数据类型存储到类型化数组中。
语法
SIMD.Float32x4.store(tarray, index, value)
SIMD.Float32x4.store1(tarray, index, value)
SIMD.Float32x4.store2(tarray, index, value)
SIMD.Float32x4.store3(tarray, index, value)
SIMD.Float64x2.store(tarray, index, value)
SIMD.Float64x2.store1(tarray, index, value)
SIMD.Int32x4.store(tarray, index, value)
SIMD.Int32x4.store1(tarray, index, value)
SIMD.Int32x4.store2(tarray, index, value)
SIMD.Int32x4.store3(tarray, index, value)
SIMD.Int8x16.store(tarray, index, value)
SIMD.Int16x8.store(tarray, index, value)
SIMD.Uint32x4.store(tarray, index, value)
SIMD.Uint32x4.store1(tarray, index, value)
SIMD.Uint32x4.store2(tarray, index, value)
SIMD.Uint32x4.store3(tarray, index, value)
SIMD.Uint8x16.store(tarray, index, value)
SIMD.Uint16x8.store(tarray, index, value) 参数
tarray类型数组的一个实例。这可以是以下之一:
Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,或Float64Array。index索引号从哪里开始存储在类型数组中。valueSIMD数据类型的一个实例,存储到类型化数组中。返回值value已存储的数据类型(SIMD数据类型).
Exception 异常
- 如果
index超出范围,例如SIMD.Int32x4.store(tarray, -1, value)或大于tarray的大小,RangeError则抛出。
- 如果
tarray不是其中一种类型的数组类型,SIMD.Int32x4.store(tarray.buffer, 0)(数组缓冲区无效),TypeError则抛出。
描述
SIMD load和store方法与类型数组混合。使用load,您可以将类型化数组传递到SIMD类型,并且store,可以将SIMD数据存储到类型化数组中。
您可以使用存储所有车道值store(),或只保存一个,两个或三个车道值与方法store1(),store2()或store3()。
例子
以下示例使用SIMD.Int32x4存储在数据类型中的数据类型Int32Array。
存储所有的值
var tarray = new Int32Array(8);
var value = SIMD.Int32x4(1, 2, 3, 4);
SIMD.Int32x4.store(tarray, 0, value);
// tarray = Int32Array[1, 2, 3, 4, 0, 0, 0, 0]
var tarray = new Int32Array(8);
var value = SIMD.Int32x4(1, 2, 3, 4);
SIMD.Int32x4.store(tarray, 2, value);
// tarray = Int32Array[0, 0, 1, 2, 3, 4, 0, 0]存储一个值
var tarray = new Int32Array(8);
var value = SIMD.Int32x4(1, 2, 3, 4);
SIMD.Int32x4.store1(tarray, 0, value);
// tarray = Int32Array[1, 0, 0, 0, 0, 0, 0, 0]
var tarray = new Int32Array(8);
var value = SIMD.Int32x4(1, 2, 3, 4);
SIMD.Int32x4.store1(tarray, 2, value);
// tarray = Int32Array[0, 0, 1, 0, 0, 0, 0, 0]存储两个值
var tarray = new Int32Array(8);
var value = SIMD.Int32x4(1, 2, 3, 4);
SIMD.Int32x4.store2(tarray, 0, value);
// tarray = Int32Array[1, 2, 0, 0, 0, 0, 0, 0]
var tarray = new Int32Array(8);
var value = SIMD.Int32x4(1, 2, 3, 4);
SIMD.Int32x4.store2(tarray, 2, value);
// tarray = Int32Array[0, 0, 1, 2, 0, 0, 0, 0]存储三个值
var tarray = new Int32Array(8);
var value = SIMD.Int32x4(1, 2, 3, 4);
SIMD.Int32x4.store3(tarray, 0, value);
// tarray = Int32Array[1, 2, 3, 0, 0, 0, 0, 0]
var tarray = new Int32Array(8);
var value = SIMD.Int32x4(1, 2, 3, 4);
SIMD.Int32x4.store3(tarray, 2, value);
// tarray = Int32Array[0, 0, 1, 2, 3, 0, 0, 0]规范
Specification | Status | Comment |
|---|---|---|
SIMDThe definition of 'SIMDConstructor.store' in that specification. | Draft | Initial definition. |
浏览器兼容性
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
|---|---|---|---|---|---|
Basic support | No support | Nightly build | No support | No support | No support |
Feature | Android | Chrome for Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
|---|---|---|---|---|---|---|
Basic support | No support | No support | Nightly build | No support | No support | No support |
本文档系腾讯云开发者社区成员共同维护,如有问题请联系 cloudcommunity@tencent.com

