Chromium Code Reviews| Index: src/runtime/runtime-simd.cc |
| diff --git a/src/runtime/runtime-simd.cc b/src/runtime/runtime-simd.cc |
| index bed866facfe324a68e82acd3366ae960c95ccd78..fa067bf58c858f7853763effc913d010805a58b2 100644 |
| --- a/src/runtime/runtime-simd.cc |
| +++ b/src/runtime/runtime-simd.cc |
| @@ -6,6 +6,7 @@ |
| #include "src/arguments.h" |
| #include "src/base/macros.h" |
| +#include "src/base/safe_math.h" |
| #include "src/conversions.h" |
| #include "src/factory.h" |
| #include "src/objects-inl.h" |
| @@ -457,39 +458,34 @@ SIMD_MAXNUM_FUNCTION(Float32x4, float, 4) |
| return *result; \ |
| } |
| -#define SIMD_LSR_FUNCTION(type, lane_type, lane_bits, lane_count) \ |
| - RUNTIME_FUNCTION(Runtime_##type##ShiftRightLogicalByScalar) { \ |
| - static const int kLaneCount = lane_count; \ |
| - HandleScope scope(isolate); \ |
| - DCHECK(args.length() == 2); \ |
| - CONVERT_ARG_HANDLE_CHECKED(type, a, 0); \ |
| - CONVERT_SHIFT_ARG_CHECKED(shift, 1); \ |
| - lane_type lanes[kLaneCount] = {0}; \ |
| - if (shift < lane_bits) { \ |
| - for (int i = 0; i < kLaneCount; i++) { \ |
| - lanes[i] = static_cast<lane_type>( \ |
| - bit_cast<lane_type>(a->get_lane(i)) >> shift); \ |
| - } \ |
| - } \ |
| - Handle<type> result = isolate->factory()->New##type(lanes); \ |
| - return *result; \ |
| - } |
| - |
| -#define SIMD_ASR_FUNCTION(type, lane_type, lane_bits, lane_count) \ |
| - RUNTIME_FUNCTION(Runtime_##type##ShiftRightArithmeticByScalar) { \ |
| - static const int kLaneCount = lane_count; \ |
| - HandleScope scope(isolate); \ |
| - DCHECK(args.length() == 2); \ |
| - CONVERT_ARG_HANDLE_CHECKED(type, a, 0); \ |
| - CONVERT_SHIFT_ARG_CHECKED(shift, 1); \ |
| - if (shift >= lane_bits) shift = lane_bits - 1; \ |
| - lane_type lanes[kLaneCount]; \ |
| - for (int i = 0; i < kLaneCount; i++) { \ |
| - int64_t shifted = static_cast<int64_t>(a->get_lane(i)) >> shift; \ |
| - lanes[i] = static_cast<lane_type>(shifted); \ |
| - } \ |
| - Handle<type> result = isolate->factory()->New##type(lanes); \ |
| - return *result; \ |
| +#define SIMD_LSR_FUNCTION(type, lane_type, lane_bits, lane_count) \ |
|
bbudge
2015/09/16 20:25:36
It's a little misleading to have the logical and a
gdeepti1
2015/09/16 20:42:08
Done.
|
| + RUNTIME_FUNCTION(Runtime_##type##ShiftRightByScalar) { \ |
| + static const int kLaneCount = lane_count; \ |
| + HandleScope scope(isolate); \ |
| + DCHECK(args.length() == 2); \ |
| + CONVERT_ARG_HANDLE_CHECKED(type, a, 0); \ |
| + CONVERT_SHIFT_ARG_CHECKED(shift, 1); \ |
| + lane_type lanes[kLaneCount] = {0}; \ |
| + if (base::internal::is_same<lane_type, uint32_t>::value || \ |
| + base::internal::is_same<lane_type, uint16_t>::value || \ |
| + base::internal::is_same<lane_type, uint8_t>::value) { \ |
| + if (shift < lane_bits) { \ |
| + for (int i = 0; i < kLaneCount; i++) { \ |
| + lanes[i] = static_cast<lane_type>( \ |
| + bit_cast<lane_type>(a->get_lane(i)) >> shift); \ |
| + } \ |
| + } \ |
| + Handle<type> result = isolate->factory()->New##type(lanes); \ |
| + return *result; \ |
| + } else { \ |
| + if (shift >= lane_bits) shift = lane_bits - 1; \ |
| + for (int i = 0; i < kLaneCount; i++) { \ |
| + int64_t shifted = static_cast<int64_t>(a->get_lane(i)) >> shift; \ |
| + lanes[i] = static_cast<lane_type>(shifted); \ |
| + } \ |
| + Handle<type> result = isolate->factory()->New##type(lanes); \ |
| + return *result; \ |
| + } \ |
| } |
| #define SIMD_HORIZONTAL_SUM_FUNCTION(type, lane_type, lane_bits, lane_count) \ |
| @@ -506,7 +502,7 @@ SIMD_MAXNUM_FUNCTION(Float32x4, float, 4) |
| SIMD_INT_TYPES(SIMD_LSL_FUNCTION) |
| SIMD_UINT_TYPES(SIMD_LSL_FUNCTION) |
| -SIMD_INT_TYPES(SIMD_ASR_FUNCTION) |
| +SIMD_INT_TYPES(SIMD_LSR_FUNCTION) |
| SIMD_UINT_TYPES(SIMD_LSR_FUNCTION) |
| SIMD_UINT_TYPES(SIMD_HORIZONTAL_SUM_FUNCTION) |