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/ieee754.h" | 10 #include "src/base/ieee754.h" |
(...skipping 5528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5539 CHECK(std::isnan(m.Call(std::numeric_limits<double>::signaling_NaN()))); | 5539 CHECK(std::isnan(m.Call(std::numeric_limits<double>::signaling_NaN()))); |
5540 CHECK(std::isnan(m.Call(-std::numeric_limits<double>::infinity()))); | 5540 CHECK(std::isnan(m.Call(-std::numeric_limits<double>::infinity()))); |
5541 CHECK_DOUBLE_EQ(-std::numeric_limits<double>::infinity(), m.Call(-1.0)); | 5541 CHECK_DOUBLE_EQ(-std::numeric_limits<double>::infinity(), m.Call(-1.0)); |
5542 CHECK_DOUBLE_EQ(0.0, m.Call(0.0)); | 5542 CHECK_DOUBLE_EQ(0.0, m.Call(0.0)); |
5543 CHECK_DOUBLE_EQ(-0.0, m.Call(-0.0)); | 5543 CHECK_DOUBLE_EQ(-0.0, m.Call(-0.0)); |
5544 CHECK_DOUBLE_EQ(std::numeric_limits<double>::infinity(), | 5544 CHECK_DOUBLE_EQ(std::numeric_limits<double>::infinity(), |
5545 m.Call(std::numeric_limits<double>::infinity())); | 5545 m.Call(std::numeric_limits<double>::infinity())); |
5546 FOR_FLOAT64_INPUTS(i) { CHECK_DOUBLE_EQ(ieee754::log1p(*i), m.Call(*i)); } | 5546 FOR_FLOAT64_INPUTS(i) { CHECK_DOUBLE_EQ(ieee754::log1p(*i), m.Call(*i)); } |
5547 } | 5547 } |
5548 | 5548 |
| 5549 TEST(RunFloat64Log2) { |
| 5550 BufferedRawMachineAssemblerTester<double> m(MachineType::Float64()); |
| 5551 m.Return(m.Float64Log2(m.Parameter(0))); |
| 5552 CHECK(std::isnan(m.Call(std::numeric_limits<double>::quiet_NaN()))); |
| 5553 CHECK(std::isnan(m.Call(std::numeric_limits<double>::signaling_NaN()))); |
| 5554 CHECK(std::isnan(m.Call(-std::numeric_limits<double>::infinity()))); |
| 5555 CHECK(std::isnan(m.Call(-1.0))); |
| 5556 CHECK_DOUBLE_EQ(-std::numeric_limits<double>::infinity(), m.Call(-0.0)); |
| 5557 CHECK_DOUBLE_EQ(-std::numeric_limits<double>::infinity(), m.Call(0.0)); |
| 5558 CHECK_DOUBLE_EQ(0.0, m.Call(1.0)); |
| 5559 CHECK_DOUBLE_EQ(std::numeric_limits<double>::infinity(), |
| 5560 m.Call(std::numeric_limits<double>::infinity())); |
| 5561 FOR_FLOAT64_INPUTS(i) { CHECK_DOUBLE_EQ(ieee754::log2(*i), m.Call(*i)); } |
| 5562 } |
| 5563 |
| 5564 TEST(RunFloat64Log10) { |
| 5565 BufferedRawMachineAssemblerTester<double> m(MachineType::Float64()); |
| 5566 m.Return(m.Float64Log10(m.Parameter(0))); |
| 5567 CHECK(std::isnan(m.Call(std::numeric_limits<double>::quiet_NaN()))); |
| 5568 CHECK(std::isnan(m.Call(std::numeric_limits<double>::signaling_NaN()))); |
| 5569 CHECK(std::isnan(m.Call(-std::numeric_limits<double>::infinity()))); |
| 5570 CHECK(std::isnan(m.Call(-1.0))); |
| 5571 CHECK_DOUBLE_EQ(-std::numeric_limits<double>::infinity(), m.Call(-0.0)); |
| 5572 CHECK_DOUBLE_EQ(-std::numeric_limits<double>::infinity(), m.Call(0.0)); |
| 5573 CHECK_DOUBLE_EQ(std::numeric_limits<double>::infinity(), |
| 5574 m.Call(std::numeric_limits<double>::infinity())); |
| 5575 FOR_FLOAT64_INPUTS(i) { CHECK_DOUBLE_EQ(ieee754::log10(*i), m.Call(*i)); } |
| 5576 } |
| 5577 |
5549 static double two_30 = 1 << 30; // 2^30 is a smi boundary. | 5578 static double two_30 = 1 << 30; // 2^30 is a smi boundary. |
5550 static double two_52 = two_30 * (1 << 22); // 2^52 is a precision boundary. | 5579 static double two_52 = two_30 * (1 << 22); // 2^52 is a precision boundary. |
5551 static double kValues[] = {0.1, | 5580 static double kValues[] = {0.1, |
5552 0.2, | 5581 0.2, |
5553 0.49999999999999994, | 5582 0.49999999999999994, |
5554 0.5, | 5583 0.5, |
5555 0.7, | 5584 0.7, |
5556 1.0 - std::numeric_limits<double>::epsilon(), | 5585 1.0 - std::numeric_limits<double>::epsilon(), |
5557 -0.1, | 5586 -0.1, |
5558 -0.49999999999999994, | 5587 -0.49999999999999994, |
(...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6308 r.Goto(&merge); | 6337 r.Goto(&merge); |
6309 r.Bind(&merge); | 6338 r.Bind(&merge); |
6310 Node* phi = r.Phi(MachineRepresentation::kWord32, fa, fb); | 6339 Node* phi = r.Phi(MachineRepresentation::kWord32, fa, fb); |
6311 r.Return(phi); | 6340 r.Return(phi); |
6312 CHECK_EQ(1, r.Call(1)); | 6341 CHECK_EQ(1, r.Call(1)); |
6313 } | 6342 } |
6314 | 6343 |
6315 } // namespace compiler | 6344 } // namespace compiler |
6316 } // namespace internal | 6345 } // namespace internal |
6317 } // namespace v8 | 6346 } // namespace v8 |
OLD | NEW |