Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

SIMD.%type%.load()

Our volunteers haven't translated this article into Català yet. Join us and help get the job done!

This is an experimental technology
Because this technology's specification has not stabilized, check the compatibility table for usage in various browsers. Also note that the syntax and behavior of an experimental technology is subject to change in future versions of browsers as the specification changes.

The static SIMD.%type%.load() methods create a new SIMD data type with the lane values loaded from a typed array.

Syntax

SIMD.Float64x2.load(tarray, index)
SIMD.Float64x2.load1(tarray, index)

SIMD.Float32x4.load(tarray, index)
SIMD.Float32x4.load1(tarray, index)
SIMD.Float32x4.load2(tarray, index)
SIMD.Float32x4.load3(tarray, index)

SIMD.Int32x4.load(tarray, index)
SIMD.Int32x4.load1(tarray, index)
SIMD.Int32x4.load2(tarray, index)
SIMD.Int32x4.load3(tarray, index)

SIMD.Uint32x4.load(tarray, index)
SIMD.Uint32x4.load1(tarray, index)
SIMD.Uint32x4.load2(tarray, index)
SIMD.Uint32x4.load3(tarray, index) 

SIMD.Int8x16.load(tarray, index)
SIMD.Int16x8.load(tarray, index)

SIMD.Uint8x16.load(tarray, index) 
SIMD.Uint16x8.load(tarray, index)

Parameters

tarray
An instance of a typed array. This can be one of:
index
A number for the index from where to start loading in the typed array.

Return value

A new SIMD data type.

Exceptions

  • If index is out of range, for example SIMD.Int32x4.load(tarray, -1) or bigger than the size of tarray, a RangeError is thrown.
  • If tarray is not one of the typed array types, for example SIMD.Int32x4.load(tarray.buffer, 0) (an array buffer is not valid), a TypeError is thrown.

Description

The SIMD load and store methods intermix with typed arrays. With load, you can pass in typed arrays into SIMD types and with store, SIMD data can be stored into typed arrays.

You can either load all lane values using load(), or only load one, two or three lane values with the methods load1(), load2() or load3().

Examples

The following examples use an Int32Array loaded into a SIMD.Int32x4 data type.

Loading all values

var a = new Int32Array([1,2,3,4,5,6,7,8]);
SIMD.Int32x4.load(a, 0);
// Int32x4[1,2,3,4]

var b = new Int32Array([1,2,3,4,5,6,7,8]);
SIMD.Int32x4.load(a, 2);
// Int32x4[3,4,5,6]

Loading a single value

var a = new Int32Array([1,2,3,4,5,6,7,8]);
SIMD.Int32x4.load1(a, 0);
// Int32x4[1,0,0,0]

var b = new Int32Array([1,2,3,4,5,6,7,8]);
SIMD.Int32x4.load1(a, 2);
// Int32x4[3,0,0,0]

Loading two values

var a = new Int32Array([1,2,3,4,5,6,7,8]);
SIMD.Int32x4.load2(a, 0);
// Int32x4[1,2,0,0]

var b = new Int32Array([1,2,3,4,5,6,7,8]);
SIMD.Int32x4.load2(a, 2);
// Int32x4[3,4,0,0]

Loading three values

var a = new Int32Array([1,2,3,4,5,6,7,8]);
SIMD.Int32x4.load3(a, 0);
// Int32x4[1,2,3,0]

var b = new Int32Array([1,2,3,4,5,6,7,8]);
SIMD.Int32x4.load3(a, 2);
// Int32x4[3,4,5,0]

Specifications

Specification Status Comment
SIMD
The definition of 'SIMDConstructor.load' in that specification.
Draft Initial definition.

Browser compatibility

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

See also

Document Tags and Contributors

 Contributors to this page: eduardoboucas, fscholz
 Last updated by: eduardoboucas,