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/base/utils/random-number-generator.h" | 10 #include "src/base/utils/random-number-generator.h" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 m.machine()->Uint32Mod(), m.machine()->Uint32MulHigh(), | 65 m.machine()->Uint32Mod(), m.machine()->Uint32MulHigh(), |
66 m.machine()->Int32LessThan(), m.machine()->Int32LessThanOrEqual(), | 66 m.machine()->Int32LessThan(), m.machine()->Int32LessThanOrEqual(), |
67 m.machine()->Uint32LessThan(), m.machine()->Uint32LessThanOrEqual()}; | 67 m.machine()->Uint32LessThan(), m.machine()->Uint32LessThanOrEqual()}; |
68 | 68 |
69 for (size_t i = 0; i < arraysize(kOps); ++i) { | 69 for (size_t i = 0; i < arraysize(kOps); ++i) { |
70 for (int j = 0; j < 8; j++) { | 70 for (int j = 0; j < 8; j++) { |
71 for (int k = 0; k < 8; k++) { | 71 for (int k = 0; k < 8; k++) { |
72 RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachInt32); | 72 RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachInt32); |
73 Node* a = Int32Input(&m, j); | 73 Node* a = Int32Input(&m, j); |
74 Node* b = Int32Input(&m, k); | 74 Node* b = Int32Input(&m, k); |
75 m.Return(m.NewNode(kOps[i], a, b)); | 75 m.Return(m.AddNode(kOps[i], a, b)); |
76 m.GenerateCode(); | 76 m.GenerateCode(); |
77 } | 77 } |
78 } | 78 } |
79 } | 79 } |
80 } | 80 } |
81 | 81 |
82 | 82 |
83 TEST(CodeGenNop) { | 83 TEST(CodeGenNop) { |
84 RawMachineAssemblerTester<void> m; | 84 RawMachineAssemblerTester<void> m; |
85 m.Return(m.Int32Constant(0)); | 85 m.Return(m.Int32Constant(0)); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 m.machine()->Uint64Mod(), m.machine()->Int64LessThan(), | 125 m.machine()->Uint64Mod(), m.machine()->Int64LessThan(), |
126 m.machine()->Int64LessThanOrEqual(), m.machine()->Uint64LessThan(), | 126 m.machine()->Int64LessThanOrEqual(), m.machine()->Uint64LessThan(), |
127 m.machine()->Uint64LessThanOrEqual()}; | 127 m.machine()->Uint64LessThanOrEqual()}; |
128 | 128 |
129 for (size_t i = 0; i < arraysize(kOps); ++i) { | 129 for (size_t i = 0; i < arraysize(kOps); ++i) { |
130 for (int j = 0; j < 8; j++) { | 130 for (int j = 0; j < 8; j++) { |
131 for (int k = 0; k < 8; k++) { | 131 for (int k = 0; k < 8; k++) { |
132 RawMachineAssemblerTester<int64_t> m(kMachInt64, kMachInt64); | 132 RawMachineAssemblerTester<int64_t> m(kMachInt64, kMachInt64); |
133 Node* a = Int64Input(&m, j); | 133 Node* a = Int64Input(&m, j); |
134 Node* b = Int64Input(&m, k); | 134 Node* b = Int64Input(&m, k); |
135 m.Return(m.NewNode(kOps[i], a, b)); | 135 m.Return(m.AddNode(kOps[i], a, b)); |
136 m.GenerateCode(); | 136 m.GenerateCode(); |
137 } | 137 } |
138 } | 138 } |
139 } | 139 } |
140 } | 140 } |
141 | 141 |
142 | 142 |
143 // TODO(titzer): add tests that run 64-bit integer operations. | 143 // TODO(titzer): add tests that run 64-bit integer operations. |
144 #endif // V8_TARGET_ARCH_64_BIT | 144 #endif // V8_TARGET_ARCH_64_BIT |
145 | 145 |
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
619 m.Bind(case_labels[i]); | 619 m.Bind(case_labels[i]); |
620 results[i] = m.Int32Constant(values[i]); | 620 results[i] = m.Int32Constant(values[i]); |
621 m.Goto(&end); | 621 m.Goto(&end); |
622 } | 622 } |
623 m.Bind(&def); | 623 m.Bind(&def); |
624 results[kNumCases] = m.Int32Constant(values[kNumCases]); | 624 results[kNumCases] = m.Int32Constant(values[kNumCases]); |
625 m.Goto(&end); | 625 m.Goto(&end); |
626 m.Bind(&end); | 626 m.Bind(&end); |
627 const int num_results = static_cast<int>(arraysize(results)); | 627 const int num_results = static_cast<int>(arraysize(results)); |
628 Node* phi = | 628 Node* phi = |
629 m.NewNode(m.common()->Phi(kMachInt32, num_results), num_results, results); | 629 m.AddNode(m.common()->Phi(kMachInt32, num_results), num_results, results); |
630 m.Return(phi); | 630 m.Return(phi); |
631 | 631 |
632 for (size_t i = 0; i < kNumValues; ++i) { | 632 for (size_t i = 0; i < kNumValues; ++i) { |
633 CHECK_EQ(values[i], m.Call(static_cast<int>(i))); | 633 CHECK_EQ(values[i], m.Call(static_cast<int>(i))); |
634 } | 634 } |
635 } | 635 } |
636 | 636 |
637 | 637 |
638 TEST(RunLoadInt32) { | 638 TEST(RunLoadInt32) { |
639 RawMachineAssemblerTester<int32_t> m; | 639 RawMachineAssemblerTester<int32_t> m; |
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1046 { | 1046 { |
1047 RawMachineAssemblerTester<void> m; | 1047 RawMachineAssemblerTester<void> m; |
1048 const Operator* shops[] = {m.machine()->Word32Sar(), | 1048 const Operator* shops[] = {m.machine()->Word32Sar(), |
1049 m.machine()->Word32Shl(), | 1049 m.machine()->Word32Shl(), |
1050 m.machine()->Word32Shr()}; | 1050 m.machine()->Word32Shr()}; |
1051 for (size_t n = 0; n < arraysize(shops); n++) { | 1051 for (size_t n = 0; n < arraysize(shops); n++) { |
1052 RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32, | 1052 RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32, |
1053 kMachUint32); | 1053 kMachUint32); |
1054 MLabel blocka, blockb; | 1054 MLabel blocka, blockb; |
1055 m.Branch(m.Word32Equal(m.Int32Add(m.Parameter(0), | 1055 m.Branch(m.Word32Equal(m.Int32Add(m.Parameter(0), |
1056 m.NewNode(shops[n], m.Parameter(1), | 1056 m.AddNode(shops[n], m.Parameter(1), |
1057 m.Parameter(2))), | 1057 m.Parameter(2))), |
1058 m.Int32Constant(0)), | 1058 m.Int32Constant(0)), |
1059 &blocka, &blockb); | 1059 &blocka, &blockb); |
1060 m.Bind(&blocka); | 1060 m.Bind(&blocka); |
1061 m.Return(m.Int32Constant(constant)); | 1061 m.Return(m.Int32Constant(constant)); |
1062 m.Bind(&blockb); | 1062 m.Bind(&blockb); |
1063 m.Return(m.Int32Constant(0 - constant)); | 1063 m.Return(m.Int32Constant(0 - constant)); |
1064 FOR_UINT32_INPUTS(i) { | 1064 FOR_UINT32_INPUTS(i) { |
1065 FOR_INT32_INPUTS(j) { | 1065 FOR_INT32_INPUTS(j) { |
1066 FOR_UINT32_SHIFTS(shift) { | 1066 FOR_UINT32_SHIFTS(shift) { |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1138 { | 1138 { |
1139 RawMachineAssemblerTester<void> m; | 1139 RawMachineAssemblerTester<void> m; |
1140 const Operator* shops[] = {m.machine()->Word32Sar(), | 1140 const Operator* shops[] = {m.machine()->Word32Sar(), |
1141 m.machine()->Word32Shl(), | 1141 m.machine()->Word32Shl(), |
1142 m.machine()->Word32Shr()}; | 1142 m.machine()->Word32Shr()}; |
1143 for (size_t n = 0; n < arraysize(shops); n++) { | 1143 for (size_t n = 0; n < arraysize(shops); n++) { |
1144 RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32, | 1144 RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32, |
1145 kMachUint32); | 1145 kMachUint32); |
1146 m.Return(m.Word32Equal( | 1146 m.Return(m.Word32Equal( |
1147 m.Int32Add(m.Parameter(0), | 1147 m.Int32Add(m.Parameter(0), |
1148 m.NewNode(shops[n], m.Parameter(1), m.Parameter(2))), | 1148 m.AddNode(shops[n], m.Parameter(1), m.Parameter(2))), |
1149 m.Int32Constant(0))); | 1149 m.Int32Constant(0))); |
1150 FOR_UINT32_INPUTS(i) { | 1150 FOR_UINT32_INPUTS(i) { |
1151 FOR_INT32_INPUTS(j) { | 1151 FOR_INT32_INPUTS(j) { |
1152 FOR_UINT32_SHIFTS(shift) { | 1152 FOR_UINT32_SHIFTS(shift) { |
1153 int32_t right; | 1153 int32_t right; |
1154 switch (shops[n]->opcode()) { | 1154 switch (shops[n]->opcode()) { |
1155 default: | 1155 default: |
1156 UNREACHABLE(); | 1156 UNREACHABLE(); |
1157 case IrOpcode::kWord32Sar: | 1157 case IrOpcode::kWord32Sar: |
1158 right = *j >> shift; | 1158 right = *j >> shift; |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1383 { | 1383 { |
1384 RawMachineAssemblerTester<void> m; | 1384 RawMachineAssemblerTester<void> m; |
1385 const Operator* shops[] = {m.machine()->Word32Sar(), | 1385 const Operator* shops[] = {m.machine()->Word32Sar(), |
1386 m.machine()->Word32Shl(), | 1386 m.machine()->Word32Shl(), |
1387 m.machine()->Word32Shr()}; | 1387 m.machine()->Word32Shr()}; |
1388 for (size_t n = 0; n < arraysize(shops); n++) { | 1388 for (size_t n = 0; n < arraysize(shops); n++) { |
1389 RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32, | 1389 RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32, |
1390 kMachUint32); | 1390 kMachUint32); |
1391 MLabel blocka, blockb; | 1391 MLabel blocka, blockb; |
1392 m.Branch(m.Word32Equal(m.Int32Sub(m.Parameter(0), | 1392 m.Branch(m.Word32Equal(m.Int32Sub(m.Parameter(0), |
1393 m.NewNode(shops[n], m.Parameter(1), | 1393 m.AddNode(shops[n], m.Parameter(1), |
1394 m.Parameter(2))), | 1394 m.Parameter(2))), |
1395 m.Int32Constant(0)), | 1395 m.Int32Constant(0)), |
1396 &blocka, &blockb); | 1396 &blocka, &blockb); |
1397 m.Bind(&blocka); | 1397 m.Bind(&blocka); |
1398 m.Return(m.Int32Constant(constant)); | 1398 m.Return(m.Int32Constant(constant)); |
1399 m.Bind(&blockb); | 1399 m.Bind(&blockb); |
1400 m.Return(m.Int32Constant(0 - constant)); | 1400 m.Return(m.Int32Constant(0 - constant)); |
1401 FOR_UINT32_INPUTS(i) { | 1401 FOR_UINT32_INPUTS(i) { |
1402 FOR_INT32_INPUTS(j) { | 1402 FOR_INT32_INPUTS(j) { |
1403 FOR_UINT32_SHIFTS(shift) { | 1403 FOR_UINT32_SHIFTS(shift) { |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1475 { | 1475 { |
1476 RawMachineAssemblerTester<void> m; | 1476 RawMachineAssemblerTester<void> m; |
1477 const Operator* shops[] = {m.machine()->Word32Sar(), | 1477 const Operator* shops[] = {m.machine()->Word32Sar(), |
1478 m.machine()->Word32Shl(), | 1478 m.machine()->Word32Shl(), |
1479 m.machine()->Word32Shr()}; | 1479 m.machine()->Word32Shr()}; |
1480 for (size_t n = 0; n < arraysize(shops); n++) { | 1480 for (size_t n = 0; n < arraysize(shops); n++) { |
1481 RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32, | 1481 RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32, |
1482 kMachUint32); | 1482 kMachUint32); |
1483 m.Return(m.Word32Equal( | 1483 m.Return(m.Word32Equal( |
1484 m.Int32Sub(m.Parameter(0), | 1484 m.Int32Sub(m.Parameter(0), |
1485 m.NewNode(shops[n], m.Parameter(1), m.Parameter(2))), | 1485 m.AddNode(shops[n], m.Parameter(1), m.Parameter(2))), |
1486 m.Int32Constant(0))); | 1486 m.Int32Constant(0))); |
1487 FOR_UINT32_INPUTS(i) { | 1487 FOR_UINT32_INPUTS(i) { |
1488 FOR_INT32_INPUTS(j) { | 1488 FOR_INT32_INPUTS(j) { |
1489 FOR_UINT32_SHIFTS(shift) { | 1489 FOR_UINT32_SHIFTS(shift) { |
1490 int32_t right; | 1490 int32_t right; |
1491 switch (shops[n]->opcode()) { | 1491 switch (shops[n]->opcode()) { |
1492 default: | 1492 default: |
1493 UNREACHABLE(); | 1493 UNREACHABLE(); |
1494 case IrOpcode::kWord32Sar: | 1494 case IrOpcode::kWord32Sar: |
1495 right = *j >> shift; | 1495 right = *j >> shift; |
(...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2052 { | 2052 { |
2053 RawMachineAssemblerTester<void> m; | 2053 RawMachineAssemblerTester<void> m; |
2054 const Operator* shops[] = {m.machine()->Word32Sar(), | 2054 const Operator* shops[] = {m.machine()->Word32Sar(), |
2055 m.machine()->Word32Shl(), | 2055 m.machine()->Word32Shl(), |
2056 m.machine()->Word32Shr()}; | 2056 m.machine()->Word32Shr()}; |
2057 for (size_t n = 0; n < arraysize(shops); n++) { | 2057 for (size_t n = 0; n < arraysize(shops); n++) { |
2058 RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32, | 2058 RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32, |
2059 kMachUint32); | 2059 kMachUint32); |
2060 MLabel blocka, blockb; | 2060 MLabel blocka, blockb; |
2061 m.Branch(m.Word32Equal(m.Word32And(m.Parameter(0), | 2061 m.Branch(m.Word32Equal(m.Word32And(m.Parameter(0), |
2062 m.NewNode(shops[n], m.Parameter(1), | 2062 m.AddNode(shops[n], m.Parameter(1), |
2063 m.Parameter(2))), | 2063 m.Parameter(2))), |
2064 m.Int32Constant(0)), | 2064 m.Int32Constant(0)), |
2065 &blocka, &blockb); | 2065 &blocka, &blockb); |
2066 m.Bind(&blocka); | 2066 m.Bind(&blocka); |
2067 m.Return(m.Int32Constant(constant)); | 2067 m.Return(m.Int32Constant(constant)); |
2068 m.Bind(&blockb); | 2068 m.Bind(&blockb); |
2069 m.Return(m.Int32Constant(0 - constant)); | 2069 m.Return(m.Int32Constant(0 - constant)); |
2070 FOR_UINT32_INPUTS(i) { | 2070 FOR_UINT32_INPUTS(i) { |
2071 FOR_INT32_INPUTS(j) { | 2071 FOR_INT32_INPUTS(j) { |
2072 FOR_UINT32_SHIFTS(shift) { | 2072 FOR_UINT32_SHIFTS(shift) { |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2280 { | 2280 { |
2281 RawMachineAssemblerTester<void> m; | 2281 RawMachineAssemblerTester<void> m; |
2282 const Operator* shops[] = {m.machine()->Word32Sar(), | 2282 const Operator* shops[] = {m.machine()->Word32Sar(), |
2283 m.machine()->Word32Shl(), | 2283 m.machine()->Word32Shl(), |
2284 m.machine()->Word32Shr()}; | 2284 m.machine()->Word32Shr()}; |
2285 for (size_t n = 0; n < arraysize(shops); n++) { | 2285 for (size_t n = 0; n < arraysize(shops); n++) { |
2286 RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32, | 2286 RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32, |
2287 kMachUint32); | 2287 kMachUint32); |
2288 MLabel blocka, blockb; | 2288 MLabel blocka, blockb; |
2289 m.Branch(m.Word32Equal(m.Word32Or(m.Parameter(0), | 2289 m.Branch(m.Word32Equal(m.Word32Or(m.Parameter(0), |
2290 m.NewNode(shops[n], m.Parameter(1), | 2290 m.AddNode(shops[n], m.Parameter(1), |
2291 m.Parameter(2))), | 2291 m.Parameter(2))), |
2292 m.Int32Constant(0)), | 2292 m.Int32Constant(0)), |
2293 &blocka, &blockb); | 2293 &blocka, &blockb); |
2294 m.Bind(&blocka); | 2294 m.Bind(&blocka); |
2295 m.Return(m.Int32Constant(constant)); | 2295 m.Return(m.Int32Constant(constant)); |
2296 m.Bind(&blockb); | 2296 m.Bind(&blockb); |
2297 m.Return(m.Int32Constant(0 - constant)); | 2297 m.Return(m.Int32Constant(0 - constant)); |
2298 FOR_UINT32_INPUTS(i) { | 2298 FOR_UINT32_INPUTS(i) { |
2299 FOR_INT32_INPUTS(j) { | 2299 FOR_INT32_INPUTS(j) { |
2300 FOR_UINT32_SHIFTS(shift) { | 2300 FOR_UINT32_SHIFTS(shift) { |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2505 { | 2505 { |
2506 RawMachineAssemblerTester<void> m; | 2506 RawMachineAssemblerTester<void> m; |
2507 const Operator* shops[] = {m.machine()->Word32Sar(), | 2507 const Operator* shops[] = {m.machine()->Word32Sar(), |
2508 m.machine()->Word32Shl(), | 2508 m.machine()->Word32Shl(), |
2509 m.machine()->Word32Shr()}; | 2509 m.machine()->Word32Shr()}; |
2510 for (size_t n = 0; n < arraysize(shops); n++) { | 2510 for (size_t n = 0; n < arraysize(shops); n++) { |
2511 RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32, | 2511 RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32, |
2512 kMachUint32); | 2512 kMachUint32); |
2513 MLabel blocka, blockb; | 2513 MLabel blocka, blockb; |
2514 m.Branch(m.Word32Equal(m.Word32Xor(m.Parameter(0), | 2514 m.Branch(m.Word32Equal(m.Word32Xor(m.Parameter(0), |
2515 m.NewNode(shops[n], m.Parameter(1), | 2515 m.AddNode(shops[n], m.Parameter(1), |
2516 m.Parameter(2))), | 2516 m.Parameter(2))), |
2517 m.Int32Constant(0)), | 2517 m.Int32Constant(0)), |
2518 &blocka, &blockb); | 2518 &blocka, &blockb); |
2519 m.Bind(&blocka); | 2519 m.Bind(&blocka); |
2520 m.Return(m.Int32Constant(constant)); | 2520 m.Return(m.Int32Constant(constant)); |
2521 m.Bind(&blockb); | 2521 m.Bind(&blockb); |
2522 m.Return(m.Int32Constant(0 - constant)); | 2522 m.Return(m.Int32Constant(0 - constant)); |
2523 FOR_UINT32_INPUTS(i) { | 2523 FOR_UINT32_INPUTS(i) { |
2524 FOR_INT32_INPUTS(j) { | 2524 FOR_INT32_INPUTS(j) { |
2525 FOR_UINT32_SHIFTS(shift) { | 2525 FOR_UINT32_SHIFTS(shift) { |
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3015 m.machine()->Int32Mul(), m.machine()->Int32MulHigh(), | 3015 m.machine()->Int32Mul(), m.machine()->Int32MulHigh(), |
3016 m.machine()->Int32Div(), m.machine()->Uint32Div(), | 3016 m.machine()->Int32Div(), m.machine()->Uint32Div(), |
3017 m.machine()->Int32Mod(), m.machine()->Uint32Mod(), | 3017 m.machine()->Int32Mod(), m.machine()->Uint32Mod(), |
3018 m.machine()->Uint32MulHigh(), m.machine()->Int32LessThan(), | 3018 m.machine()->Uint32MulHigh(), m.machine()->Int32LessThan(), |
3019 m.machine()->Int32LessThanOrEqual(), m.machine()->Uint32LessThan(), | 3019 m.machine()->Int32LessThanOrEqual(), m.machine()->Uint32LessThan(), |
3020 m.machine()->Uint32LessThanOrEqual()}; | 3020 m.machine()->Uint32LessThanOrEqual()}; |
3021 | 3021 |
3022 for (size_t i = 0; i < arraysize(kOps); ++i) { | 3022 for (size_t i = 0; i < arraysize(kOps); ++i) { |
3023 RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachInt32); | 3023 RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachInt32); |
3024 int32_t constant = static_cast<int32_t>(0x55555 + i); | 3024 int32_t constant = static_cast<int32_t>(0x55555 + i); |
3025 m.NewNode(kOps[i], m.Parameter(0), m.Parameter(1)); | 3025 m.AddNode(kOps[i], m.Parameter(0), m.Parameter(1)); |
3026 m.Return(m.Int32Constant(constant)); | 3026 m.Return(m.Int32Constant(constant)); |
3027 | 3027 |
3028 CHECK_EQ(constant, m.Call(1, 1)); | 3028 CHECK_EQ(constant, m.Call(1, 1)); |
3029 } | 3029 } |
3030 } | 3030 } |
3031 | 3031 |
3032 | 3032 |
3033 template <typename Type> | 3033 template <typename Type> |
3034 static void RunLoadImmIndex(MachineType rep) { | 3034 static void RunLoadImmIndex(MachineType rep) { |
3035 const int kNumElems = 3; | 3035 const int kNumElems = 3; |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3130 m.common()->Float32Constant(-1.0f), m.common()->Float32Constant(0.0f), | 3130 m.common()->Float32Constant(-1.0f), m.common()->Float32Constant(0.0f), |
3131 m.common()->Float32Constant(0.22f), m.common()->Float32Constant(-1.22f), | 3131 m.common()->Float32Constant(0.22f), m.common()->Float32Constant(-1.22f), |
3132 m.common()->Float32Constant(-1.22f), m.common()->Float32Constant(0.22f), | 3132 m.common()->Float32Constant(-1.22f), m.common()->Float32Constant(0.22f), |
3133 m.common()->Float32Constant(inf), m.common()->Float32Constant(0.22f), | 3133 m.common()->Float32Constant(inf), m.common()->Float32Constant(0.22f), |
3134 m.common()->Float32Constant(inf), m.common()->Float32Constant(-inf), | 3134 m.common()->Float32Constant(inf), m.common()->Float32Constant(-inf), |
3135 NULL}; | 3135 NULL}; |
3136 | 3136 |
3137 for (int i = 0; ops[i] != NULL; i++) { | 3137 for (int i = 0; ops[i] != NULL; i++) { |
3138 for (int j = 0; inputs[j] != NULL; j += 2) { | 3138 for (int j = 0; inputs[j] != NULL; j += 2) { |
3139 RawMachineAssemblerTester<int32_t> m; | 3139 RawMachineAssemblerTester<int32_t> m; |
3140 Node* a = m.NewNode(inputs[j]); | 3140 Node* a = m.AddNode(inputs[j]); |
3141 Node* b = m.NewNode(inputs[j + 1]); | 3141 Node* b = m.AddNode(inputs[j + 1]); |
3142 Node* binop = m.NewNode(ops[i], a, b); | 3142 Node* binop = m.AddNode(ops[i], a, b); |
3143 Node* base = m.PointerConstant(&result); | 3143 Node* base = m.PointerConstant(&result); |
3144 Node* zero = m.IntPtrConstant(0); | 3144 Node* zero = m.IntPtrConstant(0); |
3145 m.Store(kMachFloat32, base, zero, binop); | 3145 m.Store(kMachFloat32, base, zero, binop); |
3146 m.Return(m.Int32Constant(i + j)); | 3146 m.Return(m.Int32Constant(i + j)); |
3147 CHECK_EQ(i + j, m.Call()); | 3147 CHECK_EQ(i + j, m.Call()); |
3148 } | 3148 } |
3149 } | 3149 } |
3150 } | 3150 } |
3151 | 3151 |
3152 | 3152 |
(...skipping 13 matching lines...) Expand all Loading... |
3166 m.common()->Float64Constant(-1), m.common()->Float64Constant(0), | 3166 m.common()->Float64Constant(-1), m.common()->Float64Constant(0), |
3167 m.common()->Float64Constant(0.22), m.common()->Float64Constant(-1.22), | 3167 m.common()->Float64Constant(0.22), m.common()->Float64Constant(-1.22), |
3168 m.common()->Float64Constant(-1.22), m.common()->Float64Constant(0.22), | 3168 m.common()->Float64Constant(-1.22), m.common()->Float64Constant(0.22), |
3169 m.common()->Float64Constant(inf), m.common()->Float64Constant(0.22), | 3169 m.common()->Float64Constant(inf), m.common()->Float64Constant(0.22), |
3170 m.common()->Float64Constant(inf), m.common()->Float64Constant(-inf), | 3170 m.common()->Float64Constant(inf), m.common()->Float64Constant(-inf), |
3171 NULL}; | 3171 NULL}; |
3172 | 3172 |
3173 for (int i = 0; ops[i] != NULL; i++) { | 3173 for (int i = 0; ops[i] != NULL; i++) { |
3174 for (int j = 0; inputs[j] != NULL; j += 2) { | 3174 for (int j = 0; inputs[j] != NULL; j += 2) { |
3175 RawMachineAssemblerTester<int32_t> m; | 3175 RawMachineAssemblerTester<int32_t> m; |
3176 Node* a = m.NewNode(inputs[j]); | 3176 Node* a = m.AddNode(inputs[j]); |
3177 Node* b = m.NewNode(inputs[j + 1]); | 3177 Node* b = m.AddNode(inputs[j + 1]); |
3178 Node* binop = m.NewNode(ops[i], a, b); | 3178 Node* binop = m.AddNode(ops[i], a, b); |
3179 Node* base = m.PointerConstant(&result); | 3179 Node* base = m.PointerConstant(&result); |
3180 Node* zero = m.Int32Constant(0); | 3180 Node* zero = m.Int32Constant(0); |
3181 m.Store(kMachFloat64, base, zero, binop); | 3181 m.Store(kMachFloat64, base, zero, binop); |
3182 m.Return(m.Int32Constant(i + j)); | 3182 m.Return(m.Int32Constant(i + j)); |
3183 CHECK_EQ(i + j, m.Call()); | 3183 CHECK_EQ(i + j, m.Call()); |
3184 } | 3184 } |
3185 } | 3185 } |
3186 } | 3186 } |
3187 | 3187 |
3188 | 3188 |
3189 TEST(RunDeadFloat32Binops) { | 3189 TEST(RunDeadFloat32Binops) { |
3190 RawMachineAssemblerTester<int32_t> m; | 3190 RawMachineAssemblerTester<int32_t> m; |
3191 | 3191 |
3192 const Operator* ops[] = {m.machine()->Float32Add(), m.machine()->Float32Sub(), | 3192 const Operator* ops[] = {m.machine()->Float32Add(), m.machine()->Float32Sub(), |
3193 m.machine()->Float32Mul(), m.machine()->Float32Div(), | 3193 m.machine()->Float32Mul(), m.machine()->Float32Div(), |
3194 NULL}; | 3194 NULL}; |
3195 | 3195 |
3196 for (int i = 0; ops[i] != NULL; i++) { | 3196 for (int i = 0; ops[i] != NULL; i++) { |
3197 RawMachineAssemblerTester<int32_t> m; | 3197 RawMachineAssemblerTester<int32_t> m; |
3198 int constant = 0x53355 + i; | 3198 int constant = 0x53355 + i; |
3199 m.NewNode(ops[i], m.Float32Constant(0.1f), m.Float32Constant(1.11f)); | 3199 m.AddNode(ops[i], m.Float32Constant(0.1f), m.Float32Constant(1.11f)); |
3200 m.Return(m.Int32Constant(constant)); | 3200 m.Return(m.Int32Constant(constant)); |
3201 CHECK_EQ(constant, m.Call()); | 3201 CHECK_EQ(constant, m.Call()); |
3202 } | 3202 } |
3203 } | 3203 } |
3204 | 3204 |
3205 | 3205 |
3206 TEST(RunDeadFloat64Binops) { | 3206 TEST(RunDeadFloat64Binops) { |
3207 RawMachineAssemblerTester<int32_t> m; | 3207 RawMachineAssemblerTester<int32_t> m; |
3208 | 3208 |
3209 const Operator* ops[] = {m.machine()->Float64Add(), m.machine()->Float64Sub(), | 3209 const Operator* ops[] = {m.machine()->Float64Add(), m.machine()->Float64Sub(), |
3210 m.machine()->Float64Mul(), m.machine()->Float64Div(), | 3210 m.machine()->Float64Mul(), m.machine()->Float64Div(), |
3211 m.machine()->Float64Mod(), NULL}; | 3211 m.machine()->Float64Mod(), NULL}; |
3212 | 3212 |
3213 for (int i = 0; ops[i] != NULL; i++) { | 3213 for (int i = 0; ops[i] != NULL; i++) { |
3214 RawMachineAssemblerTester<int32_t> m; | 3214 RawMachineAssemblerTester<int32_t> m; |
3215 int constant = 0x53355 + i; | 3215 int constant = 0x53355 + i; |
3216 m.NewNode(ops[i], m.Float64Constant(0.1), m.Float64Constant(1.11)); | 3216 m.AddNode(ops[i], m.Float64Constant(0.1), m.Float64Constant(1.11)); |
3217 m.Return(m.Int32Constant(constant)); | 3217 m.Return(m.Int32Constant(constant)); |
3218 CHECK_EQ(constant, m.Call()); | 3218 CHECK_EQ(constant, m.Call()); |
3219 } | 3219 } |
3220 } | 3220 } |
3221 | 3221 |
3222 | 3222 |
3223 TEST(RunFloat32AddP) { | 3223 TEST(RunFloat32AddP) { |
3224 RawMachineAssemblerTester<int32_t> m; | 3224 RawMachineAssemblerTester<int32_t> m; |
3225 Float32BinopTester bt(&m); | 3225 Float32BinopTester bt(&m); |
3226 | 3226 |
(...skipping 1055 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4282 | 4282 |
4283 double nan = std::numeric_limits<double>::quiet_NaN(); | 4283 double nan = std::numeric_limits<double>::quiet_NaN(); |
4284 | 4284 |
4285 FOR_FLOAT64_INPUTS(i) { | 4285 FOR_FLOAT64_INPUTS(i) { |
4286 for (size_t o = 0; o < arraysize(operators); ++o) { | 4286 for (size_t o = 0; o < arraysize(operators); ++o) { |
4287 for (int j = 0; j < 2; j++) { | 4287 for (int j = 0; j < 2; j++) { |
4288 RawMachineAssemblerTester<int32_t> m; | 4288 RawMachineAssemblerTester<int32_t> m; |
4289 Node* a = m.Float64Constant(*i); | 4289 Node* a = m.Float64Constant(*i); |
4290 Node* b = m.Float64Constant(nan); | 4290 Node* b = m.Float64Constant(nan); |
4291 if (j == 1) std::swap(a, b); | 4291 if (j == 1) std::swap(a, b); |
4292 m.Return(m.NewNode(operators[o], a, b)); | 4292 m.Return(m.AddNode(operators[o], a, b)); |
4293 CHECK_EQ(0, m.Call()); | 4293 CHECK_EQ(0, m.Call()); |
4294 } | 4294 } |
4295 } | 4295 } |
4296 } | 4296 } |
4297 } | 4297 } |
4298 | 4298 |
4299 | 4299 |
4300 TEST(RunFloat64Equal) { | 4300 TEST(RunFloat64Equal) { |
4301 double input_a = 0.0; | 4301 double input_a = 0.0; |
4302 double input_b = 0.0; | 4302 double input_b = 0.0; |
(...skipping 977 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5280 #endif // USE_SIMULATOR | 5280 #endif // USE_SIMULATOR |
5281 | 5281 |
5282 #if V8_TARGET_ARCH_64_BIT | 5282 #if V8_TARGET_ARCH_64_BIT |
5283 TEST(RunCheckedLoadInt64) { | 5283 TEST(RunCheckedLoadInt64) { |
5284 int64_t buffer[] = {0x66bbccddeeff0011LL, 0x1122334455667788LL}; | 5284 int64_t buffer[] = {0x66bbccddeeff0011LL, 0x1122334455667788LL}; |
5285 RawMachineAssemblerTester<int64_t> m(kMachInt32); | 5285 RawMachineAssemblerTester<int64_t> m(kMachInt32); |
5286 Node* base = m.PointerConstant(buffer); | 5286 Node* base = m.PointerConstant(buffer); |
5287 Node* index = m.Parameter(0); | 5287 Node* index = m.Parameter(0); |
5288 Node* length = m.Int32Constant(16); | 5288 Node* length = m.Int32Constant(16); |
5289 Node* load = | 5289 Node* load = |
5290 m.NewNode(m.machine()->CheckedLoad(kMachInt64), base, index, length); | 5290 m.AddNode(m.machine()->CheckedLoad(kMachInt64), base, index, length); |
5291 m.Return(load); | 5291 m.Return(load); |
5292 | 5292 |
5293 CHECK_EQ(buffer[0], m.Call(0)); | 5293 CHECK_EQ(buffer[0], m.Call(0)); |
5294 CHECK_EQ(buffer[1], m.Call(8)); | 5294 CHECK_EQ(buffer[1], m.Call(8)); |
5295 CHECK_EQ(0, m.Call(16)); | 5295 CHECK_EQ(0, m.Call(16)); |
5296 } | 5296 } |
5297 | 5297 |
5298 | 5298 |
5299 TEST(RunCheckedStoreInt64) { | 5299 TEST(RunCheckedStoreInt64) { |
5300 const int64_t write = 0x5566778899aabbLL; | 5300 const int64_t write = 0x5566778899aabbLL; |
5301 const int64_t before = 0x33bbccddeeff0011LL; | 5301 const int64_t before = 0x33bbccddeeff0011LL; |
5302 int64_t buffer[] = {before, before}; | 5302 int64_t buffer[] = {before, before}; |
5303 RawMachineAssemblerTester<int32_t> m(kMachInt32); | 5303 RawMachineAssemblerTester<int32_t> m(kMachInt32); |
5304 Node* base = m.PointerConstant(buffer); | 5304 Node* base = m.PointerConstant(buffer); |
5305 Node* index = m.Parameter(0); | 5305 Node* index = m.Parameter(0); |
5306 Node* length = m.Int32Constant(16); | 5306 Node* length = m.Int32Constant(16); |
5307 Node* value = m.Int64Constant(write); | 5307 Node* value = m.Int64Constant(write); |
5308 Node* store = m.NewNode(m.machine()->CheckedStore(kMachInt64), base, index, | 5308 Node* store = m.AddNode(m.machine()->CheckedStore(kMachInt64), base, index, |
5309 length, value); | 5309 length, value); |
5310 USE(store); | 5310 USE(store); |
5311 m.Return(m.Int32Constant(11)); | 5311 m.Return(m.Int32Constant(11)); |
5312 | 5312 |
5313 CHECK_EQ(11, m.Call(16)); | 5313 CHECK_EQ(11, m.Call(16)); |
5314 CHECK_EQ(before, buffer[0]); | 5314 CHECK_EQ(before, buffer[0]); |
5315 CHECK_EQ(before, buffer[1]); | 5315 CHECK_EQ(before, buffer[1]); |
5316 | 5316 |
5317 CHECK_EQ(11, m.Call(0)); | 5317 CHECK_EQ(11, m.Call(0)); |
5318 CHECK_EQ(write, buffer[0]); | 5318 CHECK_EQ(write, buffer[0]); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5381 &output, kMachFloat32, | 5381 &output, kMachFloat32, |
5382 m.BitcastInt32ToFloat32(m.LoadFromPointer(&input, kMachInt32))); | 5382 m.BitcastInt32ToFloat32(m.LoadFromPointer(&input, kMachInt32))); |
5383 m.Return(m.Int32Constant(11)); | 5383 m.Return(m.Int32Constant(11)); |
5384 FOR_INT32_INPUTS(i) { | 5384 FOR_INT32_INPUTS(i) { |
5385 input = *i; | 5385 input = *i; |
5386 CHECK_EQ(11, m.Call()); | 5386 CHECK_EQ(11, m.Call()); |
5387 float expected = bit_cast<float>(input); | 5387 float expected = bit_cast<float>(input); |
5388 CHECK_EQ(bit_cast<int32_t>(expected), bit_cast<int32_t>(output)); | 5388 CHECK_EQ(bit_cast<int32_t>(expected), bit_cast<int32_t>(output)); |
5389 } | 5389 } |
5390 } | 5390 } |
OLD | NEW |