Index: src/runtime/runtime-simd.cc |
diff --git a/src/runtime/runtime-simd.cc b/src/runtime/runtime-simd.cc |
index ce9512e8da4b14c73469a879861efc2ca650ce46..24df048f0a0027330a3acb0da8ff70e0b26b87f8 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,75 @@ 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_LOADN_STOREN_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) \ |
+ Handle<JSTypedArray> tarray(JSTypedArray::cast(*tarray_obj)); \ |
bbudge
2015/08/21 22:32:42
I don't think this line is necessary (CONVERT_ARG_
gdeepti
2015/08/21 22:49:40
Done.
|
+ 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; \ |
+ 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_LOADN_STOREN_TYPES(SIMD_LOAD1_FUNCTION) |
+SIMD_LOADN_STOREN_TYPES(SIMD_LOAD2_FUNCTION) |
+SIMD_LOADN_STOREN_TYPES(SIMD_LOAD3_FUNCTION) |
+ |
+//------------------------------------------------------------------- |
+ |
} // namespace internal |
} // namespace v8 |