function NAMELoadJS(tarray, index) {
return %NAMELoad(tarray, index);
}
+
+function NAMEStoreJS(tarray, index, a) {
+ return %NAMEStore(tarray, index, a);
+}
endmacro
SIMD_NUMERIC_TYPES(DECLARE_NUMERIC_FUNCTIONS)
function NAMELoadCOUNTJS(tarray, index) {
return %NAMELoadCOUNT(tarray, index);
}
+
+function NAMEStoreCOUNTJS(tarray, index, a) {
+ return %NAMEStoreCOUNT(tarray, index, a);
+}
endmacro
SIMD_LOADN_STOREN_TYPES(DECLARE_LOADN_STOREN_FUNCTIONS)
'load1', Float32x4Load1JS,
'load2', Float32x4Load2JS,
'load3', Float32x4Load3JS,
+ 'store', Float32x4StoreJS,
+ 'store1', Float32x4Store1JS,
+ 'store2', Float32x4Store2JS,
+ 'store3', Float32x4Store3JS,
]);
utils.InstallFunctions(GlobalInt32x4, DONT_ENUM, [
'load1', Int32x4Load1JS,
'load2', Int32x4Load2JS,
'load3', Int32x4Load3JS,
+ 'store', Int32x4StoreJS,
+ 'store1', Int32x4Store1JS,
+ 'store2', Int32x4Store2JS,
+ 'store3', Int32x4Store3JS,
]);
utils.InstallFunctions(GlobalUint32x4, DONT_ENUM, [
'load1', Uint32x4Load1JS,
'load2', Uint32x4Load2JS,
'load3', Uint32x4Load3JS,
+ 'store', Uint32x4StoreJS,
+ 'store1', Uint32x4Store1JS,
+ 'store2', Uint32x4Store2JS,
+ 'store3', Uint32x4Store3JS,
]);
utils.InstallFunctions(GlobalBool32x4, DONT_ENUM, [
'fromInt8x16Bits', Int16x8FromInt8x16BitsJS,
'fromUint8x16Bits', Int16x8FromUint8x16BitsJS,
'load', Int16x8LoadJS,
+ 'store', Int16x8StoreJS,
]);
utils.InstallFunctions(GlobalUint16x8, DONT_ENUM, [
'fromInt8x16Bits', Uint16x8FromInt8x16BitsJS,
'fromUint8x16Bits', Uint16x8FromUint8x16BitsJS,
'load', Uint16x8LoadJS,
+ 'store', Uint16x8StoreJS,
]);
utils.InstallFunctions(GlobalBool16x8, DONT_ENUM, [
'fromUint16x8Bits', Int8x16FromUint16x8BitsJS,
'fromUint8x16Bits', Int8x16FromUint8x16BitsJS,
'load', Int8x16LoadJS,
+ 'store', Int8x16StoreJS,
]);
utils.InstallFunctions(GlobalUint8x16, DONT_ENUM, [
'fromUint16x8Bits', Uint8x16FromUint16x8BitsJS,
'fromInt8x16Bits', Uint8x16FromInt8x16BitsJS,
'load', Uint8x16LoadJS,
+ 'store', Uint8x16StoreJS,
]);
utils.InstallFunctions(GlobalBool8x16, DONT_ENUM, [
//-------------------------------------------------------------------
-// Load functions.
+// Load and Store functions.
+
#define SIMD_LOADN_STOREN_TYPES(FUNCTION) \
FUNCTION(Float32x4, float, 4) \
FUNCTION(Int32x4, int32_t, 4) \
FUNCTION(Uint32x4, uint32_t, 4)
-// Common Load Functions
+// Common Load and Store Functions
+
#define SIMD_LOAD(type, lane_type, lane_count, count, result) \
static const int kLaneCount = lane_count; \
DCHECK(args.length() == 2); \
Handle<type> result = isolate->factory()->New##type(lanes);
+#define SIMD_STORE(type, lane_type, lane_count, count, a) \
+ static const int kLaneCount = lane_count; \
+ DCHECK(args.length() == 3); \
+ CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, tarray, 0); \
+ CONVERT_INT32_ARG_CHECKED(index, 1) \
+ CONVERT_ARG_HANDLE_CHECKED(type, a, 2); \
+ size_t bpe = tarray->element_size(); \
+ uint32_t bytes = count * sizeof(lane_type); \
+ size_t byte_length = NumberToSize(isolate, tarray->byte_length()); \
+ RUNTIME_ASSERT(index >= 0 && index * bpe + bytes <= byte_length); \
+ size_t tarray_offset = NumberToSize(isolate, tarray->byte_offset()); \
+ uint8_t* tarray_base = \
+ static_cast<uint8_t*>(tarray->GetBuffer()->backing_store()) + \
+ tarray_offset; \
+ lane_type lanes[kLaneCount]; \
+ for (int i = 0; i < kLaneCount; i++) { \
+ lanes[i] = a->get_lane(i); \
+ } \
+ memcpy(tarray_base + index * bpe, lanes, bytes);
+
+
#define SIMD_LOAD_FUNCTION(type, lane_type, lane_count) \
RUNTIME_FUNCTION(Runtime_##type##Load) { \
HandleScope scope(isolate); \
}
+#define SIMD_STORE_FUNCTION(type, lane_type, lane_count) \
+ RUNTIME_FUNCTION(Runtime_##type##Store) { \
+ HandleScope scope(isolate); \
+ SIMD_STORE(type, lane_type, lane_count, lane_count, a); \
+ return *a; \
+ }
+
+
+#define SIMD_STORE1_FUNCTION(type, lane_type, lane_count) \
+ RUNTIME_FUNCTION(Runtime_##type##Store1) { \
+ HandleScope scope(isolate); \
+ SIMD_STORE(type, lane_type, lane_count, 1, a); \
+ return *a; \
+ }
+
+
+#define SIMD_STORE2_FUNCTION(type, lane_type, lane_count) \
+ RUNTIME_FUNCTION(Runtime_##type##Store2) { \
+ HandleScope scope(isolate); \
+ SIMD_STORE(type, lane_type, lane_count, 2, a); \
+ return *a; \
+ }
+
+
+#define SIMD_STORE3_FUNCTION(type, lane_type, lane_count) \
+ RUNTIME_FUNCTION(Runtime_##type##Store3) { \
+ HandleScope scope(isolate); \
+ SIMD_STORE(type, lane_type, lane_count, 3, a); \
+ return *a; \
+ }
+
+
SIMD_NUMERIC_TYPES(SIMD_LOAD_FUNCTION)
SIMD_LOADN_STOREN_TYPES(SIMD_LOAD1_FUNCTION)
SIMD_LOADN_STOREN_TYPES(SIMD_LOAD2_FUNCTION)
SIMD_LOADN_STOREN_TYPES(SIMD_LOAD3_FUNCTION)
+SIMD_NUMERIC_TYPES(SIMD_STORE_FUNCTION)
+SIMD_LOADN_STOREN_TYPES(SIMD_STORE1_FUNCTION)
+SIMD_LOADN_STOREN_TYPES(SIMD_STORE2_FUNCTION)
+SIMD_LOADN_STOREN_TYPES(SIMD_STORE3_FUNCTION)
//-------------------------------------------------------------------
F(Float32x4Load1, 2, 1) \
F(Float32x4Load2, 2, 1) \
F(Float32x4Load3, 2, 1) \
+ F(Float32x4Store, 3, 1) \
+ F(Float32x4Store1, 3, 1) \
+ F(Float32x4Store2, 3, 1) \
+ F(Float32x4Store3, 3, 1) \
F(Int32x4Check, 1, 1) \
F(Int32x4ExtractLane, 2, 1) \
F(Int32x4ReplaceLane, 3, 1) \
F(Int32x4Load1, 2, 1) \
F(Int32x4Load2, 2, 1) \
F(Int32x4Load3, 2, 1) \
+ F(Int32x4Store, 3, 1) \
+ F(Int32x4Store1, 3, 1) \
+ F(Int32x4Store2, 3, 1) \
+ F(Int32x4Store3, 3, 1) \
F(Uint32x4Check, 1, 1) \
F(Uint32x4ExtractLane, 2, 1) \
F(Uint32x4ReplaceLane, 3, 1) \
F(Uint32x4Load1, 2, 1) \
F(Uint32x4Load2, 2, 1) \
F(Uint32x4Load3, 2, 1) \
+ F(Uint32x4Store, 3, 1) \
+ F(Uint32x4Store1, 3, 1) \
+ F(Uint32x4Store2, 3, 1) \
+ F(Uint32x4Store3, 3, 1) \
F(Bool32x4Check, 1, 1) \
F(Bool32x4ExtractLane, 2, 1) \
F(Bool32x4ReplaceLane, 3, 1) \
F(Int16x8FromInt8x16Bits, 1, 1) \
F(Int16x8FromUint8x16Bits, 1, 1) \
F(Int16x8Load, 2, 1) \
+ F(Int16x8Store, 3, 1) \
F(Uint16x8Check, 1, 1) \
F(Uint16x8ExtractLane, 2, 1) \
F(Uint16x8ReplaceLane, 3, 1) \
F(Uint16x8FromInt8x16Bits, 1, 1) \
F(Uint16x8FromUint8x16Bits, 1, 1) \
F(Uint16x8Load, 2, 1) \
+ F(Uint16x8Store, 3, 1) \
F(Bool16x8Check, 1, 1) \
F(Bool16x8ExtractLane, 2, 1) \
F(Bool16x8ReplaceLane, 3, 1) \
F(Int8x16FromUint16x8Bits, 1, 1) \
F(Int8x16FromUint8x16Bits, 1, 1) \
F(Int8x16Load, 2, 1) \
+ F(Int8x16Store, 3, 1) \
F(Uint8x16Check, 1, 1) \
F(Uint8x16ExtractLane, 2, 1) \
F(Uint8x16ReplaceLane, 3, 1) \
F(Uint8x16FromUint16x8Bits, 1, 1) \
F(Uint8x16FromInt8x16Bits, 1, 1) \
F(Uint8x16Load, 2, 1) \
+ F(Uint8x16Store, 3, 1) \
F(Bool8x16Check, 1, 1) \
F(Bool8x16ExtractLane, 2, 1) \
F(Bool8x16ReplaceLane, 3, 1) \