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 // TODO(jochen): Remove this after the setting is turned on globally. | 5 // TODO(jochen): Remove this after the setting is turned on globally. |
6 #define V8_IMMINENT_DEPRECATION_WARNINGS | 6 #define V8_IMMINENT_DEPRECATION_WARNINGS |
7 | 7 |
8 #include <limits> | 8 #include <limits> |
9 | 9 |
10 #include "src/compiler/access-builder.h" | 10 #include "src/compiler/access-builder.h" |
(...skipping 1587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1598 t.LowerAllNodesAndLowerChanges(); | 1598 t.LowerAllNodesAndLowerChanges(); |
1599 t.GenerateCode(); | 1599 t.GenerateCode(); |
1600 | 1600 |
1601 FOR_INT32_INPUTS(i) { | 1601 FOR_INT32_INPUTS(i) { |
1602 int32_t x = 0 - *i; | 1602 int32_t x = 0 - *i; |
1603 t.CheckNumberCall(static_cast<double>(x), static_cast<double>(*i)); | 1603 t.CheckNumberCall(static_cast<double>(x), static_cast<double>(*i)); |
1604 } | 1604 } |
1605 } | 1605 } |
1606 | 1606 |
1607 | 1607 |
1608 TEST(NumberMultiply_TruncatingToInt32) { | |
1609 int32_t constants[] = {-100, -10, -1, 0, 1, 100, 1000}; | |
1610 | |
1611 for (size_t i = 0; i < arraysize(constants); i++) { | |
1612 TestingGraph t(Type::Signed32()); | |
1613 Node* k = t.jsgraph.Constant(constants[i]); | |
1614 Node* mul = t.graph()->NewNode(t.simplified()->NumberMultiply(), t.p0, k); | |
1615 Node* trunc = t.graph()->NewNode(t.simplified()->NumberToInt32(), mul); | |
1616 t.Return(trunc); | |
1617 t.Lower(); | |
1618 | |
1619 CHECK_EQ(IrOpcode::kInt32Mul, mul->opcode()); | |
1620 } | |
1621 } | |
1622 | |
1623 | |
1624 TEST(RunNumberMultiply_TruncatingToInt32) { | 1608 TEST(RunNumberMultiply_TruncatingToInt32) { |
1625 int32_t constants[] = {-100, -10, -1, 0, 1, 100, 1000, 3000999}; | 1609 int32_t constants[] = {-100, -10, -1, 0, 1, 100, 1000, 3000999}; |
1626 | 1610 |
1627 for (size_t i = 0; i < arraysize(constants); i++) { | 1611 for (size_t i = 0; i < arraysize(constants); i++) { |
1628 double k = static_cast<double>(constants[i]); | 1612 double k = static_cast<double>(constants[i]); |
1629 SimplifiedLoweringTester<Object*> t(kMachAnyTagged); | 1613 SimplifiedLoweringTester<Object*> t(kMachAnyTagged); |
1630 Node* num = t.NumberToInt32(t.Parameter(0)); | 1614 Node* num = t.NumberToInt32(t.Parameter(0)); |
1631 Node* mul = t.NumberMultiply(num, t.jsgraph.Constant(k)); | 1615 Node* mul = t.NumberMultiply(num, t.jsgraph.Constant(k)); |
1632 Node* trunc = t.NumberToInt32(mul); | 1616 Node* trunc = t.NumberToInt32(mul); |
1633 t.Return(trunc); | 1617 t.Return(trunc); |
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1970 t.Return(use); | 1954 t.Return(use); |
1971 t.Lower(); | 1955 t.Lower(); |
1972 | 1956 |
1973 CHECK_EQ(d.expected, OpParameter<MachineType>(phi)); | 1957 CHECK_EQ(d.expected, OpParameter<MachineType>(phi)); |
1974 } | 1958 } |
1975 } | 1959 } |
1976 | 1960 |
1977 } // namespace compiler | 1961 } // namespace compiler |
1978 } // namespace internal | 1962 } // namespace internal |
1979 } // namespace v8 | 1963 } // namespace v8 |
OLD | NEW |