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

Unified 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, 4 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 side-by-side diff with in-line comments
Download patch
Index: src/runtime/runtime-simd.cc
diff --git a/src/runtime/runtime-simd.cc b/src/runtime/runtime-simd.cc
index a202b64306deb47dc6178d82c8b336a9b63a6164..1883e8e2d9102e0f241265324a8143927117927b 100644
--- a/src/runtime/runtime-simd.cc
+++ b/src/runtime/runtime-simd.cc
@@ -957,5 +957,76 @@ SIMD_FROM_TYPES(SIMD_FROM_FUNCTION)
SIMD_FROM_BITS_TYPES(SIMD_FROM_BITS_FUNCTION)
+
+//-------------------------------------------------------------------
+
+// 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 and Store Functions
+#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_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_STORE_FUNCTION)
+SIMD_LOADN_STOREN_TYPES(SIMD_STORE1_FUNCTION)
+SIMD_LOADN_STOREN_TYPES(SIMD_STORE2_FUNCTION)
+SIMD_LOADN_STOREN_TYPES(SIMD_STORE3_FUNCTION)
+
+//-------------------------------------------------------------------
+
} // namespace internal
} // namespace v8

Powered by Google App Engine
This is Rietveld 408576698