Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/runtime/runtime-utils.h" | 5 #include "src/runtime/runtime-utils.h" |
| 6 | 6 |
| 7 #include "src/arguments.h" | 7 #include "src/arguments.h" |
| 8 #include "src/base/macros.h" | 8 #include "src/base/macros.h" |
| 9 #include "src/conversions.h" | 9 #include "src/conversions.h" |
| 10 #include "src/factory.h" | 10 #include "src/factory.h" |
| (...skipping 942 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 953 a->CopyBits(lanes); \ | 953 a->CopyBits(lanes); \ |
| 954 Handle<type> result = isolate->factory()->New##type(lanes); \ | 954 Handle<type> result = isolate->factory()->New##type(lanes); \ |
| 955 return *result; \ | 955 return *result; \ |
| 956 } | 956 } |
| 957 | 957 |
| 958 SIMD_FROM_BITS_TYPES(SIMD_FROM_BITS_FUNCTION) | 958 SIMD_FROM_BITS_TYPES(SIMD_FROM_BITS_FUNCTION) |
| 959 | 959 |
| 960 | 960 |
| 961 //------------------------------------------------------------------- | 961 //------------------------------------------------------------------- |
| 962 | 962 |
| 963 // Load functions. | 963 // Load and Store functions. |
|
bbudge
2015/08/27 19:10:08
nit: blank line after comment (otherwise it looks
gdeepti
2015/08/27 20:07:10
Done.
| |
| 964 #define SIMD_LOADN_STOREN_TYPES(FUNCTION) \ | 964 #define SIMD_LOADN_STOREN_TYPES(FUNCTION) \ |
| 965 FUNCTION(Float32x4, float, 4) \ | 965 FUNCTION(Float32x4, float, 4) \ |
| 966 FUNCTION(Int32x4, int32_t, 4) \ | 966 FUNCTION(Int32x4, int32_t, 4) \ |
| 967 FUNCTION(Uint32x4, uint32_t, 4) | 967 FUNCTION(Uint32x4, uint32_t, 4) |
| 968 | 968 |
| 969 | 969 |
| 970 // Common Load Functions | 970 // Common Load and Store Functions |
|
bbudge
2015/08/27 19:10:09
nit: blank line (again, to make it clearer the com
gdeepti
2015/08/27 20:07:10
Done.
| |
| 971 #define SIMD_LOAD(type, lane_type, lane_count, count, result) \ | 971 #define SIMD_LOAD(type, lane_type, lane_count, count, result) \ |
| 972 static const int kLaneCount = lane_count; \ | 972 static const int kLaneCount = lane_count; \ |
| 973 DCHECK(args.length() == 2); \ | 973 DCHECK(args.length() == 2); \ |
| 974 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, tarray, 0); \ | 974 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, tarray, 0); \ |
| 975 CONVERT_INT32_ARG_CHECKED(index, 1) \ | 975 CONVERT_INT32_ARG_CHECKED(index, 1) \ |
| 976 size_t bpe = tarray->element_size(); \ | 976 size_t bpe = tarray->element_size(); \ |
| 977 uint32_t bytes = count * sizeof(lane_type); \ | 977 uint32_t bytes = count * sizeof(lane_type); \ |
| 978 size_t byte_length = NumberToSize(isolate, tarray->byte_length()); \ | 978 size_t byte_length = NumberToSize(isolate, tarray->byte_length()); \ |
| 979 RUNTIME_ASSERT(index >= 0 && index * bpe + bytes <= byte_length); \ | 979 RUNTIME_ASSERT(index >= 0 && index * bpe + bytes <= byte_length); \ |
| 980 size_t tarray_offset = NumberToSize(isolate, tarray->byte_offset()); \ | 980 size_t tarray_offset = NumberToSize(isolate, tarray->byte_offset()); \ |
| 981 uint8_t* tarray_base = \ | 981 uint8_t* tarray_base = \ |
| 982 static_cast<uint8_t*>(tarray->GetBuffer()->backing_store()) + \ | 982 static_cast<uint8_t*>(tarray->GetBuffer()->backing_store()) + \ |
| 983 tarray_offset; \ | 983 tarray_offset; \ |
| 984 lane_type lanes[kLaneCount] = {0}; \ | 984 lane_type lanes[kLaneCount] = {0}; \ |
| 985 memcpy(lanes, tarray_base + index * bpe, bytes); \ | 985 memcpy(lanes, tarray_base + index * bpe, bytes); \ |
| 986 Handle<type> result = isolate->factory()->New##type(lanes); | 986 Handle<type> result = isolate->factory()->New##type(lanes); |
| 987 | 987 |
| 988 | 988 |
| 989 #define SIMD_STORE(type, lane_type, lane_count, count, a) \ | |
| 990 static const int kLaneCount = lane_count; \ | |
| 991 DCHECK(args.length() == 3); \ | |
| 992 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, tarray, 0); \ | |
| 993 CONVERT_INT32_ARG_CHECKED(index, 1) \ | |
| 994 CONVERT_ARG_HANDLE_CHECKED(type, a, 2); \ | |
| 995 size_t bpe = tarray->element_size(); \ | |
| 996 uint32_t bytes = count * sizeof(lane_type); \ | |
| 997 size_t byte_length = NumberToSize(isolate, tarray->byte_length()); \ | |
| 998 RUNTIME_ASSERT(index >= 0 && index * bpe + bytes <= byte_length); \ | |
| 999 size_t tarray_offset = NumberToSize(isolate, tarray->byte_offset()); \ | |
| 1000 uint8_t* tarray_base = \ | |
| 1001 static_cast<uint8_t*>(tarray->GetBuffer()->backing_store()) + \ | |
| 1002 tarray_offset; \ | |
| 1003 lane_type lanes[kLaneCount]; \ | |
| 1004 for (int i = 0; i < kLaneCount; i++) { \ | |
| 1005 lanes[i] = a->get_lane(i); \ | |
| 1006 } \ | |
| 1007 memcpy(tarray_base + index * bpe, lanes, bytes); | |
| 1008 | |
| 1009 | |
| 989 #define SIMD_LOAD_FUNCTION(type, lane_type, lane_count) \ | 1010 #define SIMD_LOAD_FUNCTION(type, lane_type, lane_count) \ |
| 990 RUNTIME_FUNCTION(Runtime_##type##Load) { \ | 1011 RUNTIME_FUNCTION(Runtime_##type##Load) { \ |
| 991 HandleScope scope(isolate); \ | 1012 HandleScope scope(isolate); \ |
| 992 SIMD_LOAD(type, lane_type, lane_count, lane_count, result); \ | 1013 SIMD_LOAD(type, lane_type, lane_count, lane_count, result); \ |
| 993 return *result; \ | 1014 return *result; \ |
| 994 } | 1015 } |
| 995 | 1016 |
| 996 | 1017 |
| 997 #define SIMD_LOAD1_FUNCTION(type, lane_type, lane_count) \ | 1018 #define SIMD_LOAD1_FUNCTION(type, lane_type, lane_count) \ |
| 998 RUNTIME_FUNCTION(Runtime_##type##Load1) { \ | 1019 RUNTIME_FUNCTION(Runtime_##type##Load1) { \ |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 1011 | 1032 |
| 1012 | 1033 |
| 1013 #define SIMD_LOAD3_FUNCTION(type, lane_type, lane_count) \ | 1034 #define SIMD_LOAD3_FUNCTION(type, lane_type, lane_count) \ |
| 1014 RUNTIME_FUNCTION(Runtime_##type##Load3) { \ | 1035 RUNTIME_FUNCTION(Runtime_##type##Load3) { \ |
| 1015 HandleScope scope(isolate); \ | 1036 HandleScope scope(isolate); \ |
| 1016 SIMD_LOAD(type, lane_type, lane_count, 3, result); \ | 1037 SIMD_LOAD(type, lane_type, lane_count, 3, result); \ |
| 1017 return *result; \ | 1038 return *result; \ |
| 1018 } | 1039 } |
| 1019 | 1040 |
| 1020 | 1041 |
| 1042 #define SIMD_STORE_FUNCTION(type, lane_type, lane_count) \ | |
| 1043 RUNTIME_FUNCTION(Runtime_##type##Store) { \ | |
| 1044 HandleScope scope(isolate); \ | |
| 1045 SIMD_STORE(type, lane_type, lane_count, lane_count, a); \ | |
| 1046 return *a; \ | |
| 1047 } | |
| 1048 | |
| 1049 | |
| 1050 #define SIMD_STORE1_FUNCTION(type, lane_type, lane_count) \ | |
| 1051 RUNTIME_FUNCTION(Runtime_##type##Store1) { \ | |
| 1052 HandleScope scope(isolate); \ | |
| 1053 SIMD_STORE(type, lane_type, lane_count, 1, a); \ | |
| 1054 return *a; \ | |
| 1055 } | |
| 1056 | |
| 1057 | |
| 1058 #define SIMD_STORE2_FUNCTION(type, lane_type, lane_count) \ | |
| 1059 RUNTIME_FUNCTION(Runtime_##type##Store2) { \ | |
| 1060 HandleScope scope(isolate); \ | |
| 1061 SIMD_STORE(type, lane_type, lane_count, 2, a); \ | |
| 1062 return *a; \ | |
| 1063 } | |
| 1064 | |
| 1065 | |
| 1066 #define SIMD_STORE3_FUNCTION(type, lane_type, lane_count) \ | |
| 1067 RUNTIME_FUNCTION(Runtime_##type##Store3) { \ | |
| 1068 HandleScope scope(isolate); \ | |
| 1069 SIMD_STORE(type, lane_type, lane_count, 3, a); \ | |
| 1070 return *a; \ | |
| 1071 } | |
| 1072 | |
| 1073 | |
| 1021 SIMD_NUMERIC_TYPES(SIMD_LOAD_FUNCTION) | 1074 SIMD_NUMERIC_TYPES(SIMD_LOAD_FUNCTION) |
| 1022 SIMD_LOADN_STOREN_TYPES(SIMD_LOAD1_FUNCTION) | 1075 SIMD_LOADN_STOREN_TYPES(SIMD_LOAD1_FUNCTION) |
| 1023 SIMD_LOADN_STOREN_TYPES(SIMD_LOAD2_FUNCTION) | 1076 SIMD_LOADN_STOREN_TYPES(SIMD_LOAD2_FUNCTION) |
| 1024 SIMD_LOADN_STOREN_TYPES(SIMD_LOAD3_FUNCTION) | 1077 SIMD_LOADN_STOREN_TYPES(SIMD_LOAD3_FUNCTION) |
| 1078 SIMD_NUMERIC_TYPES(SIMD_STORE_FUNCTION) | |
| 1079 SIMD_LOADN_STOREN_TYPES(SIMD_STORE1_FUNCTION) | |
| 1080 SIMD_LOADN_STOREN_TYPES(SIMD_STORE2_FUNCTION) | |
| 1081 SIMD_LOADN_STOREN_TYPES(SIMD_STORE3_FUNCTION) | |
| 1025 | 1082 |
| 1026 //------------------------------------------------------------------- | 1083 //------------------------------------------------------------------- |
| 1027 | 1084 |
| 1028 } // namespace internal | 1085 } // namespace internal |
| 1029 } // namespace v8 | 1086 } // namespace v8 |
| OLD | NEW |