| Index: test/unittests/compiler/typer-unittest.cc
|
| diff --git a/test/unittests/compiler/typer-unittest.cc b/test/unittests/compiler/typer-unittest.cc
|
| index f977c6fddd4d26a7d6928cee22ce734e5b9fb67e..a8398bb911c375b8892ccf1cb402c9bea197dd13 100644
|
| --- a/test/unittests/compiler/typer-unittest.cc
|
| +++ b/test/unittests/compiler/typer-unittest.cc
|
| @@ -146,6 +146,37 @@ class TyperTest : public TypedGraphTest {
|
| }
|
| }
|
|
|
| + // Careful, this function scales poorly.
|
| + template <class BinaryFunction>
|
| + void TestPreciseBinaryArithOp(const Operator* op, BinaryFunction opfun,
|
| + int32_t llow, int32_t lhigh, int32_t linc,
|
| + int32_t rlow, int32_t rhigh, int32_t rinc) {
|
| + for (int64_t lmin = llow; lmin <= lhigh; lmin += linc) {
|
| + for (int64_t lmax = lmin; lmax <= lhigh; lmax += linc) {
|
| + for (int64_t rmin = rlow; rmin <= rhigh; rmin += rinc) {
|
| + for (int64_t rmax = rmin; rmax <= rhigh; rmax += rinc) {
|
| + Type* r1 = NewRange(lmin, lmax);
|
| + Type* r2 = NewRange(rmin, rmax);
|
| + Type* derived_type = TypeBinaryOp(op, r1, r2);
|
| +
|
| + double min = +V8_INFINITY, max = -V8_INFINITY;
|
| + for (int64_t x1 = lmin; x1 <= lmax; x1++) {
|
| + for (int64_t x2 = rmin; x2 <= rmax; x2++) {
|
| + double result_value = opfun(int32_t(x1), int32_t(x2));
|
| + if (result_value < min) min = result_value;
|
| + if (result_value > max) max = result_value;
|
| + }
|
| + }
|
| + Type* expected_type = NewRange(min, max);
|
| +
|
| + EXPECT_TRUE(derived_type->Is(expected_type));
|
| + EXPECT_TRUE(expected_type->Is(derived_type));
|
| + }
|
| + }
|
| + }
|
| + }
|
| + }
|
| +
|
| template <class BinaryFunction>
|
| void TestBinaryCompareOp(const Operator* op, BinaryFunction opfun) {
|
| for (int i = 0; i < 100; ++i) {
|
| @@ -287,6 +318,14 @@ TEST_F(TyperTest, TypeJSShiftLeft) {
|
| TEST_F(TyperTest, TypeJSShiftRight) {
|
| TestBinaryBitOp(javascript_.ShiftRight(LanguageMode::SLOPPY), shift_right);
|
| TestBinaryBitOp(javascript_.ShiftRight(LanguageMode::STRONG), shift_right);
|
| + TestPreciseBinaryArithOp(javascript_.ShiftRight(LanguageMode::SLOPPY),
|
| + shift_right, -16, 15, 1, 0, 31, 1);
|
| + TestPreciseBinaryArithOp(javascript_.ShiftRight(LanguageMode::STRONG),
|
| + shift_right, -16, 15, 1, 0, 31, 1);
|
| + TestPreciseBinaryArithOp(javascript_.ShiftRight(LanguageMode::SLOPPY),
|
| + shift_right, -8, 7, 1, -64, 63, 1);
|
| + TestPreciseBinaryArithOp(javascript_.ShiftRight(LanguageMode::STRONG),
|
| + shift_right, -8, 7, 1, -64, 63, 1);
|
| }
|
|
|
|
|
|
|