Commit ad3a8f0c authored by gdeepti's avatar gdeepti Committed by Commit bot

[simd.js] Add SIMD store functions for Phase 1.

Float32x4, Int32x4, Uint32x4:
  store, store1, store2, store3

Int16x8, Int8x16, Uint16x8, Uint8x16:
  store

BUG=v8:4124
LOG=N

R=bbudge@chromium.org, littledan@chromium.org, jarin@chromium.org

Review URL: https://codereview.chromium.org/1304183004

Cr-Commit-Position: refs/heads/master@{#30429}
parent 4ecf07da
......@@ -247,6 +247,10 @@ function NAMEGreaterThanOrEqualJS(a, b) {
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)
......@@ -368,6 +372,10 @@ macro DECLARE_LOADN_STOREN_FUNCTIONS(NAME, COUNT)
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)
......@@ -628,6 +636,10 @@ utils.InstallFunctions(GlobalFloat32x4, DONT_ENUM, [
'load1', Float32x4Load1JS,
'load2', Float32x4Load2JS,
'load3', Float32x4Load3JS,
'store', Float32x4StoreJS,
'store1', Float32x4Store1JS,
'store2', Float32x4Store2JS,
'store3', Float32x4Store3JS,
]);
utils.InstallFunctions(GlobalInt32x4, DONT_ENUM, [
......@@ -668,6 +680,10 @@ utils.InstallFunctions(GlobalInt32x4, DONT_ENUM, [
'load1', Int32x4Load1JS,
'load2', Int32x4Load2JS,
'load3', Int32x4Load3JS,
'store', Int32x4StoreJS,
'store1', Int32x4Store1JS,
'store2', Int32x4Store2JS,
'store3', Int32x4Store3JS,
]);
utils.InstallFunctions(GlobalUint32x4, DONT_ENUM, [
......@@ -708,6 +724,10 @@ utils.InstallFunctions(GlobalUint32x4, DONT_ENUM, [
'load1', Uint32x4Load1JS,
'load2', Uint32x4Load2JS,
'load3', Uint32x4Load3JS,
'store', Uint32x4StoreJS,
'store1', Uint32x4Store1JS,
'store2', Uint32x4Store2JS,
'store3', Uint32x4Store3JS,
]);
utils.InstallFunctions(GlobalBool32x4, DONT_ENUM, [
......@@ -761,6 +781,7 @@ utils.InstallFunctions(GlobalInt16x8, DONT_ENUM, [
'fromInt8x16Bits', Int16x8FromInt8x16BitsJS,
'fromUint8x16Bits', Int16x8FromUint8x16BitsJS,
'load', Int16x8LoadJS,
'store', Int16x8StoreJS,
]);
utils.InstallFunctions(GlobalUint16x8, DONT_ENUM, [
......@@ -801,6 +822,7 @@ utils.InstallFunctions(GlobalUint16x8, DONT_ENUM, [
'fromInt8x16Bits', Uint16x8FromInt8x16BitsJS,
'fromUint8x16Bits', Uint16x8FromUint8x16BitsJS,
'load', Uint16x8LoadJS,
'store', Uint16x8StoreJS,
]);
utils.InstallFunctions(GlobalBool16x8, DONT_ENUM, [
......@@ -854,6 +876,7 @@ utils.InstallFunctions(GlobalInt8x16, DONT_ENUM, [
'fromUint16x8Bits', Int8x16FromUint16x8BitsJS,
'fromUint8x16Bits', Int8x16FromUint8x16BitsJS,
'load', Int8x16LoadJS,
'store', Int8x16StoreJS,
]);
utils.InstallFunctions(GlobalUint8x16, DONT_ENUM, [
......@@ -894,6 +917,7 @@ utils.InstallFunctions(GlobalUint8x16, DONT_ENUM, [
'fromUint16x8Bits', Uint8x16FromUint16x8BitsJS,
'fromInt8x16Bits', Uint8x16FromInt8x16BitsJS,
'load', Uint8x16LoadJS,
'store', Uint8x16StoreJS,
]);
utils.InstallFunctions(GlobalBool8x16, DONT_ENUM, [
......
......@@ -960,14 +960,16 @@ SIMD_FROM_BITS_TYPES(SIMD_FROM_BITS_FUNCTION)
//-------------------------------------------------------------------
// 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); \
......@@ -986,6 +988,27 @@ SIMD_FROM_BITS_TYPES(SIMD_FROM_BITS_FUNCTION)
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); \
......@@ -1018,10 +1041,46 @@ SIMD_FROM_BITS_TYPES(SIMD_FROM_BITS_FUNCTION)
}
#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)
//-------------------------------------------------------------------
......
......@@ -615,6 +615,10 @@ namespace internal {
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) \
......@@ -651,6 +655,10 @@ namespace internal {
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) \
......@@ -687,6 +695,10 @@ namespace internal {
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) \
......@@ -732,6 +744,7 @@ namespace internal {
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) \
......@@ -768,6 +781,7 @@ namespace internal {
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) \
......@@ -813,6 +827,7 @@ namespace internal {
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) \
......@@ -849,6 +864,7 @@ namespace internal {
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) \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment