Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 161 HandleScope scope(isolate); | 161 HandleScope scope(isolate); |
| 162 DCHECK(args.length() == 1); | 162 DCHECK(args.length() == 1); |
| 163 return isolate->heap()->ToBoolean(args[0]->IsSimd128Value()); | 163 return isolate->heap()->ToBoolean(args[0]->IsSimd128Value()); |
| 164 } | 164 } |
| 165 | 165 |
| 166 | 166 |
| 167 //------------------------------------------------------------------- | 167 //------------------------------------------------------------------- |
| 168 | 168 |
| 169 // Utility macros. | 169 // Utility macros. |
| 170 | 170 |
| 171 #define CONVERT_SIMD_LANE_ARG_CHECKED(name, index, lanes) \ | 171 #define CONVERT_SIMD_LANE_ARG_CHECKED(name, index, lanes) \ |
| 172 CONVERT_INT32_ARG_CHECKED(name, index); \ | 172 Handle<Object> name_object = args.at<Object>(index); \ |
| 173 RUNTIME_ASSERT(name >= 0 && name < lanes); | 173 if (!name_object->IsNumber() || !IsInt32Double(name_object->Number())) { \ |
|
bbudge
2016/05/18 09:31:13
IsInt32Double rejects -0. Reading the spec, it loo
gdeepti
2016/05/19 12:11:56
The Spec specifies ToNumber conversion, but that h
| |
| 174 THROW_NEW_ERROR_RETURN_FAILURE( \ | |
| 175 isolate, NewTypeError(MessageTemplate::kInvalidSimdOperation)); \ | |
|
bbudge
2016/05/18 09:31:13
It seems like kInvalidSimdIndex would be a more in
gdeepti
2016/05/19 12:11:56
Done.
| |
| 176 } \ | |
| 177 uint32_t name = name_object->Number(); \ | |
| 178 if (name < 0 || name >= lanes) { \ | |
| 179 THROW_NEW_ERROR_RETURN_FAILURE( \ | |
| 180 isolate, NewRangeError(MessageTemplate::kInvalidSimdIndex)); \ | |
| 181 } | |
| 174 | 182 |
| 175 #define CONVERT_SIMD_ARG_HANDLE_THROW(Type, name, index) \ | 183 #define CONVERT_SIMD_ARG_HANDLE_THROW(Type, name, index) \ |
| 176 Handle<Type> name; \ | 184 Handle<Type> name; \ |
| 177 if (args[index]->Is##Type()) { \ | 185 if (args[index]->Is##Type()) { \ |
| 178 name = args.at<Type>(index); \ | 186 name = args.at<Type>(index); \ |
| 179 } else { \ | 187 } else { \ |
| 180 THROW_NEW_ERROR_RETURN_FAILURE( \ | 188 THROW_NEW_ERROR_RETURN_FAILURE( \ |
| 181 isolate, NewTypeError(MessageTemplate::kInvalidSimdOperation)); \ | 189 isolate, NewTypeError(MessageTemplate::kInvalidSimdOperation)); \ |
| 182 } | 190 } |
| 183 | 191 |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 210 bool lanes[kLaneCount]; \ | 218 bool lanes[kLaneCount]; \ |
| 211 for (int i = 0; i < kLaneCount; i++) { \ | 219 for (int i = 0; i < kLaneCount; i++) { \ |
| 212 lanes[i] = a->get_lane(i) op b->get_lane(i); \ | 220 lanes[i] = a->get_lane(i) op b->get_lane(i); \ |
| 213 } \ | 221 } \ |
| 214 Handle<bool_type> result = isolate->factory()->New##bool_type(lanes); | 222 Handle<bool_type> result = isolate->factory()->New##bool_type(lanes); |
| 215 | 223 |
| 216 //------------------------------------------------------------------- | 224 //------------------------------------------------------------------- |
| 217 | 225 |
| 218 // Common functions. | 226 // Common functions. |
| 219 | 227 |
| 220 #define GET_NUMERIC_ARG(lane_type, name, index) \ | 228 #define GET_NUMERIC_ARG(lane_type, name, index) \ |
| 221 CONVERT_NUMBER_ARG_HANDLE_CHECKED(a, index); \ | 229 Handle<Object> a; \ |
| 230 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( \ | |
| 231 isolate, a, Object::ToNumber(args.at<Object>(index))); \ | |
| 222 name = ConvertNumber<lane_type>(a->Number()); | 232 name = ConvertNumber<lane_type>(a->Number()); |
| 223 | 233 |
| 224 #define GET_BOOLEAN_ARG(lane_type, name, index) \ | 234 #define GET_BOOLEAN_ARG(lane_type, name, index) \ |
| 225 name = args[index]->BooleanValue(); | 235 name = args[index]->BooleanValue(); |
| 226 | 236 |
| 227 #define SIMD_ALL_TYPES(FUNCTION) \ | 237 #define SIMD_ALL_TYPES(FUNCTION) \ |
| 228 FUNCTION(Float32x4, float, 4, NewNumber, GET_NUMERIC_ARG) \ | 238 FUNCTION(Float32x4, float, 4, NewNumber, GET_NUMERIC_ARG) \ |
| 229 FUNCTION(Int32x4, int32_t, 4, NewNumber, GET_NUMERIC_ARG) \ | 239 FUNCTION(Int32x4, int32_t, 4, NewNumber, GET_NUMERIC_ARG) \ |
| 230 FUNCTION(Uint32x4, uint32_t, 4, NewNumber, GET_NUMERIC_ARG) \ | 240 FUNCTION(Uint32x4, uint32_t, 4, NewNumber, GET_NUMERIC_ARG) \ |
| 231 FUNCTION(Bool32x4, bool, 4, ToBoolean, GET_BOOLEAN_ARG) \ | 241 FUNCTION(Bool32x4, bool, 4, ToBoolean, GET_BOOLEAN_ARG) \ |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 388 #define SIMD_INT_TYPES(FUNCTION) \ | 398 #define SIMD_INT_TYPES(FUNCTION) \ |
| 389 FUNCTION(Int32x4, int32_t, 32, 4) \ | 399 FUNCTION(Int32x4, int32_t, 32, 4) \ |
| 390 FUNCTION(Int16x8, int16_t, 16, 8) \ | 400 FUNCTION(Int16x8, int16_t, 16, 8) \ |
| 391 FUNCTION(Int8x16, int8_t, 8, 16) | 401 FUNCTION(Int8x16, int8_t, 8, 16) |
| 392 | 402 |
| 393 #define SIMD_UINT_TYPES(FUNCTION) \ | 403 #define SIMD_UINT_TYPES(FUNCTION) \ |
| 394 FUNCTION(Uint32x4, uint32_t, 32, 4) \ | 404 FUNCTION(Uint32x4, uint32_t, 32, 4) \ |
| 395 FUNCTION(Uint16x8, uint16_t, 16, 8) \ | 405 FUNCTION(Uint16x8, uint16_t, 16, 8) \ |
| 396 FUNCTION(Uint8x16, uint8_t, 8, 16) | 406 FUNCTION(Uint8x16, uint8_t, 8, 16) |
| 397 | 407 |
| 398 #define CONVERT_SHIFT_ARG_CHECKED(name, index) \ | 408 #define CONVERT_SHIFT_ARG_CHECKED(name, index) \ |
| 399 RUNTIME_ASSERT(args[index]->IsNumber()); \ | 409 Handle<Object> name_object = args.at<Object>(index); \ |
| 400 int32_t signed_shift = 0; \ | 410 if (!name_object->IsNumber() || !IsInt32Double(name_object->Number())) { \ |
|
bbudge
2016/05/18 09:31:13
From the spec, the conversion for shift counts is
gdeepti
2016/05/19 12:11:56
Not sure if I'm understanding this correctly, the
| |
| 401 RUNTIME_ASSERT(args[index]->ToInt32(&signed_shift)); \ | 411 THROW_NEW_ERROR_RETURN_FAILURE( \ |
| 412 isolate, NewTypeError(MessageTemplate::kInvalidSimdOperation)); \ | |
| 413 } \ | |
| 414 int32_t signed_shift = 0; \ | |
| 415 RUNTIME_ASSERT(args[index]->ToInt32(&signed_shift)); \ | |
| 402 uint32_t name = bit_cast<uint32_t>(signed_shift); | 416 uint32_t name = bit_cast<uint32_t>(signed_shift); |
| 403 | 417 |
| 404 #define SIMD_LSL_FUNCTION(type, lane_type, lane_bits, lane_count) \ | 418 #define SIMD_LSL_FUNCTION(type, lane_type, lane_bits, lane_count) \ |
| 405 RUNTIME_FUNCTION(Runtime_##type##ShiftLeftByScalar) { \ | 419 RUNTIME_FUNCTION(Runtime_##type##ShiftLeftByScalar) { \ |
| 406 static const int kLaneCount = lane_count; \ | 420 static const int kLaneCount = lane_count; \ |
| 407 HandleScope scope(isolate); \ | 421 HandleScope scope(isolate); \ |
| 408 DCHECK(args.length() == 2); \ | 422 DCHECK(args.length() == 2); \ |
| 409 CONVERT_SIMD_ARG_HANDLE_THROW(type, a, 0); \ | 423 CONVERT_SIMD_ARG_HANDLE_THROW(type, a, 0); \ |
| 410 CONVERT_SHIFT_ARG_CHECKED(shift, 1); \ | 424 CONVERT_SHIFT_ARG_CHECKED(shift, 1); \ |
| 411 lane_type lanes[kLaneCount] = {0}; \ | 425 lane_type lanes[kLaneCount] = {0}; \ |
| 412 if (shift < lane_bits) { \ | 426 shift &= lane_bits - 1; \ |
| 413 for (int i = 0; i < kLaneCount; i++) { \ | 427 for (int i = 0; i < kLaneCount; i++) { \ |
| 414 lanes[i] = a->get_lane(i) << shift; \ | 428 lanes[i] = a->get_lane(i) << shift; \ |
| 415 } \ | |
| 416 } \ | 429 } \ |
| 417 Handle<type> result = isolate->factory()->New##type(lanes); \ | 430 Handle<type> result = isolate->factory()->New##type(lanes); \ |
| 418 return *result; \ | 431 return *result; \ |
| 419 } | 432 } |
| 420 | 433 |
| 421 #define SIMD_LSR_FUNCTION(type, lane_type, lane_bits, lane_count) \ | 434 #define SIMD_LSR_FUNCTION(type, lane_type, lane_bits, lane_count) \ |
| 422 RUNTIME_FUNCTION(Runtime_##type##ShiftRightByScalar) { \ | 435 RUNTIME_FUNCTION(Runtime_##type##ShiftRightByScalar) { \ |
| 423 static const int kLaneCount = lane_count; \ | 436 static const int kLaneCount = lane_count; \ |
| 424 HandleScope scope(isolate); \ | 437 HandleScope scope(isolate); \ |
| 425 DCHECK(args.length() == 2); \ | 438 DCHECK(args.length() == 2); \ |
| 426 CONVERT_SIMD_ARG_HANDLE_THROW(type, a, 0); \ | 439 CONVERT_SIMD_ARG_HANDLE_THROW(type, a, 0); \ |
| 427 CONVERT_SHIFT_ARG_CHECKED(shift, 1); \ | 440 CONVERT_SHIFT_ARG_CHECKED(shift, 1); \ |
| 428 lane_type lanes[kLaneCount] = {0}; \ | 441 lane_type lanes[kLaneCount] = {0}; \ |
| 429 if (shift < lane_bits) { \ | 442 shift &= lane_bits - 1; \ |
| 430 for (int i = 0; i < kLaneCount; i++) { \ | 443 for (int i = 0; i < kLaneCount; i++) { \ |
| 431 lanes[i] = static_cast<lane_type>( \ | 444 lanes[i] = static_cast<lane_type>(bit_cast<lane_type>(a->get_lane(i)) >> \ |
| 432 bit_cast<lane_type>(a->get_lane(i)) >> shift); \ | 445 shift); \ |
| 433 } \ | 446 } \ |
| 434 } \ | 447 Handle<type> result = isolate->factory()->New##type(lanes); \ |
| 435 Handle<type> result = isolate->factory()->New##type(lanes); \ | 448 return *result; \ |
| 436 return *result; \ | |
| 437 } | 449 } |
| 438 | 450 |
| 439 #define SIMD_ASR_FUNCTION(type, lane_type, lane_bits, lane_count) \ | 451 #define SIMD_ASR_FUNCTION(type, lane_type, lane_bits, lane_count) \ |
| 440 RUNTIME_FUNCTION(Runtime_##type##ShiftRightByScalar) { \ | 452 RUNTIME_FUNCTION(Runtime_##type##ShiftRightByScalar) { \ |
| 441 static const int kLaneCount = lane_count; \ | 453 static const int kLaneCount = lane_count; \ |
| 442 HandleScope scope(isolate); \ | 454 HandleScope scope(isolate); \ |
| 443 DCHECK(args.length() == 2); \ | 455 DCHECK(args.length() == 2); \ |
| 444 CONVERT_SIMD_ARG_HANDLE_THROW(type, a, 0); \ | 456 CONVERT_SIMD_ARG_HANDLE_THROW(type, a, 0); \ |
| 445 CONVERT_SHIFT_ARG_CHECKED(shift, 1); \ | 457 CONVERT_SHIFT_ARG_CHECKED(shift, 1); \ |
| 446 if (shift >= lane_bits) shift = lane_bits - 1; \ | 458 shift &= lane_bits - 1; \ |
| 447 lane_type lanes[kLaneCount]; \ | 459 lane_type lanes[kLaneCount]; \ |
| 448 for (int i = 0; i < kLaneCount; i++) { \ | 460 for (int i = 0; i < kLaneCount; i++) { \ |
| 449 int64_t shifted = static_cast<int64_t>(a->get_lane(i)) >> shift; \ | 461 int64_t shifted = static_cast<int64_t>(a->get_lane(i)) >> shift; \ |
| 450 lanes[i] = static_cast<lane_type>(shifted); \ | 462 lanes[i] = static_cast<lane_type>(shifted); \ |
| 451 } \ | 463 } \ |
| 452 Handle<type> result = isolate->factory()->New##type(lanes); \ | 464 Handle<type> result = isolate->factory()->New##type(lanes); \ |
| 453 return *result; \ | 465 return *result; \ |
| 454 } | 466 } |
| 455 | 467 |
| 456 SIMD_INT_TYPES(SIMD_LSL_FUNCTION) | 468 SIMD_INT_TYPES(SIMD_LSL_FUNCTION) |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 777 FUNCTION(Uint8x16, uint8_t, 16, Int8x16, int8_t) | 789 FUNCTION(Uint8x16, uint8_t, 16, Int8x16, int8_t) |
| 778 | 790 |
| 779 #define SIMD_FROM_FUNCTION(type, lane_type, lane_count, from_type, from_ctype) \ | 791 #define SIMD_FROM_FUNCTION(type, lane_type, lane_count, from_type, from_ctype) \ |
| 780 RUNTIME_FUNCTION(Runtime_##type##From##from_type) { \ | 792 RUNTIME_FUNCTION(Runtime_##type##From##from_type) { \ |
| 781 static const int kLaneCount = lane_count; \ | 793 static const int kLaneCount = lane_count; \ |
| 782 HandleScope scope(isolate); \ | 794 HandleScope scope(isolate); \ |
| 783 DCHECK(args.length() == 1); \ | 795 DCHECK(args.length() == 1); \ |
| 784 CONVERT_SIMD_ARG_HANDLE_THROW(from_type, a, 0); \ | 796 CONVERT_SIMD_ARG_HANDLE_THROW(from_type, a, 0); \ |
| 785 lane_type lanes[kLaneCount]; \ | 797 lane_type lanes[kLaneCount]; \ |
| 786 for (int i = 0; i < kLaneCount; i++) { \ | 798 for (int i = 0; i < kLaneCount; i++) { \ |
| 787 from_ctype a_value = a->get_lane(i); \ | 799 from_ctype a_value = std::trunc(a->get_lane(i)); \ |
| 788 if (a_value != a_value) a_value = 0; \ | 800 if (a_value != a_value || !CanCast<lane_type>(a_value)) { \ |
| 789 RUNTIME_ASSERT(CanCast<lane_type>(a_value)); \ | 801 THROW_NEW_ERROR_RETURN_FAILURE( \ |
| 802 isolate, NewRangeError(MessageTemplate::kInvalidSimdIndex)); \ | |
|
bbudge
2016/05/18 09:31:13
Invalid SIMD index doesn't seem right here since t
gdeepti
2016/05/19 12:11:56
Done.
| |
| 803 } \ | |
| 790 lanes[i] = static_cast<lane_type>(a_value); \ | 804 lanes[i] = static_cast<lane_type>(a_value); \ |
| 791 } \ | 805 } \ |
| 792 Handle<type> result = isolate->factory()->New##type(lanes); \ | 806 Handle<type> result = isolate->factory()->New##type(lanes); \ |
| 793 return *result; \ | 807 return *result; \ |
| 794 } | 808 } |
| 795 | 809 |
| 796 SIMD_FROM_TYPES(SIMD_FROM_FUNCTION) | 810 SIMD_FROM_TYPES(SIMD_FROM_FUNCTION) |
| 797 | 811 |
| 798 #define SIMD_FROM_BITS_TYPES(FUNCTION) \ | 812 #define SIMD_FROM_BITS_TYPES(FUNCTION) \ |
| 799 FUNCTION(Float32x4, float, 4, Int32x4) \ | 813 FUNCTION(Float32x4, float, 4, Int32x4) \ |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 856 | 870 |
| 857 //------------------------------------------------------------------- | 871 //------------------------------------------------------------------- |
| 858 | 872 |
| 859 // Load and Store functions. | 873 // Load and Store functions. |
| 860 | 874 |
| 861 #define SIMD_LOADN_STOREN_TYPES(FUNCTION) \ | 875 #define SIMD_LOADN_STOREN_TYPES(FUNCTION) \ |
| 862 FUNCTION(Float32x4, float, 4) \ | 876 FUNCTION(Float32x4, float, 4) \ |
| 863 FUNCTION(Int32x4, int32_t, 4) \ | 877 FUNCTION(Int32x4, int32_t, 4) \ |
| 864 FUNCTION(Uint32x4, uint32_t, 4) | 878 FUNCTION(Uint32x4, uint32_t, 4) |
| 865 | 879 |
| 880 #define SIMD_COERCE_INDEX(name, i) \ | |
| 881 Handle<Object> name_object; \ | |
| 882 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, name_object, \ | |
| 883 Object::ToNumber(args.at<Object>(i))); \ | |
| 884 if (name_object->Number() != std::floor(name_object->Number())) { \ | |
|
bbudge
2016/05/18 09:31:13
The spec says the conversion is ToLength.
http://
gdeepti
2016/05/19 12:11:56
Added index ≠ ToLength(index) check as per spec.
| |
| 885 THROW_NEW_ERROR_RETURN_FAILURE( \ | |
| 886 isolate, NewRangeError(MessageTemplate::kInvalidSimdIndex)); \ | |
| 887 } \ | |
| 888 int32_t name = name_object->Number(); | |
| 866 | 889 |
| 867 // Common Load and Store Functions | 890 // Common Load and Store Functions |
| 868 | 891 |
| 869 #define SIMD_LOAD(type, lane_type, lane_count, count, result) \ | 892 #define SIMD_LOAD(type, lane_type, lane_count, count, result) \ |
| 870 static const int kLaneCount = lane_count; \ | 893 static const int kLaneCount = lane_count; \ |
| 871 DCHECK(args.length() == 2); \ | 894 DCHECK(args.length() == 2); \ |
| 872 CONVERT_SIMD_ARG_HANDLE_THROW(JSTypedArray, tarray, 0); \ | 895 CONVERT_SIMD_ARG_HANDLE_THROW(JSTypedArray, tarray, 0); \ |
| 873 CONVERT_INT32_ARG_CHECKED(index, 1) \ | 896 SIMD_COERCE_INDEX(index, 1); \ |
| 874 size_t bpe = tarray->element_size(); \ | 897 size_t bpe = tarray->element_size(); \ |
| 875 uint32_t bytes = count * sizeof(lane_type); \ | 898 uint32_t bytes = count * sizeof(lane_type); \ |
| 876 size_t byte_length = NumberToSize(isolate, tarray->byte_length()); \ | 899 size_t byte_length = NumberToSize(isolate, tarray->byte_length()); \ |
| 877 RUNTIME_ASSERT(index >= 0 && index * bpe + bytes <= byte_length); \ | 900 if (index < 0 || index * bpe + bytes > byte_length) { \ |
| 901 THROW_NEW_ERROR_RETURN_FAILURE( \ | |
| 902 isolate, NewRangeError(MessageTemplate::kInvalidSimdIndex)); \ | |
| 903 } \ | |
| 878 size_t tarray_offset = NumberToSize(isolate, tarray->byte_offset()); \ | 904 size_t tarray_offset = NumberToSize(isolate, tarray->byte_offset()); \ |
| 879 uint8_t* tarray_base = \ | 905 uint8_t* tarray_base = \ |
| 880 static_cast<uint8_t*>(tarray->GetBuffer()->backing_store()) + \ | 906 static_cast<uint8_t*>(tarray->GetBuffer()->backing_store()) + \ |
| 881 tarray_offset; \ | 907 tarray_offset; \ |
| 882 lane_type lanes[kLaneCount] = {0}; \ | 908 lane_type lanes[kLaneCount] = {0}; \ |
| 883 memcpy(lanes, tarray_base + index * bpe, bytes); \ | 909 memcpy(lanes, tarray_base + index * bpe, bytes); \ |
| 884 Handle<type> result = isolate->factory()->New##type(lanes); | 910 Handle<type> result = isolate->factory()->New##type(lanes); |
| 885 | 911 |
| 886 | |
| 887 #define SIMD_STORE(type, lane_type, lane_count, count, a) \ | 912 #define SIMD_STORE(type, lane_type, lane_count, count, a) \ |
| 888 static const int kLaneCount = lane_count; \ | 913 static const int kLaneCount = lane_count; \ |
| 889 DCHECK(args.length() == 3); \ | 914 DCHECK(args.length() == 3); \ |
| 890 CONVERT_SIMD_ARG_HANDLE_THROW(JSTypedArray, tarray, 0); \ | 915 CONVERT_SIMD_ARG_HANDLE_THROW(JSTypedArray, tarray, 0); \ |
| 891 CONVERT_SIMD_ARG_HANDLE_THROW(type, a, 2); \ | 916 CONVERT_SIMD_ARG_HANDLE_THROW(type, a, 2); \ |
| 892 CONVERT_INT32_ARG_CHECKED(index, 1) \ | 917 SIMD_COERCE_INDEX(index, 1); \ |
| 893 size_t bpe = tarray->element_size(); \ | 918 size_t bpe = tarray->element_size(); \ |
| 894 uint32_t bytes = count * sizeof(lane_type); \ | 919 uint32_t bytes = count * sizeof(lane_type); \ |
| 895 size_t byte_length = NumberToSize(isolate, tarray->byte_length()); \ | 920 size_t byte_length = NumberToSize(isolate, tarray->byte_length()); \ |
| 896 RUNTIME_ASSERT(index >= 0 && index * bpe + bytes <= byte_length); \ | 921 if (index < 0 || byte_length < index * bpe + bytes) { \ |
| 922 THROW_NEW_ERROR_RETURN_FAILURE( \ | |
| 923 isolate, NewRangeError(MessageTemplate::kInvalidSimdIndex)); \ | |
| 924 } \ | |
| 897 size_t tarray_offset = NumberToSize(isolate, tarray->byte_offset()); \ | 925 size_t tarray_offset = NumberToSize(isolate, tarray->byte_offset()); \ |
| 898 uint8_t* tarray_base = \ | 926 uint8_t* tarray_base = \ |
| 899 static_cast<uint8_t*>(tarray->GetBuffer()->backing_store()) + \ | 927 static_cast<uint8_t*>(tarray->GetBuffer()->backing_store()) + \ |
| 900 tarray_offset; \ | 928 tarray_offset; \ |
| 901 lane_type lanes[kLaneCount]; \ | 929 lane_type lanes[kLaneCount]; \ |
| 902 for (int i = 0; i < kLaneCount; i++) { \ | 930 for (int i = 0; i < kLaneCount; i++) { \ |
| 903 lanes[i] = a->get_lane(i); \ | 931 lanes[i] = a->get_lane(i); \ |
| 904 } \ | 932 } \ |
| 905 memcpy(tarray_base + index * bpe, lanes, bytes); | 933 memcpy(tarray_base + index * bpe, lanes, bytes); |
| 906 | 934 |
| 907 | |
| 908 #define SIMD_LOAD_FUNCTION(type, lane_type, lane_count) \ | 935 #define SIMD_LOAD_FUNCTION(type, lane_type, lane_count) \ |
| 909 RUNTIME_FUNCTION(Runtime_##type##Load) { \ | 936 RUNTIME_FUNCTION(Runtime_##type##Load) { \ |
| 910 HandleScope scope(isolate); \ | 937 HandleScope scope(isolate); \ |
| 911 SIMD_LOAD(type, lane_type, lane_count, lane_count, result); \ | 938 SIMD_LOAD(type, lane_type, lane_count, lane_count, result); \ |
| 912 return *result; \ | 939 return *result; \ |
| 913 } | 940 } |
| 914 | 941 |
| 915 | 942 |
| 916 #define SIMD_LOAD1_FUNCTION(type, lane_type, lane_count) \ | 943 #define SIMD_LOAD1_FUNCTION(type, lane_type, lane_count) \ |
| 917 RUNTIME_FUNCTION(Runtime_##type##Load1) { \ | 944 RUNTIME_FUNCTION(Runtime_##type##Load1) { \ |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 975 SIMD_LOADN_STOREN_TYPES(SIMD_LOAD3_FUNCTION) | 1002 SIMD_LOADN_STOREN_TYPES(SIMD_LOAD3_FUNCTION) |
| 976 SIMD_NUMERIC_TYPES(SIMD_STORE_FUNCTION) | 1003 SIMD_NUMERIC_TYPES(SIMD_STORE_FUNCTION) |
| 977 SIMD_LOADN_STOREN_TYPES(SIMD_STORE1_FUNCTION) | 1004 SIMD_LOADN_STOREN_TYPES(SIMD_STORE1_FUNCTION) |
| 978 SIMD_LOADN_STOREN_TYPES(SIMD_STORE2_FUNCTION) | 1005 SIMD_LOADN_STOREN_TYPES(SIMD_STORE2_FUNCTION) |
| 979 SIMD_LOADN_STOREN_TYPES(SIMD_STORE3_FUNCTION) | 1006 SIMD_LOADN_STOREN_TYPES(SIMD_STORE3_FUNCTION) |
| 980 | 1007 |
| 981 //------------------------------------------------------------------- | 1008 //------------------------------------------------------------------- |
| 982 | 1009 |
| 983 } // namespace internal | 1010 } // namespace internal |
| 984 } // namespace v8 | 1011 } // namespace v8 |
| OLD | NEW |