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 <functional> | 5 #include <functional> |
6 #include <limits> | 6 #include <limits> |
7 | 7 |
8 #include "src/base/bits.h" | 8 #include "src/base/bits.h" |
9 #include "src/compiler/generic-node-inl.h" | 9 #include "src/compiler/generic-node-inl.h" |
10 #include "test/cctest/cctest.h" | 10 #include "test/cctest/cctest.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 return m->Load(kMachInt32, m->PointerConstant(NULL)); | 51 return m->Load(kMachInt32, m->PointerConstant(NULL)); |
52 default: | 52 default: |
53 return NULL; | 53 return NULL; |
54 } | 54 } |
55 } | 55 } |
56 | 56 |
57 | 57 |
58 TEST(CodeGenInt32Binop) { | 58 TEST(CodeGenInt32Binop) { |
59 RawMachineAssemblerTester<void> m; | 59 RawMachineAssemblerTester<void> m; |
60 | 60 |
61 Operator* ops[] = { | 61 const Operator* ops[] = { |
62 m.machine()->Word32And(), m.machine()->Word32Or(), | 62 m.machine()->Word32And(), m.machine()->Word32Or(), |
63 m.machine()->Word32Xor(), m.machine()->Word32Shl(), | 63 m.machine()->Word32Xor(), m.machine()->Word32Shl(), |
64 m.machine()->Word32Shr(), m.machine()->Word32Sar(), | 64 m.machine()->Word32Shr(), m.machine()->Word32Sar(), |
65 m.machine()->Word32Equal(), m.machine()->Int32Add(), | 65 m.machine()->Word32Equal(), m.machine()->Int32Add(), |
66 m.machine()->Int32Sub(), m.machine()->Int32Mul(), | 66 m.machine()->Int32Sub(), m.machine()->Int32Mul(), |
67 m.machine()->Int32Div(), m.machine()->Int32UDiv(), | 67 m.machine()->Int32Div(), m.machine()->Int32UDiv(), |
68 m.machine()->Int32Mod(), m.machine()->Int32UMod(), | 68 m.machine()->Int32Mod(), m.machine()->Int32UMod(), |
69 m.machine()->Int32LessThan(), m.machine()->Int32LessThanOrEqual(), | 69 m.machine()->Int32LessThan(), m.machine()->Int32LessThanOrEqual(), |
70 m.machine()->Uint32LessThan(), m.machine()->Uint32LessThanOrEqual(), | 70 m.machine()->Uint32LessThan(), m.machine()->Uint32LessThanOrEqual(), |
71 NULL}; | 71 NULL}; |
(...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
734 m.Bind(&blockb); | 734 m.Bind(&blockb); |
735 m.Return(m.Int32Constant(0 - constant)); | 735 m.Return(m.Int32Constant(0 - constant)); |
736 FOR_UINT32_INPUTS(j) { | 736 FOR_UINT32_INPUTS(j) { |
737 uint32_t expected = (*i + *j) != 0 ? constant : 0 - constant; | 737 uint32_t expected = (*i + *j) != 0 ? constant : 0 - constant; |
738 CHECK_UINT32_EQ(expected, m.Call(*j)); | 738 CHECK_UINT32_EQ(expected, m.Call(*j)); |
739 } | 739 } |
740 } | 740 } |
741 } | 741 } |
742 { | 742 { |
743 RawMachineAssemblerTester<void> m; | 743 RawMachineAssemblerTester<void> m; |
744 Operator* shops[] = {m.machine()->Word32Sar(), m.machine()->Word32Shl(), | 744 const Operator* shops[] = {m.machine()->Word32Sar(), |
745 m.machine()->Word32Shr()}; | 745 m.machine()->Word32Shl(), |
| 746 m.machine()->Word32Shr()}; |
746 for (size_t n = 0; n < arraysize(shops); n++) { | 747 for (size_t n = 0; n < arraysize(shops); n++) { |
747 RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32, | 748 RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32, |
748 kMachUint32); | 749 kMachUint32); |
749 MLabel blocka, blockb; | 750 MLabel blocka, blockb; |
750 m.Branch(m.Word32Equal(m.Int32Add(m.Parameter(0), | 751 m.Branch(m.Word32Equal(m.Int32Add(m.Parameter(0), |
751 m.NewNode(shops[n], m.Parameter(1), | 752 m.NewNode(shops[n], m.Parameter(1), |
752 m.Parameter(2))), | 753 m.Parameter(2))), |
753 m.Int32Constant(0)), | 754 m.Int32Constant(0)), |
754 &blocka, &blockb); | 755 &blocka, &blockb); |
755 m.Bind(&blocka); | 756 m.Bind(&blocka); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
825 m.Return(m.Word32Equal(m.Int32Add(m.Parameter(0), m.Int32Constant(*i)), | 826 m.Return(m.Word32Equal(m.Int32Add(m.Parameter(0), m.Int32Constant(*i)), |
826 m.Int32Constant(0))); | 827 m.Int32Constant(0))); |
827 FOR_UINT32_INPUTS(j) { | 828 FOR_UINT32_INPUTS(j) { |
828 uint32_t expected = (*j + *i) == 0; | 829 uint32_t expected = (*j + *i) == 0; |
829 CHECK_UINT32_EQ(expected, m.Call(*j)); | 830 CHECK_UINT32_EQ(expected, m.Call(*j)); |
830 } | 831 } |
831 } | 832 } |
832 } | 833 } |
833 { | 834 { |
834 RawMachineAssemblerTester<void> m; | 835 RawMachineAssemblerTester<void> m; |
835 Operator* shops[] = {m.machine()->Word32Sar(), m.machine()->Word32Shl(), | 836 const Operator* shops[] = {m.machine()->Word32Sar(), |
836 m.machine()->Word32Shr()}; | 837 m.machine()->Word32Shl(), |
| 838 m.machine()->Word32Shr()}; |
837 for (size_t n = 0; n < arraysize(shops); n++) { | 839 for (size_t n = 0; n < arraysize(shops); n++) { |
838 RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32, | 840 RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32, |
839 kMachUint32); | 841 kMachUint32); |
840 m.Return(m.Word32Equal( | 842 m.Return(m.Word32Equal( |
841 m.Int32Add(m.Parameter(0), | 843 m.Int32Add(m.Parameter(0), |
842 m.NewNode(shops[n], m.Parameter(1), m.Parameter(2))), | 844 m.NewNode(shops[n], m.Parameter(1), m.Parameter(2))), |
843 m.Int32Constant(0))); | 845 m.Int32Constant(0))); |
844 FOR_UINT32_INPUTS(i) { | 846 FOR_UINT32_INPUTS(i) { |
845 FOR_INT32_INPUTS(j) { | 847 FOR_INT32_INPUTS(j) { |
846 FOR_UINT32_SHIFTS(shift) { | 848 FOR_UINT32_SHIFTS(shift) { |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1069 m.Bind(&blockb); | 1071 m.Bind(&blockb); |
1070 m.Return(m.Int32Constant(0 - constant)); | 1072 m.Return(m.Int32Constant(0 - constant)); |
1071 FOR_UINT32_INPUTS(j) { | 1073 FOR_UINT32_INPUTS(j) { |
1072 int32_t expected = (*i - *j) != 0 ? constant : 0 - constant; | 1074 int32_t expected = (*i - *j) != 0 ? constant : 0 - constant; |
1073 CHECK_EQ(expected, m.Call(*j)); | 1075 CHECK_EQ(expected, m.Call(*j)); |
1074 } | 1076 } |
1075 } | 1077 } |
1076 } | 1078 } |
1077 { | 1079 { |
1078 RawMachineAssemblerTester<void> m; | 1080 RawMachineAssemblerTester<void> m; |
1079 Operator* shops[] = {m.machine()->Word32Sar(), m.machine()->Word32Shl(), | 1081 const Operator* shops[] = {m.machine()->Word32Sar(), |
1080 m.machine()->Word32Shr()}; | 1082 m.machine()->Word32Shl(), |
| 1083 m.machine()->Word32Shr()}; |
1081 for (size_t n = 0; n < arraysize(shops); n++) { | 1084 for (size_t n = 0; n < arraysize(shops); n++) { |
1082 RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32, | 1085 RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32, |
1083 kMachUint32); | 1086 kMachUint32); |
1084 MLabel blocka, blockb; | 1087 MLabel blocka, blockb; |
1085 m.Branch(m.Word32Equal(m.Int32Sub(m.Parameter(0), | 1088 m.Branch(m.Word32Equal(m.Int32Sub(m.Parameter(0), |
1086 m.NewNode(shops[n], m.Parameter(1), | 1089 m.NewNode(shops[n], m.Parameter(1), |
1087 m.Parameter(2))), | 1090 m.Parameter(2))), |
1088 m.Int32Constant(0)), | 1091 m.Int32Constant(0)), |
1089 &blocka, &blockb); | 1092 &blocka, &blockb); |
1090 m.Bind(&blocka); | 1093 m.Bind(&blocka); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1160 m.Return(m.Word32Equal(m.Int32Sub(m.Parameter(0), m.Int32Constant(*i)), | 1163 m.Return(m.Word32Equal(m.Int32Sub(m.Parameter(0), m.Int32Constant(*i)), |
1161 m.Int32Constant(0))); | 1164 m.Int32Constant(0))); |
1162 FOR_UINT32_INPUTS(j) { | 1165 FOR_UINT32_INPUTS(j) { |
1163 uint32_t expected = (*j - *i) == 0; | 1166 uint32_t expected = (*j - *i) == 0; |
1164 CHECK_UINT32_EQ(expected, m.Call(*j)); | 1167 CHECK_UINT32_EQ(expected, m.Call(*j)); |
1165 } | 1168 } |
1166 } | 1169 } |
1167 } | 1170 } |
1168 { | 1171 { |
1169 RawMachineAssemblerTester<void> m; | 1172 RawMachineAssemblerTester<void> m; |
1170 Operator* shops[] = {m.machine()->Word32Sar(), m.machine()->Word32Shl(), | 1173 const Operator* shops[] = {m.machine()->Word32Sar(), |
1171 m.machine()->Word32Shr()}; | 1174 m.machine()->Word32Shl(), |
| 1175 m.machine()->Word32Shr()}; |
1172 for (size_t n = 0; n < arraysize(shops); n++) { | 1176 for (size_t n = 0; n < arraysize(shops); n++) { |
1173 RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32, | 1177 RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32, |
1174 kMachUint32); | 1178 kMachUint32); |
1175 m.Return(m.Word32Equal( | 1179 m.Return(m.Word32Equal( |
1176 m.Int32Sub(m.Parameter(0), | 1180 m.Int32Sub(m.Parameter(0), |
1177 m.NewNode(shops[n], m.Parameter(1), m.Parameter(2))), | 1181 m.NewNode(shops[n], m.Parameter(1), m.Parameter(2))), |
1178 m.Int32Constant(0))); | 1182 m.Int32Constant(0))); |
1179 FOR_UINT32_INPUTS(i) { | 1183 FOR_UINT32_INPUTS(i) { |
1180 FOR_INT32_INPUTS(j) { | 1184 FOR_INT32_INPUTS(j) { |
1181 FOR_UINT32_SHIFTS(shift) { | 1185 FOR_UINT32_SHIFTS(shift) { |
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1692 m.Bind(&blockb); | 1696 m.Bind(&blockb); |
1693 m.Return(m.Int32Constant(0 - constant)); | 1697 m.Return(m.Int32Constant(0 - constant)); |
1694 FOR_UINT32_INPUTS(j) { | 1698 FOR_UINT32_INPUTS(j) { |
1695 int32_t expected = (*i & *j) != 0 ? constant : 0 - constant; | 1699 int32_t expected = (*i & *j) != 0 ? constant : 0 - constant; |
1696 CHECK_EQ(expected, m.Call(*j)); | 1700 CHECK_EQ(expected, m.Call(*j)); |
1697 } | 1701 } |
1698 } | 1702 } |
1699 } | 1703 } |
1700 { | 1704 { |
1701 RawMachineAssemblerTester<void> m; | 1705 RawMachineAssemblerTester<void> m; |
1702 Operator* shops[] = {m.machine()->Word32Sar(), m.machine()->Word32Shl(), | 1706 const Operator* shops[] = {m.machine()->Word32Sar(), |
1703 m.machine()->Word32Shr()}; | 1707 m.machine()->Word32Shl(), |
| 1708 m.machine()->Word32Shr()}; |
1704 for (size_t n = 0; n < arraysize(shops); n++) { | 1709 for (size_t n = 0; n < arraysize(shops); n++) { |
1705 RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32, | 1710 RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32, |
1706 kMachUint32); | 1711 kMachUint32); |
1707 MLabel blocka, blockb; | 1712 MLabel blocka, blockb; |
1708 m.Branch(m.Word32Equal(m.Word32And(m.Parameter(0), | 1713 m.Branch(m.Word32Equal(m.Word32And(m.Parameter(0), |
1709 m.NewNode(shops[n], m.Parameter(1), | 1714 m.NewNode(shops[n], m.Parameter(1), |
1710 m.Parameter(2))), | 1715 m.Parameter(2))), |
1711 m.Int32Constant(0)), | 1716 m.Int32Constant(0)), |
1712 &blocka, &blockb); | 1717 &blocka, &blockb); |
1713 m.Bind(&blocka); | 1718 m.Bind(&blocka); |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1919 m.Bind(&blockb); | 1924 m.Bind(&blockb); |
1920 m.Return(m.Int32Constant(0 - constant)); | 1925 m.Return(m.Int32Constant(0 - constant)); |
1921 FOR_INT32_INPUTS(j) { | 1926 FOR_INT32_INPUTS(j) { |
1922 int32_t expected = (*i | *j) != 0 ? constant : 0 - constant; | 1927 int32_t expected = (*i | *j) != 0 ? constant : 0 - constant; |
1923 CHECK_EQ(expected, m.Call(*j)); | 1928 CHECK_EQ(expected, m.Call(*j)); |
1924 } | 1929 } |
1925 } | 1930 } |
1926 } | 1931 } |
1927 { | 1932 { |
1928 RawMachineAssemblerTester<void> m; | 1933 RawMachineAssemblerTester<void> m; |
1929 Operator* shops[] = {m.machine()->Word32Sar(), m.machine()->Word32Shl(), | 1934 const Operator* shops[] = {m.machine()->Word32Sar(), |
1930 m.machine()->Word32Shr()}; | 1935 m.machine()->Word32Shl(), |
| 1936 m.machine()->Word32Shr()}; |
1931 for (size_t n = 0; n < arraysize(shops); n++) { | 1937 for (size_t n = 0; n < arraysize(shops); n++) { |
1932 RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32, | 1938 RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32, |
1933 kMachUint32); | 1939 kMachUint32); |
1934 MLabel blocka, blockb; | 1940 MLabel blocka, blockb; |
1935 m.Branch(m.Word32Equal(m.Word32Or(m.Parameter(0), | 1941 m.Branch(m.Word32Equal(m.Word32Or(m.Parameter(0), |
1936 m.NewNode(shops[n], m.Parameter(1), | 1942 m.NewNode(shops[n], m.Parameter(1), |
1937 m.Parameter(2))), | 1943 m.Parameter(2))), |
1938 m.Int32Constant(0)), | 1944 m.Int32Constant(0)), |
1939 &blocka, &blockb); | 1945 &blocka, &blockb); |
1940 m.Bind(&blocka); | 1946 m.Bind(&blocka); |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2143 m.Bind(&blockb); | 2149 m.Bind(&blockb); |
2144 m.Return(m.Int32Constant(0 - constant)); | 2150 m.Return(m.Int32Constant(0 - constant)); |
2145 FOR_UINT32_INPUTS(j) { | 2151 FOR_UINT32_INPUTS(j) { |
2146 uint32_t expected = (*i ^ *j) != 0 ? constant : 0 - constant; | 2152 uint32_t expected = (*i ^ *j) != 0 ? constant : 0 - constant; |
2147 CHECK_UINT32_EQ(expected, m.Call(*j)); | 2153 CHECK_UINT32_EQ(expected, m.Call(*j)); |
2148 } | 2154 } |
2149 } | 2155 } |
2150 } | 2156 } |
2151 { | 2157 { |
2152 RawMachineAssemblerTester<void> m; | 2158 RawMachineAssemblerTester<void> m; |
2153 Operator* shops[] = {m.machine()->Word32Sar(), m.machine()->Word32Shl(), | 2159 const Operator* shops[] = {m.machine()->Word32Sar(), |
2154 m.machine()->Word32Shr()}; | 2160 m.machine()->Word32Shl(), |
| 2161 m.machine()->Word32Shr()}; |
2155 for (size_t n = 0; n < arraysize(shops); n++) { | 2162 for (size_t n = 0; n < arraysize(shops); n++) { |
2156 RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32, | 2163 RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32, |
2157 kMachUint32); | 2164 kMachUint32); |
2158 MLabel blocka, blockb; | 2165 MLabel blocka, blockb; |
2159 m.Branch(m.Word32Equal(m.Word32Xor(m.Parameter(0), | 2166 m.Branch(m.Word32Equal(m.Word32Xor(m.Parameter(0), |
2160 m.NewNode(shops[n], m.Parameter(1), | 2167 m.NewNode(shops[n], m.Parameter(1), |
2161 m.Parameter(2))), | 2168 m.Parameter(2))), |
2162 m.Int32Constant(0)), | 2169 m.Int32Constant(0)), |
2163 &blocka, &blockb); | 2170 &blocka, &blockb); |
2164 m.Bind(&blocka); | 2171 m.Bind(&blocka); |
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2644 } else { | 2651 } else { |
2645 CHECK_EQ(constant, m.Call(0)); | 2652 CHECK_EQ(constant, m.Call(0)); |
2646 } | 2653 } |
2647 } | 2654 } |
2648 } | 2655 } |
2649 | 2656 |
2650 | 2657 |
2651 TEST(RunDeadInt32Binops) { | 2658 TEST(RunDeadInt32Binops) { |
2652 RawMachineAssemblerTester<int32_t> m; | 2659 RawMachineAssemblerTester<int32_t> m; |
2653 | 2660 |
2654 Operator* ops[] = { | 2661 const Operator* ops[] = { |
2655 m.machine()->Word32And(), m.machine()->Word32Or(), | 2662 m.machine()->Word32And(), m.machine()->Word32Or(), |
2656 m.machine()->Word32Xor(), m.machine()->Word32Shl(), | 2663 m.machine()->Word32Xor(), m.machine()->Word32Shl(), |
2657 m.machine()->Word32Shr(), m.machine()->Word32Sar(), | 2664 m.machine()->Word32Shr(), m.machine()->Word32Sar(), |
2658 m.machine()->Word32Ror(), m.machine()->Word32Equal(), | 2665 m.machine()->Word32Ror(), m.machine()->Word32Equal(), |
2659 m.machine()->Int32Add(), m.machine()->Int32Sub(), | 2666 m.machine()->Int32Add(), m.machine()->Int32Sub(), |
2660 m.machine()->Int32Mul(), m.machine()->Int32Div(), | 2667 m.machine()->Int32Mul(), m.machine()->Int32Div(), |
2661 m.machine()->Int32UDiv(), m.machine()->Int32Mod(), | 2668 m.machine()->Int32UDiv(), m.machine()->Int32Mod(), |
2662 m.machine()->Int32UMod(), m.machine()->Int32LessThan(), | 2669 m.machine()->Int32UMod(), m.machine()->Int32LessThan(), |
2663 m.machine()->Int32LessThanOrEqual(), m.machine()->Uint32LessThan(), | 2670 m.machine()->Int32LessThanOrEqual(), m.machine()->Uint32LessThan(), |
2664 m.machine()->Uint32LessThanOrEqual(), NULL}; | 2671 m.machine()->Uint32LessThanOrEqual(), NULL}; |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2755 RunLoadStore<void*>(kMachAnyTagged); | 2762 RunLoadStore<void*>(kMachAnyTagged); |
2756 RunLoadStore<float>(kMachFloat32); | 2763 RunLoadStore<float>(kMachFloat32); |
2757 RunLoadStore<double>(kMachFloat64); | 2764 RunLoadStore<double>(kMachFloat64); |
2758 } | 2765 } |
2759 | 2766 |
2760 | 2767 |
2761 TEST(RunFloat64Binop) { | 2768 TEST(RunFloat64Binop) { |
2762 RawMachineAssemblerTester<int32_t> m; | 2769 RawMachineAssemblerTester<int32_t> m; |
2763 double result; | 2770 double result; |
2764 | 2771 |
2765 Operator* ops[] = {m.machine()->Float64Add(), m.machine()->Float64Sub(), | 2772 const Operator* ops[] = {m.machine()->Float64Add(), m.machine()->Float64Sub(), |
2766 m.machine()->Float64Mul(), m.machine()->Float64Div(), | 2773 m.machine()->Float64Mul(), m.machine()->Float64Div(), |
2767 m.machine()->Float64Mod(), NULL}; | 2774 m.machine()->Float64Mod(), NULL}; |
2768 | 2775 |
2769 double inf = V8_INFINITY; | 2776 double inf = V8_INFINITY; |
2770 Operator* inputs[] = { | 2777 const Operator* inputs[] = { |
2771 m.common()->Float64Constant(0), m.common()->Float64Constant(1), | 2778 m.common()->Float64Constant(0), m.common()->Float64Constant(1), |
2772 m.common()->Float64Constant(1), m.common()->Float64Constant(0), | 2779 m.common()->Float64Constant(1), m.common()->Float64Constant(0), |
2773 m.common()->Float64Constant(0), m.common()->Float64Constant(-1), | 2780 m.common()->Float64Constant(0), m.common()->Float64Constant(-1), |
2774 m.common()->Float64Constant(-1), m.common()->Float64Constant(0), | 2781 m.common()->Float64Constant(-1), m.common()->Float64Constant(0), |
2775 m.common()->Float64Constant(0.22), m.common()->Float64Constant(-1.22), | 2782 m.common()->Float64Constant(0.22), m.common()->Float64Constant(-1.22), |
2776 m.common()->Float64Constant(-1.22), m.common()->Float64Constant(0.22), | 2783 m.common()->Float64Constant(-1.22), m.common()->Float64Constant(0.22), |
2777 m.common()->Float64Constant(inf), m.common()->Float64Constant(0.22), | 2784 m.common()->Float64Constant(inf), m.common()->Float64Constant(0.22), |
2778 m.common()->Float64Constant(inf), m.common()->Float64Constant(-inf), | 2785 m.common()->Float64Constant(inf), m.common()->Float64Constant(-inf), |
2779 NULL}; | 2786 NULL}; |
2780 | 2787 |
2781 for (int i = 0; ops[i] != NULL; i++) { | 2788 for (int i = 0; ops[i] != NULL; i++) { |
2782 for (int j = 0; inputs[j] != NULL; j += 2) { | 2789 for (int j = 0; inputs[j] != NULL; j += 2) { |
2783 RawMachineAssemblerTester<int32_t> m; | 2790 RawMachineAssemblerTester<int32_t> m; |
2784 Node* a = m.NewNode(inputs[j]); | 2791 Node* a = m.NewNode(inputs[j]); |
2785 Node* b = m.NewNode(inputs[j + 1]); | 2792 Node* b = m.NewNode(inputs[j + 1]); |
2786 Node* binop = m.NewNode(ops[i], a, b); | 2793 Node* binop = m.NewNode(ops[i], a, b); |
2787 Node* base = m.PointerConstant(&result); | 2794 Node* base = m.PointerConstant(&result); |
2788 Node* zero = m.Int32Constant(0); | 2795 Node* zero = m.Int32Constant(0); |
2789 m.Store(kMachFloat64, base, zero, binop); | 2796 m.Store(kMachFloat64, base, zero, binop); |
2790 m.Return(m.Int32Constant(i + j)); | 2797 m.Return(m.Int32Constant(i + j)); |
2791 CHECK_EQ(i + j, m.Call()); | 2798 CHECK_EQ(i + j, m.Call()); |
2792 } | 2799 } |
2793 } | 2800 } |
2794 } | 2801 } |
2795 | 2802 |
2796 | 2803 |
2797 TEST(RunDeadFloat64Binops) { | 2804 TEST(RunDeadFloat64Binops) { |
2798 RawMachineAssemblerTester<int32_t> m; | 2805 RawMachineAssemblerTester<int32_t> m; |
2799 | 2806 |
2800 Operator* ops[] = {m.machine()->Float64Add(), m.machine()->Float64Sub(), | 2807 const Operator* ops[] = {m.machine()->Float64Add(), m.machine()->Float64Sub(), |
2801 m.machine()->Float64Mul(), m.machine()->Float64Div(), | 2808 m.machine()->Float64Mul(), m.machine()->Float64Div(), |
2802 m.machine()->Float64Mod(), NULL}; | 2809 m.machine()->Float64Mod(), NULL}; |
2803 | 2810 |
2804 for (int i = 0; ops[i] != NULL; i++) { | 2811 for (int i = 0; ops[i] != NULL; i++) { |
2805 RawMachineAssemblerTester<int32_t> m; | 2812 RawMachineAssemblerTester<int32_t> m; |
2806 int constant = 0x53355 + i; | 2813 int constant = 0x53355 + i; |
2807 m.NewNode(ops[i], m.Float64Constant(0.1), m.Float64Constant(1.11)); | 2814 m.NewNode(ops[i], m.Float64Constant(0.1), m.Float64Constant(1.11)); |
2808 m.Return(m.Int32Constant(constant)); | 2815 m.Return(m.Int32Constant(constant)); |
2809 CHECK_EQ(constant, m.Call()); | 2816 CHECK_EQ(constant, m.Call()); |
2810 } | 2817 } |
2811 } | 2818 } |
2812 | 2819 |
(...skipping 894 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3707 CHECK_EQ(expected, m.Call()); | 3714 CHECK_EQ(expected, m.Call()); |
3708 } | 3715 } |
3709 } | 3716 } |
3710 } | 3717 } |
3711 } | 3718 } |
3712 | 3719 |
3713 | 3720 |
3714 TEST(RunFloat64UnorderedCompare) { | 3721 TEST(RunFloat64UnorderedCompare) { |
3715 RawMachineAssemblerTester<int32_t> m; | 3722 RawMachineAssemblerTester<int32_t> m; |
3716 | 3723 |
3717 Operator* operators[] = {m.machine()->Float64Equal(), | 3724 const Operator* operators[] = {m.machine()->Float64Equal(), |
3718 m.machine()->Float64LessThan(), | 3725 m.machine()->Float64LessThan(), |
3719 m.machine()->Float64LessThanOrEqual()}; | 3726 m.machine()->Float64LessThanOrEqual()}; |
3720 | 3727 |
3721 double nan = v8::base::OS::nan_value(); | 3728 double nan = v8::base::OS::nan_value(); |
3722 | 3729 |
3723 FOR_FLOAT64_INPUTS(i) { | 3730 FOR_FLOAT64_INPUTS(i) { |
3724 for (size_t o = 0; o < arraysize(operators); ++o) { | 3731 for (size_t o = 0; o < arraysize(operators); ++o) { |
3725 for (int j = 0; j < 2; j++) { | 3732 for (int j = 0; j < 2; j++) { |
3726 RawMachineAssemblerTester<int32_t> m; | 3733 RawMachineAssemblerTester<int32_t> m; |
3727 Node* a = m.Float64Constant(*i); | 3734 Node* a = m.Float64Constant(*i); |
3728 Node* b = m.Float64Constant(nan); | 3735 Node* b = m.Float64Constant(nan); |
3729 if (j == 1) std::swap(a, b); | 3736 if (j == 1) std::swap(a, b); |
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4298 RawMachineAssemblerTester<int32_t> m; | 4305 RawMachineAssemblerTester<int32_t> m; |
4299 m.Return(m.TruncateFloat64ToInt32(m.LoadFromPointer(&input, kMachFloat64))); | 4306 m.Return(m.TruncateFloat64ToInt32(m.LoadFromPointer(&input, kMachFloat64))); |
4300 for (size_t i = 0; i < arraysize(kValues); ++i) { | 4307 for (size_t i = 0; i < arraysize(kValues); ++i) { |
4301 input = kValues[i].from; | 4308 input = kValues[i].from; |
4302 uint64_t expected = static_cast<int64_t>(kValues[i].raw); | 4309 uint64_t expected = static_cast<int64_t>(kValues[i].raw); |
4303 CHECK_EQ(static_cast<int>(expected), m.Call()); | 4310 CHECK_EQ(static_cast<int>(expected), m.Call()); |
4304 } | 4311 } |
4305 } | 4312 } |
4306 | 4313 |
4307 #endif // V8_TURBOFAN_TARGET | 4314 #endif // V8_TURBOFAN_TARGET |
OLD | NEW |