| 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 // TODO(jochen): Remove this after the setting is turned on globally. | 5 // TODO(jochen): Remove this after the setting is turned on globally. |
| 6 #define V8_IMMINENT_DEPRECATION_WARNINGS | 6 #define V8_IMMINENT_DEPRECATION_WARNINGS |
| 7 | 7 |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 #include <functional> | 9 #include <functional> |
| 10 #include <limits> | 10 #include <limits> |
| (...skipping 5142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5153 FOR_FLOAT32_INPUTS(i) { CheckFloatEq(floorf(*i), m.Call(*i)); } | 5153 FOR_FLOAT32_INPUTS(i) { CheckFloatEq(floorf(*i), m.Call(*i)); } |
| 5154 } | 5154 } |
| 5155 | 5155 |
| 5156 | 5156 |
| 5157 TEST(RunFloat64RoundDown1) { | 5157 TEST(RunFloat64RoundDown1) { |
| 5158 BufferedRawMachineAssemblerTester<double> m(kMachFloat64); | 5158 BufferedRawMachineAssemblerTester<double> m(kMachFloat64); |
| 5159 if (!m.machine()->Float64RoundDown().IsSupported()) return; | 5159 if (!m.machine()->Float64RoundDown().IsSupported()) return; |
| 5160 | 5160 |
| 5161 m.Return(m.Float64RoundDown(m.Parameter(0))); | 5161 m.Return(m.Float64RoundDown(m.Parameter(0))); |
| 5162 | 5162 |
| 5163 FOR_FLOAT64_INPUTS(i) { CheckDoubleEq(std::floor(*i), m.Call(*i)); } | 5163 FOR_FLOAT64_INPUTS(i) { CheckDoubleEq(floor(*i), m.Call(*i)); } |
| 5164 } | 5164 } |
| 5165 | 5165 |
| 5166 | 5166 |
| 5167 TEST(RunFloat64RoundDown2) { | 5167 TEST(RunFloat64RoundDown2) { |
| 5168 BufferedRawMachineAssemblerTester<double> m(kMachFloat64); | 5168 BufferedRawMachineAssemblerTester<double> m(kMachFloat64); |
| 5169 if (!m.machine()->Float64RoundDown().IsSupported()) return; | 5169 if (!m.machine()->Float64RoundDown().IsSupported()) return; |
| 5170 m.Return(m.Float64Sub(m.Float64Constant(-0.0), | 5170 m.Return(m.Float64Sub(m.Float64Constant(-0.0), |
| 5171 m.Float64RoundDown(m.Float64Sub(m.Float64Constant(-0.0), | 5171 m.Float64RoundDown(m.Float64Sub(m.Float64Constant(-0.0), |
| 5172 m.Parameter(0))))); | 5172 m.Parameter(0))))); |
| 5173 | 5173 |
| 5174 for (size_t i = 0; i < arraysize(kValues); ++i) { | 5174 for (size_t i = 0; i < arraysize(kValues); ++i) { |
| 5175 CHECK_EQ(std::ceil(kValues[i]), m.Call(kValues[i])); | 5175 CHECK_EQ(ceil(kValues[i]), m.Call(kValues[i])); |
| 5176 } | 5176 } |
| 5177 } | 5177 } |
| 5178 | 5178 |
| 5179 | 5179 |
| 5180 TEST(RunFloat32RoundUp) { | 5180 TEST(RunFloat32RoundUp) { |
| 5181 BufferedRawMachineAssemblerTester<float> m(kMachFloat32); | 5181 BufferedRawMachineAssemblerTester<float> m(kMachFloat32); |
| 5182 if (!m.machine()->Float32RoundUp().IsSupported()) return; | 5182 if (!m.machine()->Float32RoundUp().IsSupported()) return; |
| 5183 m.Return(m.Float32RoundUp(m.Parameter(0))); | 5183 m.Return(m.Float32RoundUp(m.Parameter(0))); |
| 5184 | 5184 |
| 5185 FOR_FLOAT32_INPUTS(i) { CheckFloatEq(std::ceil(*i), m.Call(*i)); } | 5185 FOR_FLOAT32_INPUTS(i) { CheckFloatEq(ceilf(*i), m.Call(*i)); } |
| 5186 } | 5186 } |
| 5187 | 5187 |
| 5188 | 5188 |
| 5189 TEST(RunFloat64RoundUp) { | 5189 TEST(RunFloat64RoundUp) { |
| 5190 BufferedRawMachineAssemblerTester<double> m(kMachFloat64); | 5190 BufferedRawMachineAssemblerTester<double> m(kMachFloat64); |
| 5191 if (!m.machine()->Float64RoundUp().IsSupported()) return; | 5191 if (!m.machine()->Float64RoundUp().IsSupported()) return; |
| 5192 m.Return(m.Float64RoundUp(m.Parameter(0))); | 5192 m.Return(m.Float64RoundUp(m.Parameter(0))); |
| 5193 | 5193 |
| 5194 FOR_FLOAT64_INPUTS(i) { CheckDoubleEq(std::ceil(*i), m.Call(*i)); } | 5194 FOR_FLOAT64_INPUTS(i) { CheckDoubleEq(ceil(*i), m.Call(*i)); } |
| 5195 } | 5195 } |
| 5196 | 5196 |
| 5197 | 5197 |
| 5198 TEST(RunFloat64RoundTiesEven) { | 5198 TEST(RunFloat64RoundTiesEven) { |
| 5199 BufferedRawMachineAssemblerTester<double> m(kMachFloat64); | 5199 BufferedRawMachineAssemblerTester<double> m(kMachFloat64); |
| 5200 if (!m.machine()->Float64RoundTiesEven().IsSupported()) return; | 5200 if (!m.machine()->Float64RoundTiesEven().IsSupported()) return; |
| 5201 m.Return(m.Float64RoundTiesEven(m.Parameter(0))); | 5201 m.Return(m.Float64RoundTiesEven(m.Parameter(0))); |
| 5202 | 5202 |
| 5203 FOR_FLOAT64_INPUTS(i) { CheckDoubleEq(nearbyint(*i), m.Call(*i)); } | 5203 FOR_FLOAT64_INPUTS(i) { CheckDoubleEq(nearbyint(*i), m.Call(*i)); } |
| 5204 } | 5204 } |
| 5205 | 5205 |
| 5206 | 5206 |
| 5207 TEST(RunFloat32RoundTruncate) { |
| 5208 BufferedRawMachineAssemblerTester<float> m(kMachFloat32); |
| 5209 if (!m.machine()->Float32RoundTruncate().IsSupported()) return; |
| 5210 |
| 5211 m.Return(m.Float32RoundTruncate(m.Parameter(0))); |
| 5212 |
| 5213 FOR_FLOAT32_INPUTS(i) { CheckFloatEq(truncf(*i), m.Call(*i)); } |
| 5214 } |
| 5215 |
| 5216 |
| 5207 TEST(RunFloat64RoundTruncate) { | 5217 TEST(RunFloat64RoundTruncate) { |
| 5208 BufferedRawMachineAssemblerTester<double> m(kMachFloat64); | 5218 BufferedRawMachineAssemblerTester<double> m(kMachFloat64); |
| 5209 if (!m.machine()->Float64RoundTruncate().IsSupported()) return; | 5219 if (!m.machine()->Float64RoundTruncate().IsSupported()) return; |
| 5210 m.Return(m.Float64RoundTruncate(m.Parameter(0))); | 5220 m.Return(m.Float64RoundTruncate(m.Parameter(0))); |
| 5211 for (size_t i = 0; i < arraysize(kValues); ++i) { | 5221 for (size_t i = 0; i < arraysize(kValues); ++i) { |
| 5212 CHECK_EQ(trunc(kValues[i]), m.Call(kValues[i])); | 5222 CHECK_EQ(trunc(kValues[i]), m.Call(kValues[i])); |
| 5213 } | 5223 } |
| 5214 } | 5224 } |
| 5215 | 5225 |
| 5216 | 5226 |
| (...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5674 Node* call = r.AddNode(r.common()->Call(desc), phi); | 5684 Node* call = r.AddNode(r.common()->Call(desc), phi); |
| 5675 r.Return(call); | 5685 r.Return(call); |
| 5676 | 5686 |
| 5677 CHECK_EQ(33, r.Call(1)); | 5687 CHECK_EQ(33, r.Call(1)); |
| 5678 CHECK_EQ(44, r.Call(0)); | 5688 CHECK_EQ(44, r.Call(0)); |
| 5679 } | 5689 } |
| 5680 | 5690 |
| 5681 } // namespace compiler | 5691 } // namespace compiler |
| 5682 } // namespace internal | 5692 } // namespace internal |
| 5683 } // namespace v8 | 5693 } // namespace v8 |
| OLD | NEW |