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

Unified 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: Bill's comments 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
« src/harmony-simd.js ('K') | « src/runtime/runtime.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime/runtime-simd.cc
diff --git a/src/runtime/runtime-simd.cc b/src/runtime/runtime-simd.cc
index ce9512e8da4b14c73469a879861efc2ca650ce46..83acabe21f080cd542ea74400f7cbeb0b6d4d721 100644
--- a/src/runtime/runtime-simd.cc
+++ b/src/runtime/runtime-simd.cc
@@ -588,6 +588,7 @@ SIMD_SMALL_INT_TYPES(SIMD_SUB_SATURATE_FUNCTION)
return *result; \
}
+
SIMD_NUMERIC_TYPES(SIMD_NEG_FUNCTION)
SIMD_NUMERIC_TYPES(SIMD_ADD_FUNCTION)
SIMD_NUMERIC_TYPES(SIMD_SUB_FUNCTION)
@@ -817,5 +818,76 @@ RUNTIME_FUNCTION(Runtime_Int8x16UnsignedExtractLane) {
CONVERT_SIMD_LANE_ARG_CHECKED(lane, 1, 16);
return *isolate->factory()->NewNumber(bit_cast<uint8_t>(a->get_lane(lane)));
}
+
+
+//-------------------------------------------------------------------
+
+// Load functions.
+#define SIMD_MEMORY_OP_TYPES(FUNCTION) \
+ FUNCTION(Float32x4, float, 4) \
+ FUNCTION(Int32x4, int32_t, 4)
+
+
+// Common Load Functions
+#define SIMD_LOAD(type, lane_type, lane_count, count, result) \
+ static const int kLaneCount = lane_count; \
+ lane_type lanes[kLaneCount] = {0}; \
+ Handle<type> result; \
+ DCHECK(args.length() == 2); \
+ CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, tarray_obj, 0); \
+ CONVERT_INT32_ARG_CHECKED(index, 1) \
+ RUNTIME_ASSERT(index >= 0); \
bbudge 2015/08/20 23:05:25 Combine this with the one below, i.e. index >= 0 &
gdeepti 2015/08/21 21:07:50 Done.
+ Handle<JSTypedArray> tarray(JSTypedArray::cast(*tarray_obj)); \
+ 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* bpe + bytes <= byte_length); \
bbudge 2015/08/20 23:05:26 nit: space after 'index'
gdeepti 2015/08/21 21:07:50 Done.
+ size_t tarray_offset = NumberToSize(isolate, tarray->byte_offset()); \
+ uint8_t* tarray_base = \
+ static_cast<uint8_t*>(tarray->GetBuffer()->backing_store()) + \
+ tarray_offset; \
+ memcpy(lanes, tarray_base + (index)*bpe, bytes); \
+ result = isolate->factory()->New##type(lanes);
+
+
+#define SIMD_LOAD_FUNCTION(type, lane_type, lane_count) \
+ RUNTIME_FUNCTION(Runtime_##type##Load) { \
+ HandleScope scope(isolate); \
+ SIMD_LOAD(type, lane_type, lane_count, lane_count, result); \
+ return *result; \
+ }
+
+
+#define SIMD_LOAD1_FUNCTION(type, lane_type, lane_count) \
+ RUNTIME_FUNCTION(Runtime_##type##Load1) { \
+ HandleScope scope(isolate); \
+ SIMD_LOAD(type, lane_type, lane_count, 1, result); \
+ return *result; \
+ }
+
+
+#define SIMD_LOAD2_FUNCTION(type, lane_type, lane_count) \
+ RUNTIME_FUNCTION(Runtime_##type##Load2) { \
+ HandleScope scope(isolate); \
+ SIMD_LOAD(type, lane_type, lane_count, 2, result); \
+ return *result; \
+ }
+
+
+#define SIMD_LOAD3_FUNCTION(type, lane_type, lane_count) \
+ RUNTIME_FUNCTION(Runtime_##type##Load3) { \
+ HandleScope scope(isolate); \
+ SIMD_LOAD(type, lane_type, lane_count, 3, result); \
+ return *result; \
+ }
+
+
+SIMD_NUMERIC_TYPES(SIMD_LOAD_FUNCTION)
+SIMD_MEMORY_OP_TYPES(SIMD_LOAD1_FUNCTION)
+SIMD_MEMORY_OP_TYPES(SIMD_LOAD2_FUNCTION)
+SIMD_MEMORY_OP_TYPES(SIMD_LOAD3_FUNCTION)
+
+//-------------------------------------------------------------------
+
} // namespace internal
} // namespace v8
« src/harmony-simd.js ('K') | « src/runtime/runtime.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698