typer-unittest.cc 20 KB
Newer Older
1
// Copyright 2015 the V8 project authors. All rights reserved.
2 3 4 5 6
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include <functional>

7
#include "src/base/overflowing-math.h"
8
#include "src/compiler/js-operator.h"
9
#include "src/compiler/node-properties.h"
10
#include "src/compiler/operator-properties.h"
11
#include "src/compiler/simplified-operator.h"
12
#include "src/objects/objects-inl.h"
13
#include "test/common/types-fuzz.h"
14
#include "test/unittests/compiler/graph-unittest.h"
15

16 17 18
namespace v8 {
namespace internal {
namespace compiler {
19

20
// TODO(titzer): generate a large set of deterministic inputs for these tests.
21
class TyperTest : public TypedGraphTest {
22
 public:
23 24
  TyperTest()
      : TypedGraphTest(3),
25
        broker_(isolate(), zone(), FLAG_trace_heap_broker),
26
        operation_typer_(&broker_, zone()),
27
        types_(zone(), isolate(), random_number_generator()),
28 29
        javascript_(zone()),
        simplified_(zone()) {
30
    context_node_ = graph()->NewNode(common()->Parameter(2), graph()->start());
31
    rng_ = random_number_generator();
32 33 34 35 36

    integers.push_back(0);
    integers.push_back(0);
    integers.push_back(-1);
    integers.push_back(+1);
37 38
    integers.push_back(-V8_INFINITY);
    integers.push_back(+V8_INFINITY);
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
    for (int i = 0; i < 5; ++i) {
      double x = rng_->NextInt();
      integers.push_back(x);
      x *= rng_->NextInt();
      if (!IsMinusZero(x)) integers.push_back(x);
    }

    int32s.push_back(0);
    int32s.push_back(0);
    int32s.push_back(-1);
    int32s.push_back(+1);
    int32s.push_back(kMinInt);
    int32s.push_back(kMaxInt);
    for (int i = 0; i < 10; ++i) {
      int32s.push_back(rng_->NextInt());
    }
  }

57 58
  const int kRepetitions = 50;

59
  JSHeapBroker broker_;
60
  OperationTyper operation_typer_;
61
  Types types_;
62
  JSOperatorBuilder javascript_;
63
  SimplifiedOperatorBuilder simplified_;
64
  BinaryOperationHint const hints_ = BinaryOperationHint::kAny;
65 66 67 68 69
  Node* context_node_;
  v8::base::RandomNumberGenerator* rng_;
  std::vector<double> integers;
  std::vector<double> int32s;

70
  Type TypeUnaryOp(const Operator* op, Type type0) {
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
    Node* p0 = Parameter(0);
    NodeProperties::SetType(p0, type0);
    std::vector<Node*> inputs;
    inputs.push_back(p0);
    if (OperatorProperties::HasContextInput(op)) {
      inputs.push_back(context_node_);
    }
    for (int i = 0; i < OperatorProperties::GetFrameStateInputCount(op); i++) {
      inputs.push_back(EmptyFrameState());
    }
    for (int i = 0; i < op->EffectInputCount(); i++) {
      inputs.push_back(graph()->start());
    }
    for (int i = 0; i < op->ControlInputCount(); i++) {
      inputs.push_back(graph()->start());
    }
    Node* n = graph()->NewNode(op, static_cast<int>(inputs.size()),
                               &(inputs.front()));
    return NodeProperties::GetType(n);
  }

92
  Type TypeBinaryOp(const Operator* op, Type lhs, Type rhs) {
93 94
    Node* p0 = Parameter(0);
    Node* p1 = Parameter(1);
95 96
    NodeProperties::SetType(p0, lhs);
    NodeProperties::SetType(p1, rhs);
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
    std::vector<Node*> inputs;
    inputs.push_back(p0);
    inputs.push_back(p1);
    if (OperatorProperties::HasContextInput(op)) {
      inputs.push_back(context_node_);
    }
    for (int i = 0; i < OperatorProperties::GetFrameStateInputCount(op); i++) {
      inputs.push_back(EmptyFrameState());
    }
    for (int i = 0; i < op->EffectInputCount(); i++) {
      inputs.push_back(graph()->start());
    }
    for (int i = 0; i < op->ControlInputCount(); i++) {
      inputs.push_back(graph()->start());
    }
    Node* n = graph()->NewNode(op, static_cast<int>(inputs.size()),
                               &(inputs.front()));
114
    return NodeProperties::GetType(n);
115 116
  }

117
  Type RandomRange(bool int32 = false) {
118
    std::vector<double>& numbers = int32 ? int32s : integers;
119 120 121 122 123
    double i = numbers[rng_->NextInt(static_cast<int>(numbers.size()))];
    double j = numbers[rng_->NextInt(static_cast<int>(numbers.size()))];
    return NewRange(i, j);
  }

124
  Type NewRange(double i, double j) {
125
    if (i > j) std::swap(i, j);
126
    return Type::Range(i, j, zone());
127 128 129 130
  }

  double RandomInt(double min, double max) {
    switch (rng_->NextInt(4)) {
131 132 133 134 135 136
      case 0:
        return min;
      case 1:
        return max;
      default:
        break;
137
    }
138 139 140
    if (min == +V8_INFINITY) return +V8_INFINITY;
    if (max == -V8_INFINITY) return -V8_INFINITY;
    if (min == -V8_INFINITY && max == +V8_INFINITY) {
141 142 143 144 145 146 147 148 149
      return rng_->NextInt() * static_cast<double>(rng_->NextInt());
    }
    double result = nearbyint(min + (max - min) * rng_->NextDouble());
    if (IsMinusZero(result)) return 0;
    if (std::isnan(result)) return rng_->NextInt(2) ? min : max;
    DCHECK(min <= result && result <= max);
    return result;
  }

150
  double RandomInt(const RangeType* range) {
151
    return RandomInt(range->Min(), range->Max());
152 153
  }

154 155
  Type RandomSubtype(Type type) {
    Type subtype;
156 157
    do {
      subtype = types_.Fuzz();
158
    } while (!subtype.Is(type));
159 160 161
    return subtype;
  }

162 163 164 165 166 167 168 169 170
  // Careful, this function runs O(max_width^5) trials.
  template <class BinaryFunction>
  void TestBinaryArithOpCloseToZero(const Operator* op, BinaryFunction opfun,
                                    int max_width) {
    const int min_min = -2 - max_width / 2;
    const int max_min = 2 + max_width / 2;
    for (int width = 0; width < max_width; width++) {
      for (int lmin = min_min; lmin <= max_min; lmin++) {
        for (int rmin = min_min; rmin <= max_min; rmin++) {
171 172 173
          Type r1 = NewRange(lmin, lmin + width);
          Type r2 = NewRange(rmin, rmin + width);
          Type expected_type = TypeBinaryOp(op, r1, r2);
174 175 176 177

          for (int x1 = lmin; x1 < lmin + width; x1++) {
            for (int x2 = rmin; x2 < rmin + width; x2++) {
              double result_value = opfun(x1, x2);
178
              Type result_type = Type::NewConstant(
179 180
                  &broker_, isolate()->factory()->NewNumber(result_value),
                  zone());
181
              EXPECT_TRUE(result_type.Is(expected_type));
182 183 184 185 186 187 188
            }
          }
        }
      }
    }
  }

189 190
  template <class BinaryFunction>
  void TestBinaryArithOp(const Operator* op, BinaryFunction opfun) {
191
    TestBinaryArithOpCloseToZero(op, opfun, 8);
192
    for (int i = 0; i < 100; ++i) {
193 194 195
      Type r1 = RandomRange();
      Type r2 = RandomRange();
      Type expected_type = TypeBinaryOp(op, r1, r2);
196
      for (int i = 0; i < 10; i++) {
197 198
        double x1 = RandomInt(r1.AsRange());
        double x2 = RandomInt(r2.AsRange());
199
        double result_value = opfun(x1, x2);
200
        Type result_type = Type::NewConstant(
201
            &broker_, isolate()->factory()->NewNumber(result_value), zone());
202
        EXPECT_TRUE(result_type.Is(expected_type));
203
      }
204
    }
205 206 207
    // Test extreme cases.
    double x1 = +1e-308;
    double x2 = -1e-308;
208 209 210 211
    Type r1 = Type::NewConstant(&broker_, isolate()->factory()->NewNumber(x1),
                                zone());
    Type r2 = Type::NewConstant(&broker_, isolate()->factory()->NewNumber(x2),
                                zone());
212
    Type expected_type = TypeBinaryOp(op, r1, r2);
213
    double result_value = opfun(x1, x2);
214
    Type result_type = Type::NewConstant(
215
        &broker_, isolate()->factory()->NewNumber(result_value), zone());
216
    EXPECT_TRUE(result_type.Is(expected_type));
217 218 219 220 221
  }

  template <class BinaryFunction>
  void TestBinaryCompareOp(const Operator* op, BinaryFunction opfun) {
    for (int i = 0; i < 100; ++i) {
222 223 224
      Type r1 = RandomRange();
      Type r2 = RandomRange();
      Type expected_type = TypeBinaryOp(op, r1, r2);
225
      for (int i = 0; i < 10; i++) {
226 227
        double x1 = RandomInt(r1.AsRange());
        double x2 = RandomInt(r2.AsRange());
228
        bool result_value = opfun(x1, x2);
229
        Type result_type = Type::NewConstant(
230
            &broker_,
231 232 233
            result_value ? isolate()->factory()->true_value()
                         : isolate()->factory()->false_value(),
            zone());
234
        EXPECT_TRUE(result_type.Is(expected_type));
235
      }
236 237 238 239 240 241
    }
  }

  template <class BinaryFunction>
  void TestBinaryBitOp(const Operator* op, BinaryFunction opfun) {
    for (int i = 0; i < 100; ++i) {
242 243 244
      Type r1 = RandomRange(true);
      Type r2 = RandomRange(true);
      Type expected_type = TypeBinaryOp(op, r1, r2);
245
      for (int i = 0; i < 10; i++) {
246 247
        int32_t x1 = static_cast<int32_t>(RandomInt(r1.AsRange()));
        int32_t x2 = static_cast<int32_t>(RandomInt(r2.AsRange()));
248
        double result_value = opfun(x1, x2);
249
        Type result_type = Type::NewConstant(
250
            &broker_, isolate()->factory()->NewNumber(result_value), zone());
251
        EXPECT_TRUE(result_type.Is(expected_type));
252
      }
253 254
    }
  }
255

256 257
  using UnaryTyper = std::function<Type(Type)>;
  using BinaryTyper = std::function<Type(Type, Type)>;
258

259 260
  void TestUnaryMonotonicity(UnaryTyper typer, Type upper1 = Type::Any()) {
    Type type1 = Type::Intersect(types_.Fuzz(), upper1, zone());
261
    DCHECK(type1.Is(upper1));
262
    Type type = typer(type1);
263

264 265
    Type subtype1 = RandomSubtype(type1);
    Type subtype = typer(subtype1);
266

267
    EXPECT_TRUE(subtype.Is(type));
268 269
  }

270 271 272
  void TestBinaryMonotonicity(BinaryTyper typer, Type upper1 = Type::Any(),
                              Type upper2 = Type::Any()) {
    Type type1 = Type::Intersect(types_.Fuzz(), upper1, zone());
273
    DCHECK(type1.Is(upper1));
274
    Type type2 = Type::Intersect(types_.Fuzz(), upper2, zone());
275
    DCHECK(type2.Is(upper2));
276
    Type type = typer(type1, type2);
277

278 279 280
    Type subtype1 = RandomSubtype(type1);
    Type subtype2 = RandomSubtype(type2);
    Type subtype = typer(subtype1, subtype2);
281

282
    EXPECT_TRUE(subtype.Is(type));
283 284
  }

285 286
  void TestUnaryMonotonicity(const Operator* op, Type upper1 = Type::Any()) {
    UnaryTyper typer = [&](Type type1) { return TypeUnaryOp(op, type1); };
287 288 289 290 291
    for (int i = 0; i < kRepetitions; ++i) {
      TestUnaryMonotonicity(typer, upper1);
    }
  }

292 293 294
  void TestBinaryMonotonicity(const Operator* op, Type upper1 = Type::Any(),
                              Type upper2 = Type::Any()) {
    BinaryTyper typer = [&](Type type1, Type type2) {
295 296 297 298
      return TypeBinaryOp(op, type1, type2);
    };
    for (int i = 0; i < kRepetitions; ++i) {
      TestBinaryMonotonicity(typer, upper1, upper2);
299 300
    }
  }
301 302 303
};


304 305
namespace {

306 307 308
int32_t shift_left(int32_t x, int32_t y) {
  return static_cast<uint32_t>(x) << (y & 0x1F);
}
309
int32_t shift_right(int32_t x, int32_t y) { return x >> (y & 0x1F); }
310 311 312
int32_t bit_or(int32_t x, int32_t y) { return x | y; }
int32_t bit_and(int32_t x, int32_t y) { return x & y; }
int32_t bit_xor(int32_t x, int32_t y) { return x ^ y; }
313
double divide_double_double(double x, double y) { return base::Divide(x, y); }
314
double modulo_double_double(double x, double y) { return Modulo(x, y); }
315 316

}  // namespace
317 318


319 320 321 322 323 324
//------------------------------------------------------------------------------
// Soundness
//   For simplicity, we currently only test soundness on expression operators
//   that have a direct equivalent in C++.  Also, testing is currently limited
//   to ranges as input types.

325
TEST_F(TyperTest, TypeJSAdd) {
326
  TestBinaryArithOp(javascript_.Add(hints_), std::plus<double>());
327 328
}

329
TEST_F(TyperTest, TypeJSSubtract) {
330
  TestBinaryArithOp(javascript_.Subtract(), std::minus<double>());
331 332
}

333
TEST_F(TyperTest, TypeJSMultiply) {
334
  TestBinaryArithOp(javascript_.Multiply(), std::multiplies<double>());
335 336
}

337
TEST_F(TyperTest, TypeJSDivide) {
338
  TestBinaryArithOp(javascript_.Divide(), divide_double_double);
339 340
}

341
TEST_F(TyperTest, TypeJSModulus) {
342
  TestBinaryArithOp(javascript_.Modulus(), modulo_double_double);
343 344
}

345
TEST_F(TyperTest, TypeJSBitwiseOr) {
346
  TestBinaryBitOp(javascript_.BitwiseOr(), bit_or);
347 348
}

349
TEST_F(TyperTest, TypeJSBitwiseAnd) {
350
  TestBinaryBitOp(javascript_.BitwiseAnd(), bit_and);
351 352
}

353
TEST_F(TyperTest, TypeJSBitwiseXor) {
354
  TestBinaryBitOp(javascript_.BitwiseXor(), bit_xor);
355 356
}

357
TEST_F(TyperTest, TypeJSShiftLeft) {
358
  TestBinaryBitOp(javascript_.ShiftLeft(), shift_left);
359 360
}

361
TEST_F(TyperTest, TypeJSShiftRight) {
362
  TestBinaryBitOp(javascript_.ShiftRight(), shift_right);
363 364
}

365
TEST_F(TyperTest, TypeJSLessThan) {
366
  TestBinaryCompareOp(javascript_.LessThan(CompareOperationHint::kAny),
367
                      std::less<double>());
368 369
}

370 371 372 373 374 375 376 377 378
TEST_F(TyperTest, TypeNumberLessThan) {
  TestBinaryCompareOp(simplified_.NumberLessThan(), std::less<double>());
}

TEST_F(TyperTest, TypeSpeculativeNumberLessThan) {
  TestBinaryCompareOp(simplified_.SpeculativeNumberLessThan(
                          NumberOperationHint::kNumberOrOddball),
                      std::less<double>());
}
379

380
TEST_F(TyperTest, TypeJSLessThanOrEqual) {
381
  TestBinaryCompareOp(javascript_.LessThanOrEqual(CompareOperationHint::kAny),
382
                      std::less_equal<double>());
383 384
}

385 386 387 388 389 390 391 392 393 394
TEST_F(TyperTest, TypeNumberLessThanOrEqual) {
  TestBinaryCompareOp(simplified_.NumberLessThanOrEqual(),
                      std::less_equal<double>());
}

TEST_F(TyperTest, TypeSpeculativeNumberLessThanOrEqual) {
  TestBinaryCompareOp(simplified_.SpeculativeNumberLessThanOrEqual(
                          NumberOperationHint::kNumberOrOddball),
                      std::less_equal<double>());
}
395

396
TEST_F(TyperTest, TypeJSGreaterThan) {
397
  TestBinaryCompareOp(javascript_.GreaterThan(CompareOperationHint::kAny),
398
                      std::greater<double>());
399 400 401
}


402
TEST_F(TyperTest, TypeJSGreaterThanOrEqual) {
403
  TestBinaryCompareOp(
404
      javascript_.GreaterThanOrEqual(CompareOperationHint::kAny),
405
      std::greater_equal<double>());
406 407
}

408
TEST_F(TyperTest, TypeJSEqual) {
409
  TestBinaryCompareOp(javascript_.Equal(CompareOperationHint::kAny),
410
                      std::equal_to<double>());
411 412
}

413 414 415 416 417 418 419 420 421
TEST_F(TyperTest, TypeNumberEqual) {
  TestBinaryCompareOp(simplified_.NumberEqual(), std::equal_to<double>());
}

TEST_F(TyperTest, TypeSpeculativeNumberEqual) {
  TestBinaryCompareOp(
      simplified_.SpeculativeNumberEqual(NumberOperationHint::kNumberOrOddball),
      std::equal_to<double>());
}
422 423

// For numbers there's no difference between strict and non-strict equality.
424
TEST_F(TyperTest, TypeJSStrictEqual) {
425
  TestBinaryCompareOp(javascript_.StrictEqual(CompareOperationHint::kAny),
426
                      std::equal_to<double>());
427 428
}

429
//------------------------------------------------------------------------------
430
// Typer Monotonicity
431

432 433 434 435 436 437 438 439 440 441 442 443
// JS UNOPs without hint
#define TEST_MONOTONICITY(name)                \
  TEST_F(TyperTest, Monotonicity_##name) {     \
    TestUnaryMonotonicity(javascript_.name()); \
  }
TEST_MONOTONICITY(ToLength)
TEST_MONOTONICITY(ToName)
TEST_MONOTONICITY(ToNumber)
TEST_MONOTONICITY(ToObject)
TEST_MONOTONICITY(ToString)
#undef TEST_MONOTONICITY

444 445
// JS BINOPs with CompareOperationHint
#define TEST_MONOTONICITY(name)                                           \
446 447
  TEST_F(TyperTest, Monotonicity_##name) {                                \
    TestBinaryMonotonicity(javascript_.name(CompareOperationHint::kAny)); \
448
  }
449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464
TEST_MONOTONICITY(Equal)
TEST_MONOTONICITY(StrictEqual)
TEST_MONOTONICITY(LessThan)
TEST_MONOTONICITY(GreaterThan)
TEST_MONOTONICITY(LessThanOrEqual)
TEST_MONOTONICITY(GreaterThanOrEqual)
#undef TEST_MONOTONICITY

// JS BINOPs with BinaryOperationHint
#define TEST_MONOTONICITY(name)                                          \
  TEST_F(TyperTest, Monotonicity_##name) {                               \
    TestBinaryMonotonicity(javascript_.name(BinaryOperationHint::kAny)); \
  }
TEST_MONOTONICITY(Add)
#undef TEST_MONOTONICITY

465
TEST_F(TyperTest, Monotonicity_InstanceOf) {
466
  TestBinaryMonotonicity(javascript_.InstanceOf(FeedbackSource()));
467 468
}

469 470
// JS BINOPS without hint
#define TEST_MONOTONICITY(name)                 \
471 472
  TEST_F(TyperTest, Monotonicity_##name) {      \
    TestBinaryMonotonicity(javascript_.name()); \
473
  }
474 475 476 477 478 479 480 481 482 483
TEST_MONOTONICITY(BitwiseOr)
TEST_MONOTONICITY(BitwiseXor)
TEST_MONOTONICITY(BitwiseAnd)
TEST_MONOTONICITY(ShiftLeft)
TEST_MONOTONICITY(ShiftRight)
TEST_MONOTONICITY(ShiftRightLogical)
TEST_MONOTONICITY(Subtract)
TEST_MONOTONICITY(Multiply)
TEST_MONOTONICITY(Divide)
TEST_MONOTONICITY(Modulus)
484
TEST_MONOTONICITY(OrdinaryHasInstance)
485 486
#undef TEST_MONOTONICITY

487 488 489 490 491 492 493 494 495 496 497 498 499 500
// SIMPLIFIED UNOPs without hint
#define TEST_MONOTONICITY(name)                \
  TEST_F(TyperTest, Monotonicity_##name) {     \
    TestUnaryMonotonicity(simplified_.name()); \
  }
TEST_MONOTONICITY(ObjectIsDetectableCallable)
TEST_MONOTONICITY(ObjectIsNaN)
TEST_MONOTONICITY(ObjectIsNonCallable)
TEST_MONOTONICITY(ObjectIsNumber)
TEST_MONOTONICITY(ObjectIsReceiver)
TEST_MONOTONICITY(ObjectIsSmi)
TEST_MONOTONICITY(ObjectIsString)
TEST_MONOTONICITY(ObjectIsSymbol)
TEST_MONOTONICITY(ObjectIsUndetectable)
501
TEST_MONOTONICITY(TypeOf)
502 503 504
TEST_MONOTONICITY(ToBoolean)
#undef TEST_MONOTONICITY

505 506 507 508 509 510
// SIMPLIFIED BINOPs without hint, with Number input restriction
#define TEST_MONOTONICITY(name)                                \
  TEST_F(TyperTest, Monotonicity_##name) {                     \
    TestBinaryMonotonicity(simplified_.name(), Type::Number(), \
                           Type::Number());                    \
  }
511
SIMPLIFIED_NUMBER_BINOP_LIST(TEST_MONOTONICITY)
512 513 514 515 516 517 518 519 520 521
#undef TEST_MONOTONICITY

// SIMPLIFIED BINOPs without hint, without input restriction
#define TEST_MONOTONICITY(name)                 \
  TEST_F(TyperTest, Monotonicity_##name) {      \
    TestBinaryMonotonicity(simplified_.name()); \
  }
TEST_MONOTONICITY(NumberLessThan)
TEST_MONOTONICITY(NumberLessThanOrEqual)
TEST_MONOTONICITY(NumberEqual)
522 523 524 525
TEST_MONOTONICITY(ReferenceEqual)
TEST_MONOTONICITY(StringEqual)
TEST_MONOTONICITY(StringLessThan)
TEST_MONOTONICITY(StringLessThanOrEqual)
526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551
#undef TEST_MONOTONICITY

// SIMPLIFIED BINOPs with NumberOperationHint, without input restriction
#define TEST_MONOTONICITY(name)                                             \
  TEST_F(TyperTest, Monotonicity_##name) {                                  \
    TestBinaryMonotonicity(simplified_.name(NumberOperationHint::kNumber)); \
  }
TEST_MONOTONICITY(SpeculativeNumberEqual)
TEST_MONOTONICITY(SpeculativeNumberLessThan)
TEST_MONOTONICITY(SpeculativeNumberLessThanOrEqual)
#undef TEST_MONOTONICITY

// SIMPLIFIED BINOPs with NumberOperationHint, without input restriction
#define TEST_MONOTONICITY(name)                                             \
  TEST_F(TyperTest, Monotonicity_##name) {                                  \
    TestBinaryMonotonicity(simplified_.name(NumberOperationHint::kNumber)); \
  }
SIMPLIFIED_SPECULATIVE_NUMBER_BINOP_LIST(TEST_MONOTONICITY)
#undef TEST_MONOTONICITY

//------------------------------------------------------------------------------
// OperationTyper Monotonicity

// SIMPLIFIED UNOPs with Number input restriction
#define TEST_MONOTONICITY(name)                      \
  TEST_F(TyperTest, Monotonicity_Operation_##name) { \
552
    UnaryTyper typer = [&](Type type1) {             \
553 554 555 556 557 558 559 560 561 562 563 564
      return operation_typer_.name(type1);           \
    };                                               \
    for (int i = 0; i < kRepetitions; ++i) {         \
      TestUnaryMonotonicity(typer, Type::Number());  \
    }                                                \
  }
SIMPLIFIED_NUMBER_UNOP_LIST(TEST_MONOTONICITY)
#undef TEST_MONOTONICITY

// SIMPLIFIED BINOPs with Number input restriction
#define TEST_MONOTONICITY(name)                                      \
  TEST_F(TyperTest, Monotonicity_Operation_##name) {                 \
565
    BinaryTyper typer = [&](Type type1, Type type2) {                \
566 567 568 569 570 571 572 573 574 575
      return operation_typer_.name(type1, type2);                    \
    };                                                               \
    for (int i = 0; i < kRepetitions; ++i) {                         \
      TestBinaryMonotonicity(typer, Type::Number(), Type::Number()); \
    }                                                                \
  }
SIMPLIFIED_NUMBER_BINOP_LIST(TEST_MONOTONICITY)
#undef TEST_MONOTONICITY

// SIMPLIFIED BINOPs without input restriction
576 577 578 579 580 581 582 583
#define TEST_MONOTONICITY(name)                       \
  TEST_F(TyperTest, Monotonicity_Operation_##name) {  \
    BinaryTyper typer = [&](Type type1, Type type2) { \
      return operation_typer_.name(type1, type2);     \
    };                                                \
    for (int i = 0; i < kRepetitions; ++i) {          \
      TestBinaryMonotonicity(typer);                  \
    }                                                 \
584
  }
585 586
SIMPLIFIED_SPECULATIVE_NUMBER_BINOP_LIST(TEST_MONOTONICITY)
#undef TEST_MONOTONICITY
587

588 589 590
}  // namespace compiler
}  // namespace internal
}  // namespace v8