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

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: Re-enabling polyfill 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
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 939 matching lines...) Expand 10 before | Expand all | Expand 10 after
950 DCHECK(args.length() == 1); \ 950 DCHECK(args.length() == 1); \
951 CONVERT_ARG_HANDLE_CHECKED(from_type, a, 0); \ 951 CONVERT_ARG_HANDLE_CHECKED(from_type, a, 0); \
952 lane_type lanes[kLaneCount]; \ 952 lane_type lanes[kLaneCount]; \
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
961 //-------------------------------------------------------------------
962
963 // Load and Store functions.
964 #define SIMD_LOADN_STOREN_TYPES(FUNCTION) \
965 FUNCTION(Float32x4, float, 4) \
966 FUNCTION(Int32x4, int32_t, 4) \
967 FUNCTION(Uint32x4, uint32_t, 4)
968
969
970 // Common Load and Store Functions
971 #define SIMD_STORE(type, lane_type, lane_count, count, a) \
972 static const int kLaneCount = lane_count; \
973 DCHECK(args.length() == 3); \
974 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, tarray, 0); \
975 CONVERT_INT32_ARG_CHECKED(index, 1) \
976 CONVERT_ARG_HANDLE_CHECKED(type, a, 2); \
977 size_t bpe = tarray->element_size(); \
978 uint32_t bytes = count * sizeof(lane_type); \
979 size_t byte_length = NumberToSize(isolate, tarray->byte_length()); \
980 RUNTIME_ASSERT(index >= 0 && index * bpe + bytes <= byte_length); \
981 size_t tarray_offset = NumberToSize(isolate, tarray->byte_offset()); \
982 uint8_t* tarray_base = \
983 static_cast<uint8_t*>(tarray->GetBuffer()->backing_store()) + \
984 tarray_offset; \
985 lane_type lanes[kLaneCount]; \
986 for (int i = 0; i < kLaneCount; i++) { \
987 lanes[i] = a->get_lane(i); \
988 } \
989 memcpy(tarray_base + index * bpe, lanes, bytes);
990
991
992 #define SIMD_STORE_FUNCTION(type, lane_type, lane_count) \
993 RUNTIME_FUNCTION(Runtime_##type##Store) { \
994 HandleScope scope(isolate); \
995 SIMD_STORE(type, lane_type, lane_count, lane_count, a); \
996 return *a; \
997 }
998
999
1000 #define SIMD_STORE1_FUNCTION(type, lane_type, lane_count) \
1001 RUNTIME_FUNCTION(Runtime_##type##Store1) { \
1002 HandleScope scope(isolate); \
1003 SIMD_STORE(type, lane_type, lane_count, 1, a); \
1004 return *a; \
1005 }
1006
1007
1008 #define SIMD_STORE2_FUNCTION(type, lane_type, lane_count) \
1009 RUNTIME_FUNCTION(Runtime_##type##Store2) { \
1010 HandleScope scope(isolate); \
1011 SIMD_STORE(type, lane_type, lane_count, 2, a); \
1012 return *a; \
1013 }
1014
1015
1016 #define SIMD_STORE3_FUNCTION(type, lane_type, lane_count) \
1017 RUNTIME_FUNCTION(Runtime_##type##Store3) { \
1018 HandleScope scope(isolate); \
1019 SIMD_STORE(type, lane_type, lane_count, 3, a); \
1020 return *a; \
1021 }
1022
1023
1024 SIMD_NUMERIC_TYPES(SIMD_STORE_FUNCTION)
1025 SIMD_LOADN_STOREN_TYPES(SIMD_STORE1_FUNCTION)
1026 SIMD_LOADN_STOREN_TYPES(SIMD_STORE2_FUNCTION)
1027 SIMD_LOADN_STOREN_TYPES(SIMD_STORE3_FUNCTION)
1028
1029 //-------------------------------------------------------------------
1030
960 } // namespace internal 1031 } // namespace internal
961 } // namespace v8 1032 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698