| 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" |
| 11 #include "src/objects-inl.h" | 11 #include "src/objects-inl.h" |
| 12 | 12 |
| 13 // Implement Single Instruction Multiple Data (SIMD) operations as defined in | 13 // Implement Single Instruction Multiple Data (SIMD) operations as defined in |
| 14 // the SIMD.js draft spec: | 14 // the SIMD.js draft spec: |
| 15 // http://littledan.github.io/simd.html | 15 // http://littledan.github.io/simd.html |
| 16 | 16 |
| 17 namespace v8 { | 17 namespace v8 { |
| 18 namespace internal { | 18 namespace internal { |
| 19 | 19 |
| 20 namespace { | 20 namespace { |
| 21 | 21 |
| 22 // Functions to convert Numbers to SIMD component types. | 22 // Functions to convert Numbers to SIMD component types. |
| 23 | 23 |
| 24 template <typename T, typename F> | 24 template <typename T, typename F> |
| 25 static bool CanCast(F from) { | 25 static bool CanCast(F from) { |
| 26 // A float can't represent 2^31 - 1 or 2^32 - 1 exactly, so promote the limits | 26 // A float can't represent 2^31 - 1 or 2^32 - 1 exactly, so promote the limits |
| 27 // to double. Otherwise, the limit is truncated and numbers like 2^31 or 2^32 | 27 // to double. Otherwise, the limit is truncated and numbers like 2^31 or 2^32 |
| 28 // get through, causing any static_cast to be undefined. | 28 // get through, causing any static_cast to be undefined. |
| 29 from = std::trunc(from); | 29 from = trunc(from); |
| 30 return from >= static_cast<double>(std::numeric_limits<T>::min()) && | 30 return from >= static_cast<double>(std::numeric_limits<T>::min()) && |
| 31 from <= static_cast<double>(std::numeric_limits<T>::max()); | 31 from <= static_cast<double>(std::numeric_limits<T>::max()); |
| 32 } | 32 } |
| 33 | 33 |
| 34 | 34 |
| 35 // Explicitly specialize for conversions to float, which always succeed. | 35 // Explicitly specialize for conversions to float, which always succeed. |
| 36 template <> | 36 template <> |
| 37 bool CanCast<float>(int32_t from) { | 37 bool CanCast<float>(int32_t from) { |
| 38 return true; | 38 return true; |
| 39 } | 39 } |
| (...skipping 967 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1007 SIMD_LOADN_STOREN_TYPES(SIMD_LOAD3_FUNCTION) | 1007 SIMD_LOADN_STOREN_TYPES(SIMD_LOAD3_FUNCTION) |
| 1008 SIMD_NUMERIC_TYPES(SIMD_STORE_FUNCTION) | 1008 SIMD_NUMERIC_TYPES(SIMD_STORE_FUNCTION) |
| 1009 SIMD_LOADN_STOREN_TYPES(SIMD_STORE1_FUNCTION) | 1009 SIMD_LOADN_STOREN_TYPES(SIMD_STORE1_FUNCTION) |
| 1010 SIMD_LOADN_STOREN_TYPES(SIMD_STORE2_FUNCTION) | 1010 SIMD_LOADN_STOREN_TYPES(SIMD_STORE2_FUNCTION) |
| 1011 SIMD_LOADN_STOREN_TYPES(SIMD_STORE3_FUNCTION) | 1011 SIMD_LOADN_STOREN_TYPES(SIMD_STORE3_FUNCTION) |
| 1012 | 1012 |
| 1013 //------------------------------------------------------------------- | 1013 //------------------------------------------------------------------- |
| 1014 | 1014 |
| 1015 } // namespace internal | 1015 } // namespace internal |
| 1016 } // namespace v8 | 1016 } // namespace v8 |
| OLD | NEW |