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 5499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5510 BufferedRawMachineAssemblerTester<double> m(MachineType::Float64(), | 5510 BufferedRawMachineAssemblerTester<double> m(MachineType::Float64(), |
5511 MachineType::Float64()); | 5511 MachineType::Float64()); |
5512 m.Return(m.Float64Atan2(m.Parameter(0), m.Parameter(1))); | 5512 m.Return(m.Float64Atan2(m.Parameter(0), m.Parameter(1))); |
5513 FOR_FLOAT64_INPUTS(i) { | 5513 FOR_FLOAT64_INPUTS(i) { |
5514 FOR_FLOAT64_INPUTS(j) { | 5514 FOR_FLOAT64_INPUTS(j) { |
5515 CHECK_DOUBLE_EQ(ieee754::atan2(*i, *j), m.Call(*i, *j)); | 5515 CHECK_DOUBLE_EQ(ieee754::atan2(*i, *j), m.Call(*i, *j)); |
5516 } | 5516 } |
5517 } | 5517 } |
5518 } | 5518 } |
5519 | 5519 |
| 5520 TEST(RunFloat64Atanh) { |
| 5521 BufferedRawMachineAssemblerTester<double> m(MachineType::Float64()); |
| 5522 m.Return(m.Float64Atanh(m.Parameter(0))); |
| 5523 CHECK(std::isnan(m.Call(std::numeric_limits<double>::quiet_NaN()))); |
| 5524 CHECK(std::isnan(m.Call(std::numeric_limits<double>::signaling_NaN()))); |
| 5525 CHECK_DOUBLE_EQ(std::numeric_limits<double>::infinity(), m.Call(1.0)); |
| 5526 CHECK_DOUBLE_EQ(-std::numeric_limits<double>::infinity(), m.Call(-1.0)); |
| 5527 CHECK_DOUBLE_EQ(-0.0, m.Call(-0.0)); |
| 5528 CHECK_DOUBLE_EQ(0.0, m.Call(0.0)); |
| 5529 FOR_FLOAT64_INPUTS(i) { CHECK_DOUBLE_EQ(ieee754::atanh(*i), m.Call(*i)); } |
| 5530 } |
| 5531 |
5520 TEST(RunFloat64Exp) { | 5532 TEST(RunFloat64Exp) { |
5521 BufferedRawMachineAssemblerTester<double> m(MachineType::Float64()); | 5533 BufferedRawMachineAssemblerTester<double> m(MachineType::Float64()); |
5522 m.Return(m.Float64Exp(m.Parameter(0))); | 5534 m.Return(m.Float64Exp(m.Parameter(0))); |
5523 CHECK(std::isnan(m.Call(std::numeric_limits<double>::quiet_NaN()))); | 5535 CHECK(std::isnan(m.Call(std::numeric_limits<double>::quiet_NaN()))); |
5524 CHECK(std::isnan(m.Call(std::numeric_limits<double>::signaling_NaN()))); | 5536 CHECK(std::isnan(m.Call(std::numeric_limits<double>::signaling_NaN()))); |
5525 CHECK_EQ(0.0, m.Call(-std::numeric_limits<double>::infinity())); | 5537 CHECK_EQ(0.0, m.Call(-std::numeric_limits<double>::infinity())); |
5526 CHECK_DOUBLE_EQ(1.0, m.Call(-0.0)); | 5538 CHECK_DOUBLE_EQ(1.0, m.Call(-0.0)); |
5527 CHECK_DOUBLE_EQ(1.0, m.Call(0.0)); | 5539 CHECK_DOUBLE_EQ(1.0, m.Call(0.0)); |
5528 CHECK_DOUBLE_EQ(std::numeric_limits<double>::infinity(), | 5540 CHECK_DOUBLE_EQ(std::numeric_limits<double>::infinity(), |
5529 m.Call(std::numeric_limits<double>::infinity())); | 5541 m.Call(std::numeric_limits<double>::infinity())); |
5530 FOR_FLOAT64_INPUTS(i) { CHECK_DOUBLE_EQ(ieee754::exp(*i), m.Call(*i)); } | 5542 FOR_FLOAT64_INPUTS(i) { CHECK_DOUBLE_EQ(ieee754::exp(*i), m.Call(*i)); } |
5531 } | 5543 } |
5532 | 5544 |
| 5545 TEST(RunFloat64Expm1) { |
| 5546 BufferedRawMachineAssemblerTester<double> m(MachineType::Float64()); |
| 5547 m.Return(m.Float64Expm1(m.Parameter(0))); |
| 5548 CHECK(std::isnan(m.Call(std::numeric_limits<double>::quiet_NaN()))); |
| 5549 CHECK(std::isnan(m.Call(std::numeric_limits<double>::signaling_NaN()))); |
| 5550 CHECK_EQ(-1.0, m.Call(-std::numeric_limits<double>::infinity())); |
| 5551 CHECK_DOUBLE_EQ(std::numeric_limits<double>::infinity(), |
| 5552 m.Call(std::numeric_limits<double>::infinity())); |
| 5553 FOR_FLOAT64_INPUTS(i) { CHECK_DOUBLE_EQ(ieee754::expm1(*i), m.Call(*i)); } |
| 5554 } |
| 5555 |
5533 TEST(RunFloat64Log) { | 5556 TEST(RunFloat64Log) { |
5534 BufferedRawMachineAssemblerTester<double> m(MachineType::Float64()); | 5557 BufferedRawMachineAssemblerTester<double> m(MachineType::Float64()); |
5535 m.Return(m.Float64Log(m.Parameter(0))); | 5558 m.Return(m.Float64Log(m.Parameter(0))); |
5536 CHECK(std::isnan(m.Call(std::numeric_limits<double>::quiet_NaN()))); | 5559 CHECK(std::isnan(m.Call(std::numeric_limits<double>::quiet_NaN()))); |
5537 CHECK(std::isnan(m.Call(std::numeric_limits<double>::signaling_NaN()))); | 5560 CHECK(std::isnan(m.Call(std::numeric_limits<double>::signaling_NaN()))); |
5538 CHECK(std::isnan(m.Call(-std::numeric_limits<double>::infinity()))); | 5561 CHECK(std::isnan(m.Call(-std::numeric_limits<double>::infinity()))); |
5539 CHECK(std::isnan(m.Call(-1.0))); | 5562 CHECK(std::isnan(m.Call(-1.0))); |
5540 CHECK_DOUBLE_EQ(-std::numeric_limits<double>::infinity(), m.Call(-0.0)); | 5563 CHECK_DOUBLE_EQ(-std::numeric_limits<double>::infinity(), m.Call(-0.0)); |
5541 CHECK_DOUBLE_EQ(-std::numeric_limits<double>::infinity(), m.Call(0.0)); | 5564 CHECK_DOUBLE_EQ(-std::numeric_limits<double>::infinity(), m.Call(0.0)); |
5542 CHECK_DOUBLE_EQ(0.0, m.Call(1.0)); | 5565 CHECK_DOUBLE_EQ(0.0, m.Call(1.0)); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5581 CHECK(std::isnan(m.Call(std::numeric_limits<double>::signaling_NaN()))); | 5604 CHECK(std::isnan(m.Call(std::numeric_limits<double>::signaling_NaN()))); |
5582 CHECK(std::isnan(m.Call(-std::numeric_limits<double>::infinity()))); | 5605 CHECK(std::isnan(m.Call(-std::numeric_limits<double>::infinity()))); |
5583 CHECK(std::isnan(m.Call(-1.0))); | 5606 CHECK(std::isnan(m.Call(-1.0))); |
5584 CHECK_DOUBLE_EQ(-std::numeric_limits<double>::infinity(), m.Call(-0.0)); | 5607 CHECK_DOUBLE_EQ(-std::numeric_limits<double>::infinity(), m.Call(-0.0)); |
5585 CHECK_DOUBLE_EQ(-std::numeric_limits<double>::infinity(), m.Call(0.0)); | 5608 CHECK_DOUBLE_EQ(-std::numeric_limits<double>::infinity(), m.Call(0.0)); |
5586 CHECK_DOUBLE_EQ(std::numeric_limits<double>::infinity(), | 5609 CHECK_DOUBLE_EQ(std::numeric_limits<double>::infinity(), |
5587 m.Call(std::numeric_limits<double>::infinity())); | 5610 m.Call(std::numeric_limits<double>::infinity())); |
5588 FOR_FLOAT64_INPUTS(i) { CHECK_DOUBLE_EQ(ieee754::log10(*i), m.Call(*i)); } | 5611 FOR_FLOAT64_INPUTS(i) { CHECK_DOUBLE_EQ(ieee754::log10(*i), m.Call(*i)); } |
5589 } | 5612 } |
5590 | 5613 |
| 5614 TEST(RunFloat64Cbrt) { |
| 5615 BufferedRawMachineAssemblerTester<double> m(MachineType::Float64()); |
| 5616 m.Return(m.Float64Cbrt(m.Parameter(0))); |
| 5617 CHECK(std::isnan(m.Call(std::numeric_limits<double>::quiet_NaN()))); |
| 5618 CHECK(std::isnan(m.Call(std::numeric_limits<double>::signaling_NaN()))); |
| 5619 CHECK_DOUBLE_EQ(std::numeric_limits<double>::infinity(), |
| 5620 m.Call(std::numeric_limits<double>::infinity())); |
| 5621 CHECK_DOUBLE_EQ(-std::numeric_limits<double>::infinity(), |
| 5622 m.Call(-std::numeric_limits<double>::infinity())); |
| 5623 FOR_FLOAT64_INPUTS(i) { CHECK_DOUBLE_EQ(ieee754::cbrt(*i), m.Call(*i)); } |
| 5624 } |
| 5625 |
5591 static double two_30 = 1 << 30; // 2^30 is a smi boundary. | 5626 static double two_30 = 1 << 30; // 2^30 is a smi boundary. |
5592 static double two_52 = two_30 * (1 << 22); // 2^52 is a precision boundary. | 5627 static double two_52 = two_30 * (1 << 22); // 2^52 is a precision boundary. |
5593 static double kValues[] = {0.1, | 5628 static double kValues[] = {0.1, |
5594 0.2, | 5629 0.2, |
5595 0.49999999999999994, | 5630 0.49999999999999994, |
5596 0.5, | 5631 0.5, |
5597 0.7, | 5632 0.7, |
5598 1.0 - std::numeric_limits<double>::epsilon(), | 5633 1.0 - std::numeric_limits<double>::epsilon(), |
5599 -0.1, | 5634 -0.1, |
5600 -0.49999999999999994, | 5635 -0.49999999999999994, |
(...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6350 r.Goto(&merge); | 6385 r.Goto(&merge); |
6351 r.Bind(&merge); | 6386 r.Bind(&merge); |
6352 Node* phi = r.Phi(MachineRepresentation::kWord32, fa, fb); | 6387 Node* phi = r.Phi(MachineRepresentation::kWord32, fa, fb); |
6353 r.Return(phi); | 6388 r.Return(phi); |
6354 CHECK_EQ(1, r.Call(1)); | 6389 CHECK_EQ(1, r.Call(1)); |
6355 } | 6390 } |
6356 | 6391 |
6357 } // namespace compiler | 6392 } // namespace compiler |
6358 } // namespace internal | 6393 } // namespace internal |
6359 } // namespace v8 | 6394 } // namespace v8 |
OLD | NEW |