| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. Use of this | 1 // Copyright 2014 the V8 project authors. All rights reserved. Use of this |
| 2 // source code is governed by a BSD-style license that can be found in the | 2 // source code is governed by a BSD-style license that can be found in the |
| 3 // LICENSE file. | 3 // 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/base/utils/random-number-generator.h" | 10 #include "src/base/utils/random-number-generator.h" |
| (...skipping 4106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4117 | 4117 |
| 4118 | 4118 |
| 4119 TEST(RunChangeUint32ToFloat64) { | 4119 TEST(RunChangeUint32ToFloat64) { |
| 4120 BufferedRawMachineAssemblerTester<double> m(MachineType::Uint32()); | 4120 BufferedRawMachineAssemblerTester<double> m(MachineType::Uint32()); |
| 4121 m.Return(m.ChangeUint32ToFloat64(m.Parameter(0))); | 4121 m.Return(m.ChangeUint32ToFloat64(m.Parameter(0))); |
| 4122 | 4122 |
| 4123 FOR_UINT32_INPUTS(i) { CheckDoubleEq(static_cast<double>(*i), m.Call(*i)); } | 4123 FOR_UINT32_INPUTS(i) { CheckDoubleEq(static_cast<double>(*i), m.Call(*i)); } |
| 4124 } | 4124 } |
| 4125 | 4125 |
| 4126 | 4126 |
| 4127 TEST(RunTruncateFloat32ToInt32) { |
| 4128 BufferedRawMachineAssemblerTester<int32_t> m(MachineType::Float32()); |
| 4129 m.Return(m.TruncateFloat32ToInt32(m.Parameter(0))); |
| 4130 FOR_FLOAT32_INPUTS(i) { |
| 4131 if (*i <= static_cast<float>(std::numeric_limits<int32_t>::max()) && |
| 4132 *i >= static_cast<float>(std::numeric_limits<int32_t>::min())) { |
| 4133 CheckFloatEq(static_cast<int32_t>(*i), m.Call(*i)); |
| 4134 } |
| 4135 } |
| 4136 } |
| 4137 |
| 4138 |
| 4127 TEST(RunChangeFloat64ToInt32_A) { | 4139 TEST(RunChangeFloat64ToInt32_A) { |
| 4128 BufferedRawMachineAssemblerTester<int32_t> m; | 4140 BufferedRawMachineAssemblerTester<int32_t> m; |
| 4129 double magic = 11.1; | 4141 double magic = 11.1; |
| 4130 m.Return(m.ChangeFloat64ToInt32(m.Float64Constant(magic))); | 4142 m.Return(m.ChangeFloat64ToInt32(m.Float64Constant(magic))); |
| 4131 CHECK_EQ(static_cast<int32_t>(magic), m.Call()); | 4143 CHECK_EQ(static_cast<int32_t>(magic), m.Call()); |
| 4132 } | 4144 } |
| 4133 | 4145 |
| 4134 | 4146 |
| 4135 TEST(RunChangeFloat64ToInt32_B) { | 4147 TEST(RunChangeFloat64ToInt32_B) { |
| 4136 BufferedRawMachineAssemblerTester<int32_t> m(MachineType::Float64()); | 4148 BufferedRawMachineAssemblerTester<int32_t> m(MachineType::Float64()); |
| (...skipping 1927 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6064 Node* call = r.AddNode(r.common()->Call(desc), phi); | 6076 Node* call = r.AddNode(r.common()->Call(desc), phi); |
| 6065 r.Return(call); | 6077 r.Return(call); |
| 6066 | 6078 |
| 6067 CHECK_EQ(33, r.Call(1)); | 6079 CHECK_EQ(33, r.Call(1)); |
| 6068 CHECK_EQ(44, r.Call(0)); | 6080 CHECK_EQ(44, r.Call(0)); |
| 6069 } | 6081 } |
| 6070 | 6082 |
| 6071 } // namespace compiler | 6083 } // namespace compiler |
| 6072 } // namespace internal | 6084 } // namespace internal |
| 6073 } // namespace v8 | 6085 } // namespace v8 |
| OLD | NEW |