Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(369)

Side by Side Diff: src/runtime/runtime-simd.cc

Issue 1304183004: [simd.js] Add SIMD store functions for Phase 1. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Bill's comments Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/runtime/runtime.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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.
964
964 #define SIMD_LOADN_STOREN_TYPES(FUNCTION) \ 965 #define SIMD_LOADN_STOREN_TYPES(FUNCTION) \
965 FUNCTION(Float32x4, float, 4) \ 966 FUNCTION(Float32x4, float, 4) \
966 FUNCTION(Int32x4, int32_t, 4) \ 967 FUNCTION(Int32x4, int32_t, 4) \
967 FUNCTION(Uint32x4, uint32_t, 4) 968 FUNCTION(Uint32x4, uint32_t, 4)
968 969
969 970
970 // Common Load Functions 971 // Common Load and Store Functions
972
971 #define SIMD_LOAD(type, lane_type, lane_count, count, result) \ 973 #define SIMD_LOAD(type, lane_type, lane_count, count, result) \
972 static const int kLaneCount = lane_count; \ 974 static const int kLaneCount = lane_count; \
973 DCHECK(args.length() == 2); \ 975 DCHECK(args.length() == 2); \
974 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, tarray, 0); \ 976 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, tarray, 0); \
975 CONVERT_INT32_ARG_CHECKED(index, 1) \ 977 CONVERT_INT32_ARG_CHECKED(index, 1) \
976 size_t bpe = tarray->element_size(); \ 978 size_t bpe = tarray->element_size(); \
977 uint32_t bytes = count * sizeof(lane_type); \ 979 uint32_t bytes = count * sizeof(lane_type); \
978 size_t byte_length = NumberToSize(isolate, tarray->byte_length()); \ 980 size_t byte_length = NumberToSize(isolate, tarray->byte_length()); \
979 RUNTIME_ASSERT(index >= 0 && index * bpe + bytes <= byte_length); \ 981 RUNTIME_ASSERT(index >= 0 && index * bpe + bytes <= byte_length); \
980 size_t tarray_offset = NumberToSize(isolate, tarray->byte_offset()); \ 982 size_t tarray_offset = NumberToSize(isolate, tarray->byte_offset()); \
981 uint8_t* tarray_base = \ 983 uint8_t* tarray_base = \
982 static_cast<uint8_t*>(tarray->GetBuffer()->backing_store()) + \ 984 static_cast<uint8_t*>(tarray->GetBuffer()->backing_store()) + \
983 tarray_offset; \ 985 tarray_offset; \
984 lane_type lanes[kLaneCount] = {0}; \ 986 lane_type lanes[kLaneCount] = {0}; \
985 memcpy(lanes, tarray_base + index * bpe, bytes); \ 987 memcpy(lanes, tarray_base + index * bpe, bytes); \
986 Handle<type> result = isolate->factory()->New##type(lanes); 988 Handle<type> result = isolate->factory()->New##type(lanes);
987 989
988 990
991 #define SIMD_STORE(type, lane_type, lane_count, count, a) \
992 static const int kLaneCount = lane_count; \
993 DCHECK(args.length() == 3); \
994 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, tarray, 0); \
995 CONVERT_INT32_ARG_CHECKED(index, 1) \
996 CONVERT_ARG_HANDLE_CHECKED(type, a, 2); \
997 size_t bpe = tarray->element_size(); \
998 uint32_t bytes = count * sizeof(lane_type); \
999 size_t byte_length = NumberToSize(isolate, tarray->byte_length()); \
1000 RUNTIME_ASSERT(index >= 0 && index * bpe + bytes <= byte_length); \
1001 size_t tarray_offset = NumberToSize(isolate, tarray->byte_offset()); \
1002 uint8_t* tarray_base = \
1003 static_cast<uint8_t*>(tarray->GetBuffer()->backing_store()) + \
1004 tarray_offset; \
1005 lane_type lanes[kLaneCount]; \
1006 for (int i = 0; i < kLaneCount; i++) { \
1007 lanes[i] = a->get_lane(i); \
1008 } \
1009 memcpy(tarray_base + index * bpe, lanes, bytes);
1010
1011
989 #define SIMD_LOAD_FUNCTION(type, lane_type, lane_count) \ 1012 #define SIMD_LOAD_FUNCTION(type, lane_type, lane_count) \
990 RUNTIME_FUNCTION(Runtime_##type##Load) { \ 1013 RUNTIME_FUNCTION(Runtime_##type##Load) { \
991 HandleScope scope(isolate); \ 1014 HandleScope scope(isolate); \
992 SIMD_LOAD(type, lane_type, lane_count, lane_count, result); \ 1015 SIMD_LOAD(type, lane_type, lane_count, lane_count, result); \
993 return *result; \ 1016 return *result; \
994 } 1017 }
995 1018
996 1019
997 #define SIMD_LOAD1_FUNCTION(type, lane_type, lane_count) \ 1020 #define SIMD_LOAD1_FUNCTION(type, lane_type, lane_count) \
998 RUNTIME_FUNCTION(Runtime_##type##Load1) { \ 1021 RUNTIME_FUNCTION(Runtime_##type##Load1) { \
(...skipping 12 matching lines...) Expand all
1011 1034
1012 1035
1013 #define SIMD_LOAD3_FUNCTION(type, lane_type, lane_count) \ 1036 #define SIMD_LOAD3_FUNCTION(type, lane_type, lane_count) \
1014 RUNTIME_FUNCTION(Runtime_##type##Load3) { \ 1037 RUNTIME_FUNCTION(Runtime_##type##Load3) { \
1015 HandleScope scope(isolate); \ 1038 HandleScope scope(isolate); \
1016 SIMD_LOAD(type, lane_type, lane_count, 3, result); \ 1039 SIMD_LOAD(type, lane_type, lane_count, 3, result); \
1017 return *result; \ 1040 return *result; \
1018 } 1041 }
1019 1042
1020 1043
1044 #define SIMD_STORE_FUNCTION(type, lane_type, lane_count) \
1045 RUNTIME_FUNCTION(Runtime_##type##Store) { \
1046 HandleScope scope(isolate); \
1047 SIMD_STORE(type, lane_type, lane_count, lane_count, a); \
1048 return *a; \
1049 }
1050
1051
1052 #define SIMD_STORE1_FUNCTION(type, lane_type, lane_count) \
1053 RUNTIME_FUNCTION(Runtime_##type##Store1) { \
1054 HandleScope scope(isolate); \
1055 SIMD_STORE(type, lane_type, lane_count, 1, a); \
1056 return *a; \
1057 }
1058
1059
1060 #define SIMD_STORE2_FUNCTION(type, lane_type, lane_count) \
1061 RUNTIME_FUNCTION(Runtime_##type##Store2) { \
1062 HandleScope scope(isolate); \
1063 SIMD_STORE(type, lane_type, lane_count, 2, a); \
1064 return *a; \
1065 }
1066
1067
1068 #define SIMD_STORE3_FUNCTION(type, lane_type, lane_count) \
1069 RUNTIME_FUNCTION(Runtime_##type##Store3) { \
1070 HandleScope scope(isolate); \
1071 SIMD_STORE(type, lane_type, lane_count, 3, a); \
1072 return *a; \
1073 }
1074
1075
1021 SIMD_NUMERIC_TYPES(SIMD_LOAD_FUNCTION) 1076 SIMD_NUMERIC_TYPES(SIMD_LOAD_FUNCTION)
1022 SIMD_LOADN_STOREN_TYPES(SIMD_LOAD1_FUNCTION) 1077 SIMD_LOADN_STOREN_TYPES(SIMD_LOAD1_FUNCTION)
1023 SIMD_LOADN_STOREN_TYPES(SIMD_LOAD2_FUNCTION) 1078 SIMD_LOADN_STOREN_TYPES(SIMD_LOAD2_FUNCTION)
1024 SIMD_LOADN_STOREN_TYPES(SIMD_LOAD3_FUNCTION) 1079 SIMD_LOADN_STOREN_TYPES(SIMD_LOAD3_FUNCTION)
1080 SIMD_NUMERIC_TYPES(SIMD_STORE_FUNCTION)
1081 SIMD_LOADN_STOREN_TYPES(SIMD_STORE1_FUNCTION)
1082 SIMD_LOADN_STOREN_TYPES(SIMD_STORE2_FUNCTION)
1083 SIMD_LOADN_STOREN_TYPES(SIMD_STORE3_FUNCTION)
1025 1084
1026 //------------------------------------------------------------------- 1085 //-------------------------------------------------------------------
1027 1086
1028 } // namespace internal 1087 } // namespace internal
1029 } // namespace v8 1088 } // namespace v8
OLDNEW
« no previous file with comments | « src/runtime/runtime.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698