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

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

Issue 1302133002: [simd.js] Add SIMD load functions for Phase 1. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fixed format 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 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 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 Functions
971 #define SIMD_LOAD(type, lane_type, lane_count, count, result) \
972 static const int kLaneCount = lane_count; \
973 DCHECK(args.length() == 2); \
974 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, tarray, 0); \
975 CONVERT_INT32_ARG_CHECKED(index, 1) \
976 size_t bpe = tarray->element_size(); \
977 uint32_t bytes = count * sizeof(lane_type); \
978 size_t byte_length = NumberToSize(isolate, tarray->byte_length()); \
979 RUNTIME_ASSERT(index >= 0 && index * bpe + bytes <= byte_length); \
980 size_t tarray_offset = NumberToSize(isolate, tarray->byte_offset()); \
981 uint8_t* tarray_base = \
982 static_cast<uint8_t*>(tarray->GetBuffer()->backing_store()) + \
983 tarray_offset; \
984 lane_type lanes[kLaneCount] = {0}; \
985 memcpy(lanes, tarray_base + index * bpe, bytes); \
986 Handle<type> result = isolate->factory()->New##type(lanes);
987
988
989 #define SIMD_LOAD_FUNCTION(type, lane_type, lane_count) \
990 RUNTIME_FUNCTION(Runtime_##type##Load) { \
991 HandleScope scope(isolate); \
992 SIMD_LOAD(type, lane_type, lane_count, lane_count, result); \
993 return *result; \
994 }
995
996
997 #define SIMD_LOAD1_FUNCTION(type, lane_type, lane_count) \
998 RUNTIME_FUNCTION(Runtime_##type##Load1) { \
999 HandleScope scope(isolate); \
1000 SIMD_LOAD(type, lane_type, lane_count, 1, result); \
1001 return *result; \
1002 }
1003
1004
1005 #define SIMD_LOAD2_FUNCTION(type, lane_type, lane_count) \
1006 RUNTIME_FUNCTION(Runtime_##type##Load2) { \
1007 HandleScope scope(isolate); \
1008 SIMD_LOAD(type, lane_type, lane_count, 2, result); \
1009 return *result; \
1010 }
1011
1012
1013 #define SIMD_LOAD3_FUNCTION(type, lane_type, lane_count) \
1014 RUNTIME_FUNCTION(Runtime_##type##Load3) { \
1015 HandleScope scope(isolate); \
1016 SIMD_LOAD(type, lane_type, lane_count, 3, result); \
1017 return *result; \
1018 }
1019
1020
1021 SIMD_NUMERIC_TYPES(SIMD_LOAD_FUNCTION)
1022 SIMD_LOADN_STOREN_TYPES(SIMD_LOAD1_FUNCTION)
1023 SIMD_LOADN_STOREN_TYPES(SIMD_LOAD2_FUNCTION)
1024 SIMD_LOADN_STOREN_TYPES(SIMD_LOAD3_FUNCTION)
1025
1026 //-------------------------------------------------------------------
1027
960 } // namespace internal 1028 } // namespace internal
961 } // namespace v8 1029 } // 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