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 2892 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2903 | 2903 |
2904 | 2904 |
2905 TEST(RunFloat64Binop) { | 2905 TEST(RunFloat64Binop) { |
2906 RawMachineAssemblerTester<int32_t> m; | 2906 RawMachineAssemblerTester<int32_t> m; |
2907 double result; | 2907 double result; |
2908 | 2908 |
2909 const Operator* ops[] = {m.machine()->Float64Add(), m.machine()->Float64Sub(), | 2909 const Operator* ops[] = {m.machine()->Float64Add(), m.machine()->Float64Sub(), |
2910 m.machine()->Float64Mul(), m.machine()->Float64Div(), | 2910 m.machine()->Float64Mul(), m.machine()->Float64Div(), |
2911 m.machine()->Float64Mod(), NULL}; | 2911 m.machine()->Float64Mod(), NULL}; |
2912 | 2912 |
2913 double inf = V8_INFINITY; | 2913 double inf = std::numeric_limits<double>::infinity(); |
2914 const Operator* inputs[] = { | 2914 const Operator* inputs[] = { |
2915 m.common()->Float64Constant(0), m.common()->Float64Constant(1), | 2915 m.common()->Float64Constant(0), m.common()->Float64Constant(1), |
2916 m.common()->Float64Constant(1), m.common()->Float64Constant(0), | 2916 m.common()->Float64Constant(1), m.common()->Float64Constant(0), |
2917 m.common()->Float64Constant(0), m.common()->Float64Constant(-1), | 2917 m.common()->Float64Constant(0), m.common()->Float64Constant(-1), |
2918 m.common()->Float64Constant(-1), m.common()->Float64Constant(0), | 2918 m.common()->Float64Constant(-1), m.common()->Float64Constant(0), |
2919 m.common()->Float64Constant(0.22), m.common()->Float64Constant(-1.22), | 2919 m.common()->Float64Constant(0.22), m.common()->Float64Constant(-1.22), |
2920 m.common()->Float64Constant(-1.22), m.common()->Float64Constant(0.22), | 2920 m.common()->Float64Constant(-1.22), m.common()->Float64Constant(0.22), |
2921 m.common()->Float64Constant(inf), m.common()->Float64Constant(0.22), | 2921 m.common()->Float64Constant(inf), m.common()->Float64Constant(0.22), |
2922 m.common()->Float64Constant(inf), m.common()->Float64Constant(-inf), | 2922 m.common()->Float64Constant(inf), m.common()->Float64Constant(-inf), |
2923 NULL}; | 2923 NULL}; |
(...skipping 933 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3857 break; | 3857 break; |
3858 default: | 3858 default: |
3859 UNREACHABLE(); | 3859 UNREACHABLE(); |
3860 } | 3860 } |
3861 m->Return(cmp); | 3861 m->Return(cmp); |
3862 return expected; | 3862 return expected; |
3863 } | 3863 } |
3864 | 3864 |
3865 | 3865 |
3866 TEST(RunFloat64Compare) { | 3866 TEST(RunFloat64Compare) { |
3867 double inf = V8_INFINITY; | 3867 double inf = std::numeric_limits<double>::infinity(); |
3868 // All pairs (a1, a2) are of the form a1 < a2. | 3868 // All pairs (a1, a2) are of the form a1 < a2. |
3869 double inputs[] = {0.0, 1.0, -1.0, 0.22, -1.22, 0.22, | 3869 double inputs[] = {0.0, 1.0, -1.0, 0.22, -1.22, 0.22, |
3870 -inf, 0.22, 0.22, inf, -inf, inf}; | 3870 -inf, 0.22, 0.22, inf, -inf, inf}; |
3871 | 3871 |
3872 for (int test = 0; test < kFloat64CompareHelperTestCases; test++) { | 3872 for (int test = 0; test < kFloat64CompareHelperTestCases; test++) { |
3873 for (int node_type = 0; node_type < kFloat64CompareHelperNodeType; | 3873 for (int node_type = 0; node_type < kFloat64CompareHelperNodeType; |
3874 node_type++) { | 3874 node_type++) { |
3875 for (size_t input = 0; input < arraysize(inputs); input += 2) { | 3875 for (size_t input = 0; input < arraysize(inputs); input += 2) { |
3876 RawMachineAssemblerTester<int32_t> m; | 3876 RawMachineAssemblerTester<int32_t> m; |
3877 int expected = Float64CompareHelper(&m, test, node_type, inputs[input], | 3877 int expected = Float64CompareHelper(&m, test, node_type, inputs[input], |
(...skipping 804 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4682 m.Float64RoundTiesAway(m.LoadFromPointer(&input, kMachFloat64))); | 4682 m.Float64RoundTiesAway(m.LoadFromPointer(&input, kMachFloat64))); |
4683 m.Return(m.Int32Constant(0)); | 4683 m.Return(m.Int32Constant(0)); |
4684 for (size_t i = 0; i < arraysize(kValues); ++i) { | 4684 for (size_t i = 0; i < arraysize(kValues); ++i) { |
4685 input = kValues[i]; | 4685 input = kValues[i]; |
4686 CHECK_EQ(0, m.Call()); | 4686 CHECK_EQ(0, m.Call()); |
4687 double expected = round(kValues[i]); | 4687 double expected = round(kValues[i]); |
4688 CHECK_EQ(expected, result); | 4688 CHECK_EQ(expected, result); |
4689 } | 4689 } |
4690 } | 4690 } |
4691 #endif // V8_TURBOFAN_TARGET | 4691 #endif // V8_TURBOFAN_TARGET |
OLD | NEW |