Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(140)

Side by Side Diff: test/unittests/compiler/js-typed-lowering-unittest.cc

Issue 2228983002: [turbofan] Simplify BinaryOperationHints and CompareOperationHints. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix compile for realz Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "src/code-factory.h" 5 #include "src/code-factory.h"
6 #include "src/compiler/access-builder.h" 6 #include "src/compiler/access-builder.h"
7 #include "src/compiler/js-graph.h" 7 #include "src/compiler/js-graph.h"
8 #include "src/compiler/js-operator.h" 8 #include "src/compiler/js-operator.h"
9 #include "src/compiler/js-typed-lowering.h" 9 #include "src/compiler/js-typed-lowering.h"
10 #include "src/compiler/machine-operator.h" 10 #include "src/compiler/machine-operator.h"
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 // JSStrictEqual 387 // JSStrictEqual
388 388
389 389
390 TEST_F(JSTypedLoweringTest, JSStrictEqualWithTheHole) { 390 TEST_F(JSTypedLoweringTest, JSStrictEqualWithTheHole) {
391 Node* const the_hole = HeapConstant(factory()->the_hole_value()); 391 Node* const the_hole = HeapConstant(factory()->the_hole_value());
392 Node* const context = UndefinedConstant(); 392 Node* const context = UndefinedConstant();
393 Node* const effect = graph()->start(); 393 Node* const effect = graph()->start();
394 Node* const control = graph()->start(); 394 Node* const control = graph()->start();
395 TRACED_FOREACH(Type*, type, kJSTypes) { 395 TRACED_FOREACH(Type*, type, kJSTypes) {
396 Node* const lhs = Parameter(type); 396 Node* const lhs = Parameter(type);
397 Reduction r = Reduce(graph()->NewNode( 397 Reduction r = Reduce(
398 javascript()->StrictEqual(CompareOperationHints::Any()), lhs, the_hole, 398 graph()->NewNode(javascript()->StrictEqual(CompareOperationHint::kAny),
399 context, effect, control)); 399 lhs, the_hole, context, effect, control));
400 ASSERT_TRUE(r.Changed()); 400 ASSERT_TRUE(r.Changed());
401 EXPECT_THAT(r.replacement(), IsFalseConstant()); 401 EXPECT_THAT(r.replacement(), IsFalseConstant());
402 } 402 }
403 } 403 }
404 404
405 405
406 TEST_F(JSTypedLoweringTest, JSStrictEqualWithUnique) { 406 TEST_F(JSTypedLoweringTest, JSStrictEqualWithUnique) {
407 Node* const lhs = Parameter(Type::Unique(), 0); 407 Node* const lhs = Parameter(Type::Unique(), 0);
408 Node* const rhs = Parameter(Type::Unique(), 1); 408 Node* const rhs = Parameter(Type::Unique(), 1);
409 Node* const context = Parameter(Type::Any(), 2); 409 Node* const context = Parameter(Type::Any(), 2);
410 Node* const effect = graph()->start(); 410 Node* const effect = graph()->start();
411 Node* const control = graph()->start(); 411 Node* const control = graph()->start();
412 Reduction r = Reduce( 412 Reduction r = Reduce(
413 graph()->NewNode(javascript()->StrictEqual(CompareOperationHints::Any()), 413 graph()->NewNode(javascript()->StrictEqual(CompareOperationHint::kAny),
414 lhs, rhs, context, effect, control)); 414 lhs, rhs, context, effect, control));
415 ASSERT_TRUE(r.Changed()); 415 ASSERT_TRUE(r.Changed());
416 EXPECT_THAT(r.replacement(), IsReferenceEqual(Type::Unique(), lhs, rhs)); 416 EXPECT_THAT(r.replacement(), IsReferenceEqual(Type::Unique(), lhs, rhs));
417 } 417 }
418 418
419 419
420 // ----------------------------------------------------------------------------- 420 // -----------------------------------------------------------------------------
421 // JSShiftLeft 421 // JSShiftLeft
422 422
423 TEST_F(JSTypedLoweringTest, JSShiftLeftWithSigned32AndConstant) { 423 TEST_F(JSTypedLoweringTest, JSShiftLeftWithSigned32AndConstant) {
424 BinaryOperationHints const hints = BinaryOperationHints::Any(); 424 BinaryOperationHint const hint = BinaryOperationHint::kAny;
425 Node* const lhs = Parameter(Type::Signed32()); 425 Node* const lhs = Parameter(Type::Signed32());
426 Node* const context = UndefinedConstant(); 426 Node* const context = UndefinedConstant();
427 Node* const effect = graph()->start(); 427 Node* const effect = graph()->start();
428 Node* const control = graph()->start(); 428 Node* const control = graph()->start();
429 TRACED_FORRANGE(double, rhs, 0, 31) { 429 TRACED_FORRANGE(double, rhs, 0, 31) {
430 Reduction r = Reduce(graph()->NewNode(javascript()->ShiftLeft(hints), lhs, 430 Reduction r = Reduce(graph()->NewNode(javascript()->ShiftLeft(hint), lhs,
431 NumberConstant(rhs), context, 431 NumberConstant(rhs), context,
432 EmptyFrameState(), effect, control)); 432 EmptyFrameState(), effect, control));
433 ASSERT_TRUE(r.Changed()); 433 ASSERT_TRUE(r.Changed());
434 EXPECT_THAT(r.replacement(), 434 EXPECT_THAT(r.replacement(),
435 IsNumberShiftLeft(lhs, IsNumberConstant(BitEq(rhs)))); 435 IsNumberShiftLeft(lhs, IsNumberConstant(BitEq(rhs))));
436 } 436 }
437 } 437 }
438 438
439 TEST_F(JSTypedLoweringTest, JSShiftLeftWithSigned32AndUnsigned32) { 439 TEST_F(JSTypedLoweringTest, JSShiftLeftWithSigned32AndUnsigned32) {
440 BinaryOperationHints const hints = BinaryOperationHints::Any(); 440 BinaryOperationHint const hint = BinaryOperationHint::kAny;
441 Node* const lhs = Parameter(Type::Signed32()); 441 Node* const lhs = Parameter(Type::Signed32());
442 Node* const rhs = Parameter(Type::Unsigned32()); 442 Node* const rhs = Parameter(Type::Unsigned32());
443 Node* const context = UndefinedConstant(); 443 Node* const context = UndefinedConstant();
444 Node* const effect = graph()->start(); 444 Node* const effect = graph()->start();
445 Node* const control = graph()->start(); 445 Node* const control = graph()->start();
446 Reduction r = 446 Reduction r =
447 Reduce(graph()->NewNode(javascript()->ShiftLeft(hints), lhs, rhs, context, 447 Reduce(graph()->NewNode(javascript()->ShiftLeft(hint), lhs, rhs, context,
448 EmptyFrameState(), effect, control)); 448 EmptyFrameState(), effect, control));
449 ASSERT_TRUE(r.Changed()); 449 ASSERT_TRUE(r.Changed());
450 EXPECT_THAT(r.replacement(), IsNumberShiftLeft(lhs, rhs)); 450 EXPECT_THAT(r.replacement(), IsNumberShiftLeft(lhs, rhs));
451 } 451 }
452 452
453 TEST_F(JSTypedLoweringTest, JSShiftLeftWithSignedSmallHint) { 453 TEST_F(JSTypedLoweringTest, JSShiftLeftWithSignedSmallHint) {
454 BinaryOperationHints const hints(BinaryOperationHints::kSignedSmall, 454 BinaryOperationHint const hint = BinaryOperationHint::kSignedSmall;
455 BinaryOperationHints::kSignedSmall,
456 BinaryOperationHints::kSignedSmall);
457 Node* lhs = Parameter(Type::Number(), 2); 455 Node* lhs = Parameter(Type::Number(), 2);
458 Node* rhs = Parameter(Type::Number(), 3); 456 Node* rhs = Parameter(Type::Number(), 3);
459 Node* effect = graph()->start(); 457 Node* effect = graph()->start();
460 Node* control = graph()->start(); 458 Node* control = graph()->start();
461 Reduction r = Reduce(graph()->NewNode(javascript()->ShiftLeft(hints), lhs, 459 Reduction r = Reduce(graph()->NewNode(javascript()->ShiftLeft(hint), lhs, rhs,
462 rhs, UndefinedConstant(), 460 UndefinedConstant(), EmptyFrameState(),
463 EmptyFrameState(), effect, control)); 461 effect, control));
464 ASSERT_TRUE(r.Changed()); 462 ASSERT_TRUE(r.Changed());
465 EXPECT_THAT(r.replacement(), 463 EXPECT_THAT(r.replacement(),
466 IsSpeculativeNumberShiftLeft(NumberOperationHint::kSignedSmall, 464 IsSpeculativeNumberShiftLeft(NumberOperationHint::kSignedSmall,
467 lhs, rhs, effect, control)); 465 lhs, rhs, effect, control));
468 } 466 }
469 467
470 TEST_F(JSTypedLoweringTest, JSShiftLeftWithSigned32Hint) { 468 TEST_F(JSTypedLoweringTest, JSShiftLeftWithSigned32Hint) {
471 BinaryOperationHints const hints(BinaryOperationHints::kSigned32, 469 BinaryOperationHint const hint = BinaryOperationHint::kSigned32;
472 BinaryOperationHints::kSigned32,
473 BinaryOperationHints::kSigned32);
474 Node* lhs = Parameter(Type::Number(), 2); 470 Node* lhs = Parameter(Type::Number(), 2);
475 Node* rhs = Parameter(Type::Number(), 3); 471 Node* rhs = Parameter(Type::Number(), 3);
476 Node* effect = graph()->start(); 472 Node* effect = graph()->start();
477 Node* control = graph()->start(); 473 Node* control = graph()->start();
478 Reduction r = Reduce(graph()->NewNode(javascript()->ShiftLeft(hints), lhs, 474 Reduction r = Reduce(graph()->NewNode(javascript()->ShiftLeft(hint), lhs, rhs,
479 rhs, UndefinedConstant(), 475 UndefinedConstant(), EmptyFrameState(),
480 EmptyFrameState(), effect, control)); 476 effect, control));
481 ASSERT_TRUE(r.Changed()); 477 ASSERT_TRUE(r.Changed());
482 EXPECT_THAT(r.replacement(), 478 EXPECT_THAT(r.replacement(),
483 IsSpeculativeNumberShiftLeft(NumberOperationHint::kSigned32, lhs, 479 IsSpeculativeNumberShiftLeft(NumberOperationHint::kSigned32, lhs,
484 rhs, effect, control)); 480 rhs, effect, control));
485 } 481 }
486 482
487 TEST_F(JSTypedLoweringTest, JSShiftLeftWithNumberOrOddballHint) { 483 TEST_F(JSTypedLoweringTest, JSShiftLeftWithNumberOrOddballHint) {
488 BinaryOperationHints const hints(BinaryOperationHints::kNumberOrOddball, 484 BinaryOperationHint const hint = BinaryOperationHint::kNumberOrOddball;
489 BinaryOperationHints::kNumberOrOddball,
490 BinaryOperationHints::kNumberOrOddball);
491 Node* lhs = Parameter(Type::Number(), 2); 485 Node* lhs = Parameter(Type::Number(), 2);
492 Node* rhs = Parameter(Type::Number(), 3); 486 Node* rhs = Parameter(Type::Number(), 3);
493 Node* effect = graph()->start(); 487 Node* effect = graph()->start();
494 Node* control = graph()->start(); 488 Node* control = graph()->start();
495 Reduction r = Reduce(graph()->NewNode(javascript()->ShiftLeft(hints), lhs, 489 Reduction r = Reduce(graph()->NewNode(javascript()->ShiftLeft(hint), lhs, rhs,
496 rhs, UndefinedConstant(), 490 UndefinedConstant(), EmptyFrameState(),
497 EmptyFrameState(), effect, control)); 491 effect, control));
498 ASSERT_TRUE(r.Changed()); 492 ASSERT_TRUE(r.Changed());
499 EXPECT_THAT(r.replacement(), IsSpeculativeNumberShiftLeft( 493 EXPECT_THAT(r.replacement(), IsSpeculativeNumberShiftLeft(
500 NumberOperationHint::kNumberOrOddball, lhs, 494 NumberOperationHint::kNumberOrOddball, lhs,
501 rhs, effect, control)); 495 rhs, effect, control));
502 } 496 }
503 497
504 // ----------------------------------------------------------------------------- 498 // -----------------------------------------------------------------------------
505 // JSShiftRight 499 // JSShiftRight
506 500
507 501
508 TEST_F(JSTypedLoweringTest, JSShiftRightWithSigned32AndConstant) { 502 TEST_F(JSTypedLoweringTest, JSShiftRightWithSigned32AndConstant) {
509 BinaryOperationHints const hints = BinaryOperationHints::Any(); 503 BinaryOperationHint const hint = BinaryOperationHint::kAny;
510 Node* const lhs = Parameter(Type::Signed32()); 504 Node* const lhs = Parameter(Type::Signed32());
511 Node* const context = UndefinedConstant(); 505 Node* const context = UndefinedConstant();
512 Node* const effect = graph()->start(); 506 Node* const effect = graph()->start();
513 Node* const control = graph()->start(); 507 Node* const control = graph()->start();
514 TRACED_FORRANGE(double, rhs, 0, 31) { 508 TRACED_FORRANGE(double, rhs, 0, 31) {
515 Reduction r = Reduce(graph()->NewNode(javascript()->ShiftRight(hints), lhs, 509 Reduction r = Reduce(graph()->NewNode(javascript()->ShiftRight(hint), lhs,
516 NumberConstant(rhs), context, 510 NumberConstant(rhs), context,
517 EmptyFrameState(), effect, control)); 511 EmptyFrameState(), effect, control));
518 ASSERT_TRUE(r.Changed()); 512 ASSERT_TRUE(r.Changed());
519 EXPECT_THAT(r.replacement(), 513 EXPECT_THAT(r.replacement(),
520 IsNumberShiftRight(lhs, IsNumberConstant(BitEq(rhs)))); 514 IsNumberShiftRight(lhs, IsNumberConstant(BitEq(rhs))));
521 } 515 }
522 } 516 }
523 517
524 518
525 TEST_F(JSTypedLoweringTest, JSShiftRightWithSigned32AndUnsigned32) { 519 TEST_F(JSTypedLoweringTest, JSShiftRightWithSigned32AndUnsigned32) {
526 BinaryOperationHints const hints = BinaryOperationHints::Any(); 520 BinaryOperationHint const hint = BinaryOperationHint::kAny;
527 Node* const lhs = Parameter(Type::Signed32()); 521 Node* const lhs = Parameter(Type::Signed32());
528 Node* const rhs = Parameter(Type::Unsigned32()); 522 Node* const rhs = Parameter(Type::Unsigned32());
529 Node* const context = UndefinedConstant(); 523 Node* const context = UndefinedConstant();
530 Node* const effect = graph()->start(); 524 Node* const effect = graph()->start();
531 Node* const control = graph()->start(); 525 Node* const control = graph()->start();
532 Reduction r = 526 Reduction r =
533 Reduce(graph()->NewNode(javascript()->ShiftRight(hints), lhs, rhs, 527 Reduce(graph()->NewNode(javascript()->ShiftRight(hint), lhs, rhs, context,
534 context, EmptyFrameState(), effect, control)); 528 EmptyFrameState(), effect, control));
535 ASSERT_TRUE(r.Changed()); 529 ASSERT_TRUE(r.Changed());
536 EXPECT_THAT(r.replacement(), IsNumberShiftRight(lhs, rhs)); 530 EXPECT_THAT(r.replacement(), IsNumberShiftRight(lhs, rhs));
537 } 531 }
538 532
539 TEST_F(JSTypedLoweringTest, JSShiftRightWithSignedSmallHint) { 533 TEST_F(JSTypedLoweringTest, JSShiftRightWithSignedSmallHint) {
540 BinaryOperationHints const hints(BinaryOperationHints::kSignedSmall, 534 BinaryOperationHint const hint = BinaryOperationHint::kSignedSmall;
541 BinaryOperationHints::kSignedSmall,
542 BinaryOperationHints::kSignedSmall);
543 Node* lhs = Parameter(Type::Number(), 2); 535 Node* lhs = Parameter(Type::Number(), 2);
544 Node* rhs = Parameter(Type::Number(), 3); 536 Node* rhs = Parameter(Type::Number(), 3);
545 Node* effect = graph()->start(); 537 Node* effect = graph()->start();
546 Node* control = graph()->start(); 538 Node* control = graph()->start();
547 Reduction r = Reduce(graph()->NewNode(javascript()->ShiftRight(hints), lhs, 539 Reduction r = Reduce(graph()->NewNode(javascript()->ShiftRight(hint), lhs,
548 rhs, UndefinedConstant(), 540 rhs, UndefinedConstant(),
549 EmptyFrameState(), effect, control)); 541 EmptyFrameState(), effect, control));
550 ASSERT_TRUE(r.Changed()); 542 ASSERT_TRUE(r.Changed());
551 EXPECT_THAT(r.replacement(), 543 EXPECT_THAT(r.replacement(),
552 IsSpeculativeNumberShiftRight(NumberOperationHint::kSignedSmall, 544 IsSpeculativeNumberShiftRight(NumberOperationHint::kSignedSmall,
553 lhs, rhs, effect, control)); 545 lhs, rhs, effect, control));
554 } 546 }
555 547
556 TEST_F(JSTypedLoweringTest, JSShiftRightWithSigned32Hint) { 548 TEST_F(JSTypedLoweringTest, JSShiftRightWithSigned32Hint) {
557 BinaryOperationHints const hints(BinaryOperationHints::kSigned32, 549 BinaryOperationHint const hint = BinaryOperationHint::kSigned32;
558 BinaryOperationHints::kSigned32,
559 BinaryOperationHints::kSigned32);
560 Node* lhs = Parameter(Type::Number(), 2); 550 Node* lhs = Parameter(Type::Number(), 2);
561 Node* rhs = Parameter(Type::Number(), 3); 551 Node* rhs = Parameter(Type::Number(), 3);
562 Node* effect = graph()->start(); 552 Node* effect = graph()->start();
563 Node* control = graph()->start(); 553 Node* control = graph()->start();
564 Reduction r = Reduce(graph()->NewNode(javascript()->ShiftRight(hints), lhs, 554 Reduction r = Reduce(graph()->NewNode(javascript()->ShiftRight(hint), lhs,
565 rhs, UndefinedConstant(), 555 rhs, UndefinedConstant(),
566 EmptyFrameState(), effect, control)); 556 EmptyFrameState(), effect, control));
567 ASSERT_TRUE(r.Changed()); 557 ASSERT_TRUE(r.Changed());
568 EXPECT_THAT(r.replacement(), 558 EXPECT_THAT(r.replacement(),
569 IsSpeculativeNumberShiftRight(NumberOperationHint::kSigned32, lhs, 559 IsSpeculativeNumberShiftRight(NumberOperationHint::kSigned32, lhs,
570 rhs, effect, control)); 560 rhs, effect, control));
571 } 561 }
572 562
573 TEST_F(JSTypedLoweringTest, JSShiftRightWithNumberOrOddballHint) { 563 TEST_F(JSTypedLoweringTest, JSShiftRightWithNumberOrOddballHint) {
574 BinaryOperationHints const hints(BinaryOperationHints::kNumberOrOddball, 564 BinaryOperationHint const hint = BinaryOperationHint::kNumberOrOddball;
575 BinaryOperationHints::kNumberOrOddball,
576 BinaryOperationHints::kNumberOrOddball);
577 Node* lhs = Parameter(Type::Number(), 2); 565 Node* lhs = Parameter(Type::Number(), 2);
578 Node* rhs = Parameter(Type::Number(), 3); 566 Node* rhs = Parameter(Type::Number(), 3);
579 Node* effect = graph()->start(); 567 Node* effect = graph()->start();
580 Node* control = graph()->start(); 568 Node* control = graph()->start();
581 Reduction r = Reduce(graph()->NewNode(javascript()->ShiftRight(hints), lhs, 569 Reduction r = Reduce(graph()->NewNode(javascript()->ShiftRight(hint), lhs,
582 rhs, UndefinedConstant(), 570 rhs, UndefinedConstant(),
583 EmptyFrameState(), effect, control)); 571 EmptyFrameState(), effect, control));
584 ASSERT_TRUE(r.Changed()); 572 ASSERT_TRUE(r.Changed());
585 EXPECT_THAT(r.replacement(), IsSpeculativeNumberShiftRight( 573 EXPECT_THAT(r.replacement(), IsSpeculativeNumberShiftRight(
586 NumberOperationHint::kNumberOrOddball, lhs, 574 NumberOperationHint::kNumberOrOddball, lhs,
587 rhs, effect, control)); 575 rhs, effect, control));
588 } 576 }
589 577
590 // ----------------------------------------------------------------------------- 578 // -----------------------------------------------------------------------------
591 // JSShiftRightLogical 579 // JSShiftRightLogical
592 580
593 581
594 TEST_F(JSTypedLoweringTest, 582 TEST_F(JSTypedLoweringTest,
595 JSShiftRightLogicalWithUnsigned32AndConstant) { 583 JSShiftRightLogicalWithUnsigned32AndConstant) {
596 BinaryOperationHints const hints = BinaryOperationHints::Any(); 584 BinaryOperationHint const hint = BinaryOperationHint::kAny;
597 Node* const lhs = Parameter(Type::Unsigned32()); 585 Node* const lhs = Parameter(Type::Unsigned32());
598 Node* const context = UndefinedConstant(); 586 Node* const context = UndefinedConstant();
599 Node* const effect = graph()->start(); 587 Node* const effect = graph()->start();
600 Node* const control = graph()->start(); 588 Node* const control = graph()->start();
601 TRACED_FORRANGE(double, rhs, 0, 31) { 589 TRACED_FORRANGE(double, rhs, 0, 31) {
602 Reduction r = Reduce(graph()->NewNode( 590 Reduction r = Reduce(graph()->NewNode(javascript()->ShiftRightLogical(hint),
603 javascript()->ShiftRightLogical(hints), lhs, NumberConstant(rhs), 591 lhs, NumberConstant(rhs), context,
604 context, EmptyFrameState(), effect, control)); 592 EmptyFrameState(), effect, control));
605 ASSERT_TRUE(r.Changed()); 593 ASSERT_TRUE(r.Changed());
606 EXPECT_THAT(r.replacement(), 594 EXPECT_THAT(r.replacement(),
607 IsNumberShiftRightLogical(lhs, IsNumberConstant(BitEq(rhs)))); 595 IsNumberShiftRightLogical(lhs, IsNumberConstant(BitEq(rhs))));
608 } 596 }
609 } 597 }
610 598
611 599
612 TEST_F(JSTypedLoweringTest, JSShiftRightLogicalWithUnsigned32AndUnsigned32) { 600 TEST_F(JSTypedLoweringTest, JSShiftRightLogicalWithUnsigned32AndUnsigned32) {
613 BinaryOperationHints const hints = BinaryOperationHints::Any(); 601 BinaryOperationHint const hint = BinaryOperationHint::kAny;
614 Node* const lhs = Parameter(Type::Unsigned32()); 602 Node* const lhs = Parameter(Type::Unsigned32());
615 Node* const rhs = Parameter(Type::Unsigned32()); 603 Node* const rhs = Parameter(Type::Unsigned32());
616 Node* const context = UndefinedConstant(); 604 Node* const context = UndefinedConstant();
617 Node* const effect = graph()->start(); 605 Node* const effect = graph()->start();
618 Node* const control = graph()->start(); 606 Node* const control = graph()->start();
619 Reduction r = 607 Reduction r =
620 Reduce(graph()->NewNode(javascript()->ShiftRightLogical(hints), lhs, rhs, 608 Reduce(graph()->NewNode(javascript()->ShiftRightLogical(hint), lhs, rhs,
621 context, EmptyFrameState(), effect, control)); 609 context, EmptyFrameState(), effect, control));
622 ASSERT_TRUE(r.Changed()); 610 ASSERT_TRUE(r.Changed());
623 EXPECT_THAT(r.replacement(), IsNumberShiftRightLogical(lhs, rhs)); 611 EXPECT_THAT(r.replacement(), IsNumberShiftRightLogical(lhs, rhs));
624 } 612 }
625 613
626 TEST_F(JSTypedLoweringTest, JSShiftRightLogicalWithSignedSmallHint) { 614 TEST_F(JSTypedLoweringTest, JSShiftRightLogicalWithSignedSmallHint) {
627 BinaryOperationHints const hints(BinaryOperationHints::kSignedSmall, 615 BinaryOperationHint const hint = BinaryOperationHint::kSignedSmall;
628 BinaryOperationHints::kSignedSmall,
629 BinaryOperationHints::kSignedSmall);
630 Node* lhs = Parameter(Type::Number(), 2); 616 Node* lhs = Parameter(Type::Number(), 2);
631 Node* rhs = Parameter(Type::Number(), 3); 617 Node* rhs = Parameter(Type::Number(), 3);
632 Node* effect = graph()->start(); 618 Node* effect = graph()->start();
633 Node* control = graph()->start(); 619 Node* control = graph()->start();
634 Reduction r = Reduce(graph()->NewNode(javascript()->ShiftRightLogical(hints), 620 Reduction r = Reduce(graph()->NewNode(javascript()->ShiftRightLogical(hint),
635 lhs, rhs, UndefinedConstant(), 621 lhs, rhs, UndefinedConstant(),
636 EmptyFrameState(), effect, control)); 622 EmptyFrameState(), effect, control));
637 ASSERT_TRUE(r.Changed()); 623 ASSERT_TRUE(r.Changed());
638 EXPECT_THAT(r.replacement(), IsSpeculativeNumberShiftRightLogical( 624 EXPECT_THAT(r.replacement(), IsSpeculativeNumberShiftRightLogical(
639 NumberOperationHint::kSignedSmall, lhs, rhs, 625 NumberOperationHint::kSignedSmall, lhs, rhs,
640 effect, control)); 626 effect, control));
641 } 627 }
642 628
643 TEST_F(JSTypedLoweringTest, JSShiftRightLogicalWithSigned32Hint) { 629 TEST_F(JSTypedLoweringTest, JSShiftRightLogicalWithSigned32Hint) {
644 BinaryOperationHints const hints(BinaryOperationHints::kSigned32, 630 BinaryOperationHint const hint = BinaryOperationHint::kSigned32;
645 BinaryOperationHints::kSigned32,
646 BinaryOperationHints::kSigned32);
647 Node* lhs = Parameter(Type::Number(), 2); 631 Node* lhs = Parameter(Type::Number(), 2);
648 Node* rhs = Parameter(Type::Number(), 3); 632 Node* rhs = Parameter(Type::Number(), 3);
649 Node* effect = graph()->start(); 633 Node* effect = graph()->start();
650 Node* control = graph()->start(); 634 Node* control = graph()->start();
651 Reduction r = Reduce(graph()->NewNode(javascript()->ShiftRightLogical(hints), 635 Reduction r = Reduce(graph()->NewNode(javascript()->ShiftRightLogical(hint),
652 lhs, rhs, UndefinedConstant(), 636 lhs, rhs, UndefinedConstant(),
653 EmptyFrameState(), effect, control)); 637 EmptyFrameState(), effect, control));
654 ASSERT_TRUE(r.Changed()); 638 ASSERT_TRUE(r.Changed());
655 EXPECT_THAT(r.replacement(), 639 EXPECT_THAT(r.replacement(),
656 IsSpeculativeNumberShiftRightLogical( 640 IsSpeculativeNumberShiftRightLogical(
657 NumberOperationHint::kSigned32, lhs, rhs, effect, control)); 641 NumberOperationHint::kSigned32, lhs, rhs, effect, control));
658 } 642 }
659 643
660 TEST_F(JSTypedLoweringTest, JSShiftRightLogicalWithNumberOrOddballHint) { 644 TEST_F(JSTypedLoweringTest, JSShiftRightLogicalWithNumberOrOddballHint) {
661 BinaryOperationHints const hints(BinaryOperationHints::kNumberOrOddball, 645 BinaryOperationHint const hint = BinaryOperationHint::kNumberOrOddball;
662 BinaryOperationHints::kNumberOrOddball,
663 BinaryOperationHints::kNumberOrOddball);
664 Node* lhs = Parameter(Type::Number(), 2); 646 Node* lhs = Parameter(Type::Number(), 2);
665 Node* rhs = Parameter(Type::Number(), 3); 647 Node* rhs = Parameter(Type::Number(), 3);
666 Node* effect = graph()->start(); 648 Node* effect = graph()->start();
667 Node* control = graph()->start(); 649 Node* control = graph()->start();
668 Reduction r = Reduce(graph()->NewNode(javascript()->ShiftRightLogical(hints), 650 Reduction r = Reduce(graph()->NewNode(javascript()->ShiftRightLogical(hint),
669 lhs, rhs, UndefinedConstant(), 651 lhs, rhs, UndefinedConstant(),
670 EmptyFrameState(), effect, control)); 652 EmptyFrameState(), effect, control));
671 ASSERT_TRUE(r.Changed()); 653 ASSERT_TRUE(r.Changed());
672 EXPECT_THAT(r.replacement(), IsSpeculativeNumberShiftRightLogical( 654 EXPECT_THAT(r.replacement(), IsSpeculativeNumberShiftRightLogical(
673 NumberOperationHint::kNumberOrOddball, lhs, 655 NumberOperationHint::kNumberOrOddball, lhs,
674 rhs, effect, control)); 656 rhs, effect, control));
675 } 657 }
676 658
677 // ----------------------------------------------------------------------------- 659 // -----------------------------------------------------------------------------
678 // JSLoadContext 660 // JSLoadContext
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
978 EXPECT_THAT(r.replacement(), IsLoadField(AccessBuilder::ForStringLength(), 960 EXPECT_THAT(r.replacement(), IsLoadField(AccessBuilder::ForStringLength(),
979 receiver, effect, control)); 961 receiver, effect, control));
980 } 962 }
981 963
982 964
983 // ----------------------------------------------------------------------------- 965 // -----------------------------------------------------------------------------
984 // JSAdd 966 // JSAdd
985 967
986 968
987 TEST_F(JSTypedLoweringTest, JSAddWithString) { 969 TEST_F(JSTypedLoweringTest, JSAddWithString) {
988 BinaryOperationHints const hints = BinaryOperationHints::Any(); 970 BinaryOperationHint const hint = BinaryOperationHint::kAny;
989 Node* lhs = Parameter(Type::String(), 0); 971 Node* lhs = Parameter(Type::String(), 0);
990 Node* rhs = Parameter(Type::String(), 1); 972 Node* rhs = Parameter(Type::String(), 1);
991 Node* context = Parameter(Type::Any(), 2); 973 Node* context = Parameter(Type::Any(), 2);
992 Node* frame_state = EmptyFrameState(); 974 Node* frame_state = EmptyFrameState();
993 Node* effect = graph()->start(); 975 Node* effect = graph()->start();
994 Node* control = graph()->start(); 976 Node* control = graph()->start();
995 Reduction r = Reduce(graph()->NewNode(javascript()->Add(hints), lhs, rhs, 977 Reduction r = Reduce(graph()->NewNode(javascript()->Add(hint), lhs, rhs,
996 context, frame_state, effect, control)); 978 context, frame_state, effect, control));
997 ASSERT_TRUE(r.Changed()); 979 ASSERT_TRUE(r.Changed());
998 EXPECT_THAT(r.replacement(), 980 EXPECT_THAT(r.replacement(),
999 IsCall(_, IsHeapConstant( 981 IsCall(_, IsHeapConstant(
1000 CodeFactory::StringAdd( 982 CodeFactory::StringAdd(
1001 isolate(), STRING_ADD_CHECK_NONE, NOT_TENURED) 983 isolate(), STRING_ADD_CHECK_NONE, NOT_TENURED)
1002 .code()), 984 .code()),
1003 lhs, rhs, context, frame_state, effect, control)); 985 lhs, rhs, context, frame_state, effect, control));
1004 } 986 }
1005 987
1006 TEST_F(JSTypedLoweringTest, JSAddSmis) { 988 TEST_F(JSTypedLoweringTest, JSAddSmis) {
1007 BinaryOperationHints const hints(BinaryOperationHints::kSignedSmall, 989 BinaryOperationHint const hint = BinaryOperationHint::kSignedSmall;
1008 BinaryOperationHints::kSignedSmall,
1009 BinaryOperationHints::kSignedSmall);
1010 Node* lhs = Parameter(Type::Number(), 0); 990 Node* lhs = Parameter(Type::Number(), 0);
1011 Node* rhs = Parameter(Type::Number(), 1); 991 Node* rhs = Parameter(Type::Number(), 1);
1012 Node* context = Parameter(Type::Any(), 2); 992 Node* context = Parameter(Type::Any(), 2);
1013 Node* frame_state = EmptyFrameState(); 993 Node* frame_state = EmptyFrameState();
1014 Node* effect = graph()->start(); 994 Node* effect = graph()->start();
1015 Node* control = graph()->start(); 995 Node* control = graph()->start();
1016 Reduction r = Reduce(graph()->NewNode(javascript()->Add(hints), lhs, rhs, 996 Reduction r = Reduce(graph()->NewNode(javascript()->Add(hint), lhs, rhs,
1017 context, frame_state, effect, control)); 997 context, frame_state, effect, control));
1018 ASSERT_TRUE(r.Changed()); 998 ASSERT_TRUE(r.Changed());
1019 EXPECT_THAT(r.replacement(), 999 EXPECT_THAT(r.replacement(),
1020 IsSpeculativeNumberAdd(NumberOperationHint::kSignedSmall, lhs, 1000 IsSpeculativeNumberAdd(NumberOperationHint::kSignedSmall, lhs,
1021 rhs, effect, control)); 1001 rhs, effect, control));
1022 } 1002 }
1023 1003
1024 // ----------------------------------------------------------------------------- 1004 // -----------------------------------------------------------------------------
1025 // JSSubtract 1005 // JSSubtract
1026 1006
1027 TEST_F(JSTypedLoweringTest, JSSubtractSmis) { 1007 TEST_F(JSTypedLoweringTest, JSSubtractSmis) {
1028 BinaryOperationHints const hints(BinaryOperationHints::kSignedSmall, 1008 BinaryOperationHint const hint = BinaryOperationHint::kSignedSmall;
1029 BinaryOperationHints::kSignedSmall,
1030 BinaryOperationHints::kSignedSmall);
1031 Node* lhs = Parameter(Type::Number(), 0); 1009 Node* lhs = Parameter(Type::Number(), 0);
1032 Node* rhs = Parameter(Type::Number(), 1); 1010 Node* rhs = Parameter(Type::Number(), 1);
1033 Node* context = Parameter(Type::Any(), 2); 1011 Node* context = Parameter(Type::Any(), 2);
1034 Node* frame_state = EmptyFrameState(); 1012 Node* frame_state = EmptyFrameState();
1035 Node* effect = graph()->start(); 1013 Node* effect = graph()->start();
1036 Node* control = graph()->start(); 1014 Node* control = graph()->start();
1037 Reduction r = Reduce(graph()->NewNode(javascript()->Subtract(hints), lhs, rhs, 1015 Reduction r = Reduce(graph()->NewNode(javascript()->Subtract(hint), lhs, rhs,
1038 context, frame_state, effect, control)); 1016 context, frame_state, effect, control));
1039 ASSERT_TRUE(r.Changed()); 1017 ASSERT_TRUE(r.Changed());
1040 EXPECT_THAT(r.replacement(), 1018 EXPECT_THAT(r.replacement(),
1041 IsSpeculativeNumberSubtract(NumberOperationHint::kSignedSmall, 1019 IsSpeculativeNumberSubtract(NumberOperationHint::kSignedSmall,
1042 lhs, rhs, effect, control)); 1020 lhs, rhs, effect, control));
1043 } 1021 }
1044 1022
1045 // ----------------------------------------------------------------------------- 1023 // -----------------------------------------------------------------------------
1046 // JSInstanceOf 1024 // JSInstanceOf
1047 // Test that instanceOf is reduced if and only if the right-hand side is a 1025 // Test that instanceOf is reduced if and only if the right-hand side is a
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
1101 frame_state, effect, control); 1079 frame_state, effect, control);
1102 Reduction r = Reduce(instanceOf); 1080 Reduction r = Reduce(instanceOf);
1103 ASSERT_FALSE(r.Changed()); 1081 ASSERT_FALSE(r.Changed());
1104 ASSERT_EQ(instanceOf, dummy->InputAt(0)); 1082 ASSERT_EQ(instanceOf, dummy->InputAt(0));
1105 } 1083 }
1106 1084
1107 // ----------------------------------------------------------------------------- 1085 // -----------------------------------------------------------------------------
1108 // JSBitwiseAnd 1086 // JSBitwiseAnd
1109 1087
1110 TEST_F(JSTypedLoweringTest, JSBitwiseAndWithSignedSmallHint) { 1088 TEST_F(JSTypedLoweringTest, JSBitwiseAndWithSignedSmallHint) {
1111 BinaryOperationHints const hints(BinaryOperationHints::kSignedSmall, 1089 BinaryOperationHint const hint = BinaryOperationHint::kSignedSmall;
1112 BinaryOperationHints::kSignedSmall,
1113 BinaryOperationHints::kSignedSmall);
1114 Node* lhs = Parameter(Type::Number(), 2); 1090 Node* lhs = Parameter(Type::Number(), 2);
1115 Node* rhs = Parameter(Type::Number(), 3); 1091 Node* rhs = Parameter(Type::Number(), 3);
1116 Node* effect = graph()->start(); 1092 Node* effect = graph()->start();
1117 Node* control = graph()->start(); 1093 Node* control = graph()->start();
1118 Reduction r = Reduce(graph()->NewNode(javascript()->BitwiseAnd(hints), lhs, 1094 Reduction r = Reduce(graph()->NewNode(javascript()->BitwiseAnd(hint), lhs,
1119 rhs, UndefinedConstant(), 1095 rhs, UndefinedConstant(),
1120 EmptyFrameState(), effect, control)); 1096 EmptyFrameState(), effect, control));
1121 ASSERT_TRUE(r.Changed()); 1097 ASSERT_TRUE(r.Changed());
1122 EXPECT_THAT(r.replacement(), 1098 EXPECT_THAT(r.replacement(),
1123 IsSpeculativeNumberBitwiseAnd(NumberOperationHint::kSignedSmall, 1099 IsSpeculativeNumberBitwiseAnd(NumberOperationHint::kSignedSmall,
1124 lhs, rhs, effect, control)); 1100 lhs, rhs, effect, control));
1125 } 1101 }
1126 1102
1127 TEST_F(JSTypedLoweringTest, JSBitwiseAndWithSigned32Hint) { 1103 TEST_F(JSTypedLoweringTest, JSBitwiseAndWithSigned32Hint) {
1128 BinaryOperationHints const hints(BinaryOperationHints::kSigned32, 1104 BinaryOperationHint const hint = BinaryOperationHint::kSigned32;
1129 BinaryOperationHints::kSigned32,
1130 BinaryOperationHints::kSigned32);
1131 Node* lhs = Parameter(Type::Number(), 2); 1105 Node* lhs = Parameter(Type::Number(), 2);
1132 Node* rhs = Parameter(Type::Number(), 3); 1106 Node* rhs = Parameter(Type::Number(), 3);
1133 Node* effect = graph()->start(); 1107 Node* effect = graph()->start();
1134 Node* control = graph()->start(); 1108 Node* control = graph()->start();
1135 Reduction r = Reduce(graph()->NewNode(javascript()->BitwiseAnd(hints), lhs, 1109 Reduction r = Reduce(graph()->NewNode(javascript()->BitwiseAnd(hint), lhs,
1136 rhs, UndefinedConstant(), 1110 rhs, UndefinedConstant(),
1137 EmptyFrameState(), effect, control)); 1111 EmptyFrameState(), effect, control));
1138 ASSERT_TRUE(r.Changed()); 1112 ASSERT_TRUE(r.Changed());
1139 EXPECT_THAT(r.replacement(), 1113 EXPECT_THAT(r.replacement(),
1140 IsSpeculativeNumberBitwiseAnd(NumberOperationHint::kSigned32, lhs, 1114 IsSpeculativeNumberBitwiseAnd(NumberOperationHint::kSigned32, lhs,
1141 rhs, effect, control)); 1115 rhs, effect, control));
1142 } 1116 }
1143 1117
1144 TEST_F(JSTypedLoweringTest, JSBitwiseAndWithNumberOrOddballHint) { 1118 TEST_F(JSTypedLoweringTest, JSBitwiseAndWithNumberOrOddballHint) {
1145 BinaryOperationHints const hints(BinaryOperationHints::kNumberOrOddball, 1119 BinaryOperationHint const hint = BinaryOperationHint::kNumberOrOddball;
1146 BinaryOperationHints::kNumberOrOddball,
1147 BinaryOperationHints::kNumberOrOddball);
1148 Node* lhs = Parameter(Type::Number(), 2); 1120 Node* lhs = Parameter(Type::Number(), 2);
1149 Node* rhs = Parameter(Type::Number(), 3); 1121 Node* rhs = Parameter(Type::Number(), 3);
1150 Node* effect = graph()->start(); 1122 Node* effect = graph()->start();
1151 Node* control = graph()->start(); 1123 Node* control = graph()->start();
1152 Reduction r = Reduce(graph()->NewNode(javascript()->BitwiseAnd(hints), lhs, 1124 Reduction r = Reduce(graph()->NewNode(javascript()->BitwiseAnd(hint), lhs,
1153 rhs, UndefinedConstant(), 1125 rhs, UndefinedConstant(),
1154 EmptyFrameState(), effect, control)); 1126 EmptyFrameState(), effect, control));
1155 ASSERT_TRUE(r.Changed()); 1127 ASSERT_TRUE(r.Changed());
1156 EXPECT_THAT(r.replacement(), IsSpeculativeNumberBitwiseAnd( 1128 EXPECT_THAT(r.replacement(), IsSpeculativeNumberBitwiseAnd(
1157 NumberOperationHint::kNumberOrOddball, lhs, 1129 NumberOperationHint::kNumberOrOddball, lhs,
1158 rhs, effect, control)); 1130 rhs, effect, control));
1159 } 1131 }
1160 1132
1161 // ----------------------------------------------------------------------------- 1133 // -----------------------------------------------------------------------------
1162 // JSBitwiseOr 1134 // JSBitwiseOr
1163 1135
1164 TEST_F(JSTypedLoweringTest, JSBitwiseOrWithSignedSmallHint) { 1136 TEST_F(JSTypedLoweringTest, JSBitwiseOrWithSignedSmallHint) {
1165 BinaryOperationHints const hints(BinaryOperationHints::kSignedSmall, 1137 BinaryOperationHint const hint = BinaryOperationHint::kSignedSmall;
1166 BinaryOperationHints::kSignedSmall,
1167 BinaryOperationHints::kSignedSmall);
1168 Node* lhs = Parameter(Type::Number(), 2); 1138 Node* lhs = Parameter(Type::Number(), 2);
1169 Node* rhs = Parameter(Type::Number(), 3); 1139 Node* rhs = Parameter(Type::Number(), 3);
1170 Node* effect = graph()->start(); 1140 Node* effect = graph()->start();
1171 Node* control = graph()->start(); 1141 Node* control = graph()->start();
1172 Reduction r = Reduce(graph()->NewNode(javascript()->BitwiseOr(hints), lhs, 1142 Reduction r = Reduce(graph()->NewNode(javascript()->BitwiseOr(hint), lhs, rhs,
1173 rhs, UndefinedConstant(), 1143 UndefinedConstant(), EmptyFrameState(),
1174 EmptyFrameState(), effect, control)); 1144 effect, control));
1175 ASSERT_TRUE(r.Changed()); 1145 ASSERT_TRUE(r.Changed());
1176 EXPECT_THAT(r.replacement(), 1146 EXPECT_THAT(r.replacement(),
1177 IsSpeculativeNumberBitwiseOr(NumberOperationHint::kSignedSmall, 1147 IsSpeculativeNumberBitwiseOr(NumberOperationHint::kSignedSmall,
1178 lhs, rhs, effect, control)); 1148 lhs, rhs, effect, control));
1179 } 1149 }
1180 1150
1181 TEST_F(JSTypedLoweringTest, JSBitwiseOrWithSigned32Hint) { 1151 TEST_F(JSTypedLoweringTest, JSBitwiseOrWithSigned32Hint) {
1182 BinaryOperationHints const hints(BinaryOperationHints::kSigned32, 1152 BinaryOperationHint const hint = BinaryOperationHint::kSigned32;
1183 BinaryOperationHints::kSigned32,
1184 BinaryOperationHints::kSigned32);
1185 Node* lhs = Parameter(Type::Number(), 2); 1153 Node* lhs = Parameter(Type::Number(), 2);
1186 Node* rhs = Parameter(Type::Number(), 3); 1154 Node* rhs = Parameter(Type::Number(), 3);
1187 Node* effect = graph()->start(); 1155 Node* effect = graph()->start();
1188 Node* control = graph()->start(); 1156 Node* control = graph()->start();
1189 Reduction r = Reduce(graph()->NewNode(javascript()->BitwiseOr(hints), lhs, 1157 Reduction r = Reduce(graph()->NewNode(javascript()->BitwiseOr(hint), lhs, rhs,
1190 rhs, UndefinedConstant(), 1158 UndefinedConstant(), EmptyFrameState(),
1191 EmptyFrameState(), effect, control)); 1159 effect, control));
1192 ASSERT_TRUE(r.Changed()); 1160 ASSERT_TRUE(r.Changed());
1193 EXPECT_THAT(r.replacement(), 1161 EXPECT_THAT(r.replacement(),
1194 IsSpeculativeNumberBitwiseOr(NumberOperationHint::kSigned32, lhs, 1162 IsSpeculativeNumberBitwiseOr(NumberOperationHint::kSigned32, lhs,
1195 rhs, effect, control)); 1163 rhs, effect, control));
1196 } 1164 }
1197 1165
1198 TEST_F(JSTypedLoweringTest, JSBitwiseOrWithNumberOrOddballHint) { 1166 TEST_F(JSTypedLoweringTest, JSBitwiseOrWithNumberOrOddballHint) {
1199 BinaryOperationHints const hints(BinaryOperationHints::kNumberOrOddball, 1167 BinaryOperationHint const hint = BinaryOperationHint::kNumberOrOddball;
1200 BinaryOperationHints::kNumberOrOddball,
1201 BinaryOperationHints::kNumberOrOddball);
1202 Node* lhs = Parameter(Type::Number(), 2); 1168 Node* lhs = Parameter(Type::Number(), 2);
1203 Node* rhs = Parameter(Type::Number(), 3); 1169 Node* rhs = Parameter(Type::Number(), 3);
1204 Node* effect = graph()->start(); 1170 Node* effect = graph()->start();
1205 Node* control = graph()->start(); 1171 Node* control = graph()->start();
1206 Reduction r = Reduce(graph()->NewNode(javascript()->BitwiseOr(hints), lhs, 1172 Reduction r = Reduce(graph()->NewNode(javascript()->BitwiseOr(hint), lhs, rhs,
1207 rhs, UndefinedConstant(), 1173 UndefinedConstant(), EmptyFrameState(),
1208 EmptyFrameState(), effect, control)); 1174 effect, control));
1209 ASSERT_TRUE(r.Changed()); 1175 ASSERT_TRUE(r.Changed());
1210 EXPECT_THAT(r.replacement(), IsSpeculativeNumberBitwiseOr( 1176 EXPECT_THAT(r.replacement(), IsSpeculativeNumberBitwiseOr(
1211 NumberOperationHint::kNumberOrOddball, lhs, 1177 NumberOperationHint::kNumberOrOddball, lhs,
1212 rhs, effect, control)); 1178 rhs, effect, control));
1213 } 1179 }
1214 1180
1215 // ----------------------------------------------------------------------------- 1181 // -----------------------------------------------------------------------------
1216 // JSBitwiseXor 1182 // JSBitwiseXor
1217 1183
1218 TEST_F(JSTypedLoweringTest, JSBitwiseXorWithSignedSmallHint) { 1184 TEST_F(JSTypedLoweringTest, JSBitwiseXorWithSignedSmallHint) {
1219 BinaryOperationHints const hints(BinaryOperationHints::kSignedSmall, 1185 BinaryOperationHint const hint = BinaryOperationHint::kSignedSmall;
1220 BinaryOperationHints::kSignedSmall,
1221 BinaryOperationHints::kSignedSmall);
1222 Node* lhs = Parameter(Type::Number(), 2); 1186 Node* lhs = Parameter(Type::Number(), 2);
1223 Node* rhs = Parameter(Type::Number(), 3); 1187 Node* rhs = Parameter(Type::Number(), 3);
1224 Node* effect = graph()->start(); 1188 Node* effect = graph()->start();
1225 Node* control = graph()->start(); 1189 Node* control = graph()->start();
1226 Reduction r = Reduce(graph()->NewNode(javascript()->BitwiseXor(hints), lhs, 1190 Reduction r = Reduce(graph()->NewNode(javascript()->BitwiseXor(hint), lhs,
1227 rhs, UndefinedConstant(), 1191 rhs, UndefinedConstant(),
1228 EmptyFrameState(), effect, control)); 1192 EmptyFrameState(), effect, control));
1229 ASSERT_TRUE(r.Changed()); 1193 ASSERT_TRUE(r.Changed());
1230 EXPECT_THAT(r.replacement(), 1194 EXPECT_THAT(r.replacement(),
1231 IsSpeculativeNumberBitwiseXor(NumberOperationHint::kSignedSmall, 1195 IsSpeculativeNumberBitwiseXor(NumberOperationHint::kSignedSmall,
1232 lhs, rhs, effect, control)); 1196 lhs, rhs, effect, control));
1233 } 1197 }
1234 1198
1235 TEST_F(JSTypedLoweringTest, JSBitwiseXorWithSigned32Hint) { 1199 TEST_F(JSTypedLoweringTest, JSBitwiseXorWithSigned32Hint) {
1236 BinaryOperationHints const hints(BinaryOperationHints::kSigned32, 1200 BinaryOperationHint const hint = BinaryOperationHint::kSigned32;
1237 BinaryOperationHints::kSigned32,
1238 BinaryOperationHints::kSigned32);
1239 Node* lhs = Parameter(Type::Number(), 2); 1201 Node* lhs = Parameter(Type::Number(), 2);
1240 Node* rhs = Parameter(Type::Number(), 3); 1202 Node* rhs = Parameter(Type::Number(), 3);
1241 Node* effect = graph()->start(); 1203 Node* effect = graph()->start();
1242 Node* control = graph()->start(); 1204 Node* control = graph()->start();
1243 Reduction r = Reduce(graph()->NewNode(javascript()->BitwiseXor(hints), lhs, 1205 Reduction r = Reduce(graph()->NewNode(javascript()->BitwiseXor(hint), lhs,
1244 rhs, UndefinedConstant(), 1206 rhs, UndefinedConstant(),
1245 EmptyFrameState(), effect, control)); 1207 EmptyFrameState(), effect, control));
1246 ASSERT_TRUE(r.Changed()); 1208 ASSERT_TRUE(r.Changed());
1247 EXPECT_THAT(r.replacement(), 1209 EXPECT_THAT(r.replacement(),
1248 IsSpeculativeNumberBitwiseXor(NumberOperationHint::kSigned32, lhs, 1210 IsSpeculativeNumberBitwiseXor(NumberOperationHint::kSigned32, lhs,
1249 rhs, effect, control)); 1211 rhs, effect, control));
1250 } 1212 }
1251 1213
1252 TEST_F(JSTypedLoweringTest, JSBitwiseXorWithNumberOrOddballHint) { 1214 TEST_F(JSTypedLoweringTest, JSBitwiseXorWithNumberOrOddballHint) {
1253 BinaryOperationHints const hints(BinaryOperationHints::kNumberOrOddball, 1215 BinaryOperationHint const hint = BinaryOperationHint::kNumberOrOddball;
1254 BinaryOperationHints::kNumberOrOddball,
1255 BinaryOperationHints::kNumberOrOddball);
1256 Node* lhs = Parameter(Type::Number(), 2); 1216 Node* lhs = Parameter(Type::Number(), 2);
1257 Node* rhs = Parameter(Type::Number(), 3); 1217 Node* rhs = Parameter(Type::Number(), 3);
1258 Node* effect = graph()->start(); 1218 Node* effect = graph()->start();
1259 Node* control = graph()->start(); 1219 Node* control = graph()->start();
1260 Reduction r = Reduce(graph()->NewNode(javascript()->BitwiseXor(hints), lhs, 1220 Reduction r = Reduce(graph()->NewNode(javascript()->BitwiseXor(hint), lhs,
1261 rhs, UndefinedConstant(), 1221 rhs, UndefinedConstant(),
1262 EmptyFrameState(), effect, control)); 1222 EmptyFrameState(), effect, control));
1263 ASSERT_TRUE(r.Changed()); 1223 ASSERT_TRUE(r.Changed());
1264 EXPECT_THAT(r.replacement(), IsSpeculativeNumberBitwiseXor( 1224 EXPECT_THAT(r.replacement(), IsSpeculativeNumberBitwiseXor(
1265 NumberOperationHint::kNumberOrOddball, lhs, 1225 NumberOperationHint::kNumberOrOddball, lhs,
1266 rhs, effect, control)); 1226 rhs, effect, control));
1267 } 1227 }
1268 1228
1269 } // namespace compiler 1229 } // namespace compiler
1270 } // namespace internal 1230 } // namespace internal
1271 } // namespace v8 1231 } // namespace v8
OLDNEW
« no previous file with comments | « test/cctest/compiler/test-js-typed-lowering.cc ('k') | test/unittests/compiler/typer-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698