OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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 <cmath> | 5 #include <cmath> |
6 #include <functional> | 6 #include <functional> |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
(...skipping 4629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4640 float actual = *i; | 4640 float actual = *i; |
4641 RawMachineAssemblerTester<int32_t> m; | 4641 RawMachineAssemblerTester<int32_t> m; |
4642 m.StoreToPointer(&actual, kMachFloat32, m.Float32Constant(expected)); | 4642 m.StoreToPointer(&actual, kMachFloat32, m.Float32Constant(expected)); |
4643 m.Return(m.Int32Constant(0)); | 4643 m.Return(m.Int32Constant(0)); |
4644 CHECK_EQ(0, m.Call()); | 4644 CHECK_EQ(0, m.Call()); |
4645 CHECK_EQ(expected, actual); | 4645 CHECK_EQ(expected, actual); |
4646 } | 4646 } |
4647 } | 4647 } |
4648 | 4648 |
4649 | 4649 |
| 4650 TEST(RunFloat64ExtractWord32) { |
| 4651 uint64_t input = 0; |
| 4652 for (int location = 0; location < 2; ++location) { |
| 4653 RawMachineAssemblerTester<int32_t> m; |
| 4654 m.Return(m.Float64ExtractWord32(location, |
| 4655 m.LoadFromPointer(&input, kMachFloat64))); |
| 4656 FOR_FLOAT64_INPUTS(i) { |
| 4657 input = bit_cast<uint64_t>(*i); |
| 4658 int32_t expected = |
| 4659 bit_cast<int32_t>(static_cast<uint32_t>(input >> (location * 32))); |
| 4660 CHECK_EQ(expected, m.Call()); |
| 4661 } |
| 4662 } |
| 4663 } |
| 4664 |
| 4665 |
| 4666 TEST(RunFloat64InsertWord32) { |
| 4667 uint64_t input = 0; |
| 4668 uint64_t result = 0; |
| 4669 for (int location = 0; location < 2; ++location) { |
| 4670 RawMachineAssemblerTester<int32_t> m(kMachInt32); |
| 4671 m.StoreToPointer( |
| 4672 &result, kMachFloat64, |
| 4673 m.Float64InsertWord32(location, m.LoadFromPointer(&input, kMachFloat64), |
| 4674 m.Parameter(0))); |
| 4675 m.Return(m.Int32Constant(0)); |
| 4676 FOR_FLOAT64_INPUTS(i) { |
| 4677 FOR_INT32_INPUTS(j) { |
| 4678 input = bit_cast<uint64_t>(*i); |
| 4679 uint64_t expected = |
| 4680 (input & ~(V8_UINT64_C(0xFFFFFFFF) << (location * 32))) | |
| 4681 (static_cast<uint64_t>(bit_cast<uint32_t>(*j)) << (location * 32)); |
| 4682 CHECK_EQ(0, m.Call(*j)); |
| 4683 CHECK_EQ(expected, result); |
| 4684 } |
| 4685 } |
| 4686 } |
| 4687 } |
| 4688 |
| 4689 |
4650 static double two_30 = 1 << 30; // 2^30 is a smi boundary. | 4690 static double two_30 = 1 << 30; // 2^30 is a smi boundary. |
4651 static double two_52 = two_30 * (1 << 22); // 2^52 is a precision boundary. | 4691 static double two_52 = two_30 * (1 << 22); // 2^52 is a precision boundary. |
4652 static double kValues[] = {0.1, | 4692 static double kValues[] = {0.1, |
4653 0.2, | 4693 0.2, |
4654 0.49999999999999994, | 4694 0.49999999999999994, |
4655 0.5, | 4695 0.5, |
4656 0.7, | 4696 0.7, |
4657 1.0 - std::numeric_limits<double>::epsilon(), | 4697 1.0 - std::numeric_limits<double>::epsilon(), |
4658 -0.1, | 4698 -0.1, |
4659 -0.49999999999999994, | 4699 -0.49999999999999994, |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4808 m.Return(m.Int32Constant(0)); | 4848 m.Return(m.Int32Constant(0)); |
4809 for (size_t i = 0; i < arraysize(kValues); ++i) { | 4849 for (size_t i = 0; i < arraysize(kValues); ++i) { |
4810 input = kValues[i]; | 4850 input = kValues[i]; |
4811 CHECK_EQ(0, m.Call()); | 4851 CHECK_EQ(0, m.Call()); |
4812 double expected = round(kValues[i]); | 4852 double expected = round(kValues[i]); |
4813 CHECK_EQ(expected, result); | 4853 CHECK_EQ(expected, result); |
4814 } | 4854 } |
4815 } | 4855 } |
4816 | 4856 |
4817 #endif // V8_TURBOFAN_TARGET | 4857 #endif // V8_TURBOFAN_TARGET |
OLD | NEW |