| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. Use of this | 1 // Copyright 2014 the V8 project authors. All rights reserved. Use of this |
| 2 // source code is governed by a BSD-style license that can be found in the | 2 // source code is governed by a BSD-style license that can be found in the |
| 3 // LICENSE file. | 3 // 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 <cmath> | 8 #include <cmath> |
| 9 #include <functional> | 9 #include <functional> |
| 10 #include <limits> | 10 #include <limits> |
| 11 | 11 |
| 12 #include "src/base/bits.h" | 12 #include "src/base/bits.h" |
| 13 #include "src/base/utils/random-number-generator.h" | 13 #include "src/base/utils/random-number-generator.h" |
| 14 #include "src/codegen.h" | 14 #include "src/codegen.h" |
| 15 #include "test/cctest/cctest.h" | 15 #include "test/cctest/cctest.h" |
| 16 #include "test/cctest/compiler/codegen-tester.h" | 16 #include "test/cctest/compiler/codegen-tester.h" |
| 17 #include "test/cctest/compiler/graph-builder-tester.h" | 17 #include "test/cctest/compiler/graph-builder-tester.h" |
| 18 #include "test/cctest/compiler/value-helper.h" | 18 #include "test/cctest/compiler/value-helper.h" |
| 19 | 19 |
| 20 using namespace v8::base; | 20 using namespace v8::base; |
| 21 | 21 |
| 22 namespace v8 { | 22 namespace v8 { |
| 23 namespace internal { | 23 namespace internal { |
| 24 namespace compiler { | 24 namespace compiler { |
| 25 | 25 |
| 26 typedef RawMachineAssembler::Label MLabel; | |
| 27 | |
| 28 | 26 |
| 29 TEST(RunInt32Add) { | 27 TEST(RunInt32Add) { |
| 30 RawMachineAssemblerTester<int32_t> m; | 28 RawMachineAssemblerTester<int32_t> m; |
| 31 Node* add = m.Int32Add(m.Int32Constant(0), m.Int32Constant(1)); | 29 Node* add = m.Int32Add(m.Int32Constant(0), m.Int32Constant(1)); |
| 32 m.Return(add); | 30 m.Return(add); |
| 33 CHECK_EQ(1, m.Call()); | 31 CHECK_EQ(1, m.Call()); |
| 34 } | 32 } |
| 35 | 33 |
| 36 | 34 |
| 37 TEST(RunWord32Ctz) { | 35 TEST(RunWord32Ctz) { |
| (...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 | 418 |
| 421 | 419 |
| 422 // TODO(titzer): add tests that run 64-bit integer operations. | 420 // TODO(titzer): add tests that run 64-bit integer operations. |
| 423 #endif // V8_TARGET_ARCH_64_BIT | 421 #endif // V8_TARGET_ARCH_64_BIT |
| 424 | 422 |
| 425 | 423 |
| 426 TEST(RunGoto) { | 424 TEST(RunGoto) { |
| 427 RawMachineAssemblerTester<int32_t> m; | 425 RawMachineAssemblerTester<int32_t> m; |
| 428 int constant = 99999; | 426 int constant = 99999; |
| 429 | 427 |
| 430 MLabel next; | 428 RawMachineLabel next; |
| 431 m.Goto(&next); | 429 m.Goto(&next); |
| 432 m.Bind(&next); | 430 m.Bind(&next); |
| 433 m.Return(m.Int32Constant(constant)); | 431 m.Return(m.Int32Constant(constant)); |
| 434 | 432 |
| 435 CHECK_EQ(constant, m.Call()); | 433 CHECK_EQ(constant, m.Call()); |
| 436 } | 434 } |
| 437 | 435 |
| 438 | 436 |
| 439 TEST(RunGotoMultiple) { | 437 TEST(RunGotoMultiple) { |
| 440 RawMachineAssemblerTester<int32_t> m; | 438 RawMachineAssemblerTester<int32_t> m; |
| 441 int constant = 9999977; | 439 int constant = 9999977; |
| 442 | 440 |
| 443 MLabel labels[10]; | 441 RawMachineLabel labels[10]; |
| 444 for (size_t i = 0; i < arraysize(labels); i++) { | 442 for (size_t i = 0; i < arraysize(labels); i++) { |
| 445 m.Goto(&labels[i]); | 443 m.Goto(&labels[i]); |
| 446 m.Bind(&labels[i]); | 444 m.Bind(&labels[i]); |
| 447 } | 445 } |
| 448 m.Return(m.Int32Constant(constant)); | 446 m.Return(m.Int32Constant(constant)); |
| 449 | 447 |
| 450 CHECK_EQ(constant, m.Call()); | 448 CHECK_EQ(constant, m.Call()); |
| 451 } | 449 } |
| 452 | 450 |
| 453 | 451 |
| 454 TEST(RunBranch) { | 452 TEST(RunBranch) { |
| 455 RawMachineAssemblerTester<int32_t> m; | 453 RawMachineAssemblerTester<int32_t> m; |
| 456 int constant = 999777; | 454 int constant = 999777; |
| 457 | 455 |
| 458 MLabel blocka, blockb; | 456 RawMachineLabel blocka, blockb; |
| 459 m.Branch(m.Int32Constant(0), &blocka, &blockb); | 457 m.Branch(m.Int32Constant(0), &blocka, &blockb); |
| 460 m.Bind(&blocka); | 458 m.Bind(&blocka); |
| 461 m.Return(m.Int32Constant(0 - constant)); | 459 m.Return(m.Int32Constant(0 - constant)); |
| 462 m.Bind(&blockb); | 460 m.Bind(&blockb); |
| 463 m.Return(m.Int32Constant(constant)); | 461 m.Return(m.Int32Constant(constant)); |
| 464 | 462 |
| 465 CHECK_EQ(constant, m.Call()); | 463 CHECK_EQ(constant, m.Call()); |
| 466 } | 464 } |
| 467 | 465 |
| 468 | 466 |
| 469 TEST(RunDiamond2) { | 467 TEST(RunDiamond2) { |
| 470 RawMachineAssemblerTester<int32_t> m; | 468 RawMachineAssemblerTester<int32_t> m; |
| 471 | 469 |
| 472 int constant = 995666; | 470 int constant = 995666; |
| 473 | 471 |
| 474 MLabel blocka, blockb, end; | 472 RawMachineLabel blocka, blockb, end; |
| 475 m.Branch(m.Int32Constant(0), &blocka, &blockb); | 473 m.Branch(m.Int32Constant(0), &blocka, &blockb); |
| 476 m.Bind(&blocka); | 474 m.Bind(&blocka); |
| 477 m.Goto(&end); | 475 m.Goto(&end); |
| 478 m.Bind(&blockb); | 476 m.Bind(&blockb); |
| 479 m.Goto(&end); | 477 m.Goto(&end); |
| 480 m.Bind(&end); | 478 m.Bind(&end); |
| 481 m.Return(m.Int32Constant(constant)); | 479 m.Return(m.Int32Constant(constant)); |
| 482 | 480 |
| 483 CHECK_EQ(constant, m.Call()); | 481 CHECK_EQ(constant, m.Call()); |
| 484 } | 482 } |
| 485 | 483 |
| 486 | 484 |
| 487 TEST(RunLoop) { | 485 TEST(RunLoop) { |
| 488 RawMachineAssemblerTester<int32_t> m; | 486 RawMachineAssemblerTester<int32_t> m; |
| 489 int constant = 999555; | 487 int constant = 999555; |
| 490 | 488 |
| 491 MLabel header, body, exit; | 489 RawMachineLabel header, body, exit; |
| 492 m.Goto(&header); | 490 m.Goto(&header); |
| 493 m.Bind(&header); | 491 m.Bind(&header); |
| 494 m.Branch(m.Int32Constant(0), &body, &exit); | 492 m.Branch(m.Int32Constant(0), &body, &exit); |
| 495 m.Bind(&body); | 493 m.Bind(&body); |
| 496 m.Goto(&header); | 494 m.Goto(&header); |
| 497 m.Bind(&exit); | 495 m.Bind(&exit); |
| 498 m.Return(m.Int32Constant(constant)); | 496 m.Return(m.Int32Constant(constant)); |
| 499 | 497 |
| 500 CHECK_EQ(constant, m.Call()); | 498 CHECK_EQ(constant, m.Call()); |
| 501 } | 499 } |
| 502 | 500 |
| 503 | 501 |
| 504 template <typename R> | 502 template <typename R> |
| 505 static void BuildDiamondPhi(RawMachineAssemblerTester<R>* m, Node* cond_node, | 503 static void BuildDiamondPhi(RawMachineAssemblerTester<R>* m, Node* cond_node, |
| 506 MachineType type, Node* true_node, | 504 MachineType type, Node* true_node, |
| 507 Node* false_node) { | 505 Node* false_node) { |
| 508 MLabel blocka, blockb, end; | 506 RawMachineLabel blocka, blockb, end; |
| 509 m->Branch(cond_node, &blocka, &blockb); | 507 m->Branch(cond_node, &blocka, &blockb); |
| 510 m->Bind(&blocka); | 508 m->Bind(&blocka); |
| 511 m->Goto(&end); | 509 m->Goto(&end); |
| 512 m->Bind(&blockb); | 510 m->Bind(&blockb); |
| 513 m->Goto(&end); | 511 m->Goto(&end); |
| 514 | 512 |
| 515 m->Bind(&end); | 513 m->Bind(&end); |
| 516 Node* phi = m->Phi(type, true_node, false_node); | 514 Node* phi = m->Phi(type, true_node, false_node); |
| 517 m->Return(phi); | 515 m->Return(phi); |
| 518 } | 516 } |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 570 TEST(RunLoopPhiConst) { | 568 TEST(RunLoopPhiConst) { |
| 571 RawMachineAssemblerTester<int32_t> m; | 569 RawMachineAssemblerTester<int32_t> m; |
| 572 int true_val = 0x44000; | 570 int true_val = 0x44000; |
| 573 int false_val = 0x00888; | 571 int false_val = 0x00888; |
| 574 | 572 |
| 575 Node* cond_node = m.Int32Constant(0); | 573 Node* cond_node = m.Int32Constant(0); |
| 576 Node* true_node = m.Int32Constant(true_val); | 574 Node* true_node = m.Int32Constant(true_val); |
| 577 Node* false_node = m.Int32Constant(false_val); | 575 Node* false_node = m.Int32Constant(false_val); |
| 578 | 576 |
| 579 // x = false_val; while(false) { x = true_val; } return x; | 577 // x = false_val; while(false) { x = true_val; } return x; |
| 580 MLabel body, header, end; | 578 RawMachineLabel body, header, end; |
| 581 | 579 |
| 582 m.Goto(&header); | 580 m.Goto(&header); |
| 583 m.Bind(&header); | 581 m.Bind(&header); |
| 584 Node* phi = m.Phi(kMachInt32, false_node, true_node); | 582 Node* phi = m.Phi(kMachInt32, false_node, true_node); |
| 585 m.Branch(cond_node, &body, &end); | 583 m.Branch(cond_node, &body, &end); |
| 586 m.Bind(&body); | 584 m.Bind(&body); |
| 587 m.Goto(&header); | 585 m.Goto(&header); |
| 588 m.Bind(&end); | 586 m.Bind(&end); |
| 589 m.Return(phi); | 587 m.Return(phi); |
| 590 | 588 |
| 591 CHECK_EQ(false_val, m.Call()); | 589 CHECK_EQ(false_val, m.Call()); |
| 592 } | 590 } |
| 593 | 591 |
| 594 | 592 |
| 595 TEST(RunLoopPhiParam) { | 593 TEST(RunLoopPhiParam) { |
| 596 RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachInt32, kMachInt32); | 594 RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachInt32, kMachInt32); |
| 597 | 595 |
| 598 MLabel blocka, blockb, end; | 596 RawMachineLabel blocka, blockb, end; |
| 599 | 597 |
| 600 m.Goto(&blocka); | 598 m.Goto(&blocka); |
| 601 | 599 |
| 602 m.Bind(&blocka); | 600 m.Bind(&blocka); |
| 603 Node* phi = m.Phi(kMachInt32, m.Parameter(1), m.Parameter(2)); | 601 Node* phi = m.Phi(kMachInt32, m.Parameter(1), m.Parameter(2)); |
| 604 Node* cond = m.Phi(kMachInt32, m.Parameter(0), m.Int32Constant(0)); | 602 Node* cond = m.Phi(kMachInt32, m.Parameter(0), m.Int32Constant(0)); |
| 605 m.Branch(cond, &blockb, &end); | 603 m.Branch(cond, &blockb, &end); |
| 606 | 604 |
| 607 m.Bind(&blockb); | 605 m.Bind(&blockb); |
| 608 m.Goto(&blocka); | 606 m.Goto(&blocka); |
| 609 | 607 |
| 610 m.Bind(&end); | 608 m.Bind(&end); |
| 611 m.Return(phi); | 609 m.Return(phi); |
| 612 | 610 |
| 613 int32_t c1 = 0xa81903b4; | 611 int32_t c1 = 0xa81903b4; |
| 614 int32_t c2 = 0x5a1207da; | 612 int32_t c2 = 0x5a1207da; |
| 615 int result = m.Call(0, c1, c2); | 613 int result = m.Call(0, c1, c2); |
| 616 CHECK_EQ(c1, result); | 614 CHECK_EQ(c1, result); |
| 617 result = m.Call(1, c1, c2); | 615 result = m.Call(1, c1, c2); |
| 618 CHECK_EQ(c2, result); | 616 CHECK_EQ(c2, result); |
| 619 } | 617 } |
| 620 | 618 |
| 621 | 619 |
| 622 TEST(RunLoopPhiInduction) { | 620 TEST(RunLoopPhiInduction) { |
| 623 RawMachineAssemblerTester<int32_t> m; | 621 RawMachineAssemblerTester<int32_t> m; |
| 624 | 622 |
| 625 int false_val = 0x10777; | 623 int false_val = 0x10777; |
| 626 | 624 |
| 627 // x = false_val; while(false) { x++; } return x; | 625 // x = false_val; while(false) { x++; } return x; |
| 628 MLabel header, body, end; | 626 RawMachineLabel header, body, end; |
| 629 Node* false_node = m.Int32Constant(false_val); | 627 Node* false_node = m.Int32Constant(false_val); |
| 630 | 628 |
| 631 m.Goto(&header); | 629 m.Goto(&header); |
| 632 | 630 |
| 633 m.Bind(&header); | 631 m.Bind(&header); |
| 634 Node* phi = m.Phi(kMachInt32, false_node, false_node); | 632 Node* phi = m.Phi(kMachInt32, false_node, false_node); |
| 635 m.Branch(m.Int32Constant(0), &body, &end); | 633 m.Branch(m.Int32Constant(0), &body, &end); |
| 636 | 634 |
| 637 m.Bind(&body); | 635 m.Bind(&body); |
| 638 Node* add = m.Int32Add(phi, m.Int32Constant(1)); | 636 Node* add = m.Int32Add(phi, m.Int32Constant(1)); |
| 639 phi->ReplaceInput(1, add); | 637 phi->ReplaceInput(1, add); |
| 640 m.Goto(&header); | 638 m.Goto(&header); |
| 641 | 639 |
| 642 m.Bind(&end); | 640 m.Bind(&end); |
| 643 m.Return(phi); | 641 m.Return(phi); |
| 644 | 642 |
| 645 CHECK_EQ(false_val, m.Call()); | 643 CHECK_EQ(false_val, m.Call()); |
| 646 } | 644 } |
| 647 | 645 |
| 648 | 646 |
| 649 TEST(RunLoopIncrement) { | 647 TEST(RunLoopIncrement) { |
| 650 RawMachineAssemblerTester<int32_t> m; | 648 RawMachineAssemblerTester<int32_t> m; |
| 651 Int32BinopTester bt(&m); | 649 Int32BinopTester bt(&m); |
| 652 | 650 |
| 653 // x = 0; while(x ^ param) { x++; } return x; | 651 // x = 0; while(x ^ param) { x++; } return x; |
| 654 MLabel header, body, end; | 652 RawMachineLabel header, body, end; |
| 655 Node* zero = m.Int32Constant(0); | 653 Node* zero = m.Int32Constant(0); |
| 656 | 654 |
| 657 m.Goto(&header); | 655 m.Goto(&header); |
| 658 | 656 |
| 659 m.Bind(&header); | 657 m.Bind(&header); |
| 660 Node* phi = m.Phi(kMachInt32, zero, zero); | 658 Node* phi = m.Phi(kMachInt32, zero, zero); |
| 661 m.Branch(m.WordXor(phi, bt.param0), &body, &end); | 659 m.Branch(m.WordXor(phi, bt.param0), &body, &end); |
| 662 | 660 |
| 663 m.Bind(&body); | 661 m.Bind(&body); |
| 664 phi->ReplaceInput(1, m.Int32Add(phi, m.Int32Constant(1))); | 662 phi->ReplaceInput(1, m.Int32Add(phi, m.Int32Constant(1))); |
| 665 m.Goto(&header); | 663 m.Goto(&header); |
| 666 | 664 |
| 667 m.Bind(&end); | 665 m.Bind(&end); |
| 668 bt.AddReturn(phi); | 666 bt.AddReturn(phi); |
| 669 | 667 |
| 670 CHECK_EQ(11, bt.call(11, 0)); | 668 CHECK_EQ(11, bt.call(11, 0)); |
| 671 CHECK_EQ(110, bt.call(110, 0)); | 669 CHECK_EQ(110, bt.call(110, 0)); |
| 672 CHECK_EQ(176, bt.call(176, 0)); | 670 CHECK_EQ(176, bt.call(176, 0)); |
| 673 } | 671 } |
| 674 | 672 |
| 675 | 673 |
| 676 TEST(RunLoopIncrement2) { | 674 TEST(RunLoopIncrement2) { |
| 677 RawMachineAssemblerTester<int32_t> m; | 675 RawMachineAssemblerTester<int32_t> m; |
| 678 Int32BinopTester bt(&m); | 676 Int32BinopTester bt(&m); |
| 679 | 677 |
| 680 // x = 0; while(x < param) { x++; } return x; | 678 // x = 0; while(x < param) { x++; } return x; |
| 681 MLabel header, body, end; | 679 RawMachineLabel header, body, end; |
| 682 Node* zero = m.Int32Constant(0); | 680 Node* zero = m.Int32Constant(0); |
| 683 | 681 |
| 684 m.Goto(&header); | 682 m.Goto(&header); |
| 685 | 683 |
| 686 m.Bind(&header); | 684 m.Bind(&header); |
| 687 Node* phi = m.Phi(kMachInt32, zero, zero); | 685 Node* phi = m.Phi(kMachInt32, zero, zero); |
| 688 m.Branch(m.Int32LessThan(phi, bt.param0), &body, &end); | 686 m.Branch(m.Int32LessThan(phi, bt.param0), &body, &end); |
| 689 | 687 |
| 690 m.Bind(&body); | 688 m.Bind(&body); |
| 691 phi->ReplaceInput(1, m.Int32Add(phi, m.Int32Constant(1))); | 689 phi->ReplaceInput(1, m.Int32Add(phi, m.Int32Constant(1))); |
| 692 m.Goto(&header); | 690 m.Goto(&header); |
| 693 | 691 |
| 694 m.Bind(&end); | 692 m.Bind(&end); |
| 695 bt.AddReturn(phi); | 693 bt.AddReturn(phi); |
| 696 | 694 |
| 697 CHECK_EQ(11, bt.call(11, 0)); | 695 CHECK_EQ(11, bt.call(11, 0)); |
| 698 CHECK_EQ(110, bt.call(110, 0)); | 696 CHECK_EQ(110, bt.call(110, 0)); |
| 699 CHECK_EQ(176, bt.call(176, 0)); | 697 CHECK_EQ(176, bt.call(176, 0)); |
| 700 CHECK_EQ(0, bt.call(-200, 0)); | 698 CHECK_EQ(0, bt.call(-200, 0)); |
| 701 } | 699 } |
| 702 | 700 |
| 703 | 701 |
| 704 TEST(RunLoopIncrement3) { | 702 TEST(RunLoopIncrement3) { |
| 705 RawMachineAssemblerTester<int32_t> m; | 703 RawMachineAssemblerTester<int32_t> m; |
| 706 Int32BinopTester bt(&m); | 704 Int32BinopTester bt(&m); |
| 707 | 705 |
| 708 // x = 0; while(x < param) { x++; } return x; | 706 // x = 0; while(x < param) { x++; } return x; |
| 709 MLabel header, body, end; | 707 RawMachineLabel header, body, end; |
| 710 Node* zero = m.Int32Constant(0); | 708 Node* zero = m.Int32Constant(0); |
| 711 | 709 |
| 712 m.Goto(&header); | 710 m.Goto(&header); |
| 713 | 711 |
| 714 m.Bind(&header); | 712 m.Bind(&header); |
| 715 Node* phi = m.Phi(kMachInt32, zero, zero); | 713 Node* phi = m.Phi(kMachInt32, zero, zero); |
| 716 m.Branch(m.Uint32LessThan(phi, bt.param0), &body, &end); | 714 m.Branch(m.Uint32LessThan(phi, bt.param0), &body, &end); |
| 717 | 715 |
| 718 m.Bind(&body); | 716 m.Bind(&body); |
| 719 phi->ReplaceInput(1, m.Int32Add(phi, m.Int32Constant(1))); | 717 phi->ReplaceInput(1, m.Int32Add(phi, m.Int32Constant(1))); |
| 720 m.Goto(&header); | 718 m.Goto(&header); |
| 721 | 719 |
| 722 m.Bind(&end); | 720 m.Bind(&end); |
| 723 bt.AddReturn(phi); | 721 bt.AddReturn(phi); |
| 724 | 722 |
| 725 CHECK_EQ(11, bt.call(11, 0)); | 723 CHECK_EQ(11, bt.call(11, 0)); |
| 726 CHECK_EQ(110, bt.call(110, 0)); | 724 CHECK_EQ(110, bt.call(110, 0)); |
| 727 CHECK_EQ(176, bt.call(176, 0)); | 725 CHECK_EQ(176, bt.call(176, 0)); |
| 728 CHECK_EQ(200, bt.call(200, 0)); | 726 CHECK_EQ(200, bt.call(200, 0)); |
| 729 } | 727 } |
| 730 | 728 |
| 731 | 729 |
| 732 TEST(RunLoopDecrement) { | 730 TEST(RunLoopDecrement) { |
| 733 RawMachineAssemblerTester<int32_t> m; | 731 RawMachineAssemblerTester<int32_t> m; |
| 734 Int32BinopTester bt(&m); | 732 Int32BinopTester bt(&m); |
| 735 | 733 |
| 736 // x = param; while(x) { x--; } return x; | 734 // x = param; while(x) { x--; } return x; |
| 737 MLabel header, body, end; | 735 RawMachineLabel header, body, end; |
| 738 | 736 |
| 739 m.Goto(&header); | 737 m.Goto(&header); |
| 740 | 738 |
| 741 m.Bind(&header); | 739 m.Bind(&header); |
| 742 Node* phi = m.Phi(kMachInt32, bt.param0, m.Int32Constant(0)); | 740 Node* phi = m.Phi(kMachInt32, bt.param0, m.Int32Constant(0)); |
| 743 m.Branch(phi, &body, &end); | 741 m.Branch(phi, &body, &end); |
| 744 | 742 |
| 745 m.Bind(&body); | 743 m.Bind(&body); |
| 746 phi->ReplaceInput(1, m.Int32Sub(phi, m.Int32Constant(1))); | 744 phi->ReplaceInput(1, m.Int32Sub(phi, m.Int32Constant(1))); |
| 747 m.Goto(&header); | 745 m.Goto(&header); |
| 748 | 746 |
| 749 m.Bind(&end); | 747 m.Bind(&end); |
| 750 bt.AddReturn(phi); | 748 bt.AddReturn(phi); |
| 751 | 749 |
| 752 CHECK_EQ(0, bt.call(11, 0)); | 750 CHECK_EQ(0, bt.call(11, 0)); |
| 753 CHECK_EQ(0, bt.call(110, 0)); | 751 CHECK_EQ(0, bt.call(110, 0)); |
| 754 CHECK_EQ(0, bt.call(197, 0)); | 752 CHECK_EQ(0, bt.call(197, 0)); |
| 755 } | 753 } |
| 756 | 754 |
| 757 | 755 |
| 758 TEST(RunLoopIncrementFloat32) { | 756 TEST(RunLoopIncrementFloat32) { |
| 759 RawMachineAssemblerTester<int32_t> m; | 757 RawMachineAssemblerTester<int32_t> m; |
| 760 | 758 |
| 761 // x = -3.0f; while(x < 10f) { x = x + 0.5f; } return (int) (double) x; | 759 // x = -3.0f; while(x < 10f) { x = x + 0.5f; } return (int) (double) x; |
| 762 MLabel header, body, end; | 760 RawMachineLabel header, body, end; |
| 763 Node* minus_3 = m.Float32Constant(-3.0f); | 761 Node* minus_3 = m.Float32Constant(-3.0f); |
| 764 Node* ten = m.Float32Constant(10.0f); | 762 Node* ten = m.Float32Constant(10.0f); |
| 765 | 763 |
| 766 m.Goto(&header); | 764 m.Goto(&header); |
| 767 | 765 |
| 768 m.Bind(&header); | 766 m.Bind(&header); |
| 769 Node* phi = m.Phi(kMachFloat32, minus_3, ten); | 767 Node* phi = m.Phi(kMachFloat32, minus_3, ten); |
| 770 m.Branch(m.Float32LessThan(phi, ten), &body, &end); | 768 m.Branch(m.Float32LessThan(phi, ten), &body, &end); |
| 771 | 769 |
| 772 m.Bind(&body); | 770 m.Bind(&body); |
| 773 phi->ReplaceInput(1, m.Float32Add(phi, m.Float32Constant(0.5f))); | 771 phi->ReplaceInput(1, m.Float32Add(phi, m.Float32Constant(0.5f))); |
| 774 m.Goto(&header); | 772 m.Goto(&header); |
| 775 | 773 |
| 776 m.Bind(&end); | 774 m.Bind(&end); |
| 777 m.Return(m.ChangeFloat64ToInt32(m.ChangeFloat32ToFloat64(phi))); | 775 m.Return(m.ChangeFloat64ToInt32(m.ChangeFloat32ToFloat64(phi))); |
| 778 | 776 |
| 779 CHECK_EQ(10, m.Call()); | 777 CHECK_EQ(10, m.Call()); |
| 780 } | 778 } |
| 781 | 779 |
| 782 | 780 |
| 783 TEST(RunLoopIncrementFloat64) { | 781 TEST(RunLoopIncrementFloat64) { |
| 784 RawMachineAssemblerTester<int32_t> m; | 782 RawMachineAssemblerTester<int32_t> m; |
| 785 | 783 |
| 786 // x = -3.0; while(x < 10) { x = x + 0.5; } return (int) x; | 784 // x = -3.0; while(x < 10) { x = x + 0.5; } return (int) x; |
| 787 MLabel header, body, end; | 785 RawMachineLabel header, body, end; |
| 788 Node* minus_3 = m.Float64Constant(-3.0); | 786 Node* minus_3 = m.Float64Constant(-3.0); |
| 789 Node* ten = m.Float64Constant(10.0); | 787 Node* ten = m.Float64Constant(10.0); |
| 790 | 788 |
| 791 m.Goto(&header); | 789 m.Goto(&header); |
| 792 | 790 |
| 793 m.Bind(&header); | 791 m.Bind(&header); |
| 794 Node* phi = m.Phi(kMachFloat64, minus_3, ten); | 792 Node* phi = m.Phi(kMachFloat64, minus_3, ten); |
| 795 m.Branch(m.Float64LessThan(phi, ten), &body, &end); | 793 m.Branch(m.Float64LessThan(phi, ten), &body, &end); |
| 796 | 794 |
| 797 m.Bind(&body); | 795 m.Bind(&body); |
| 798 phi->ReplaceInput(1, m.Float64Add(phi, m.Float64Constant(0.5))); | 796 phi->ReplaceInput(1, m.Float64Add(phi, m.Float64Constant(0.5))); |
| 799 m.Goto(&header); | 797 m.Goto(&header); |
| 800 | 798 |
| 801 m.Bind(&end); | 799 m.Bind(&end); |
| 802 m.Return(m.ChangeFloat64ToInt32(phi)); | 800 m.Return(m.ChangeFloat64ToInt32(phi)); |
| 803 | 801 |
| 804 CHECK_EQ(10, m.Call()); | 802 CHECK_EQ(10, m.Call()); |
| 805 } | 803 } |
| 806 | 804 |
| 807 | 805 |
| 808 TEST(RunSwitch1) { | 806 TEST(RunSwitch1) { |
| 809 RawMachineAssemblerTester<int32_t> m; | 807 RawMachineAssemblerTester<int32_t> m; |
| 810 | 808 |
| 811 int constant = 11223344; | 809 int constant = 11223344; |
| 812 | 810 |
| 813 MLabel block0, block1, def, end; | 811 RawMachineLabel block0, block1, def, end; |
| 814 MLabel* case_labels[] = {&block0, &block1}; | 812 RawMachineLabel* case_labels[] = {&block0, &block1}; |
| 815 int32_t case_values[] = {0, 1}; | 813 int32_t case_values[] = {0, 1}; |
| 816 m.Switch(m.Int32Constant(0), &def, case_values, case_labels, | 814 m.Switch(m.Int32Constant(0), &def, case_values, case_labels, |
| 817 arraysize(case_labels)); | 815 arraysize(case_labels)); |
| 818 m.Bind(&block0); | 816 m.Bind(&block0); |
| 819 m.Goto(&end); | 817 m.Goto(&end); |
| 820 m.Bind(&block1); | 818 m.Bind(&block1); |
| 821 m.Goto(&end); | 819 m.Goto(&end); |
| 822 m.Bind(&def); | 820 m.Bind(&def); |
| 823 m.Goto(&end); | 821 m.Goto(&end); |
| 824 m.Bind(&end); | 822 m.Bind(&end); |
| 825 m.Return(m.Int32Constant(constant)); | 823 m.Return(m.Int32Constant(constant)); |
| 826 | 824 |
| 827 CHECK_EQ(constant, m.Call()); | 825 CHECK_EQ(constant, m.Call()); |
| 828 } | 826 } |
| 829 | 827 |
| 830 | 828 |
| 831 TEST(RunSwitch2) { | 829 TEST(RunSwitch2) { |
| 832 RawMachineAssemblerTester<int32_t> m(kMachInt32); | 830 RawMachineAssemblerTester<int32_t> m(kMachInt32); |
| 833 | 831 |
| 834 MLabel blocka, blockb, blockc; | 832 RawMachineLabel blocka, blockb, blockc; |
| 835 MLabel* case_labels[] = {&blocka, &blockb}; | 833 RawMachineLabel* case_labels[] = {&blocka, &blockb}; |
| 836 int32_t case_values[] = {std::numeric_limits<int32_t>::min(), | 834 int32_t case_values[] = {std::numeric_limits<int32_t>::min(), |
| 837 std::numeric_limits<int32_t>::max()}; | 835 std::numeric_limits<int32_t>::max()}; |
| 838 m.Switch(m.Parameter(0), &blockc, case_values, case_labels, | 836 m.Switch(m.Parameter(0), &blockc, case_values, case_labels, |
| 839 arraysize(case_labels)); | 837 arraysize(case_labels)); |
| 840 m.Bind(&blocka); | 838 m.Bind(&blocka); |
| 841 m.Return(m.Int32Constant(-1)); | 839 m.Return(m.Int32Constant(-1)); |
| 842 m.Bind(&blockb); | 840 m.Bind(&blockb); |
| 843 m.Return(m.Int32Constant(1)); | 841 m.Return(m.Int32Constant(1)); |
| 844 m.Bind(&blockc); | 842 m.Bind(&blockc); |
| 845 m.Return(m.Int32Constant(0)); | 843 m.Return(m.Int32Constant(0)); |
| 846 | 844 |
| 847 CHECK_EQ(1, m.Call(std::numeric_limits<int32_t>::max())); | 845 CHECK_EQ(1, m.Call(std::numeric_limits<int32_t>::max())); |
| 848 CHECK_EQ(-1, m.Call(std::numeric_limits<int32_t>::min())); | 846 CHECK_EQ(-1, m.Call(std::numeric_limits<int32_t>::min())); |
| 849 for (int i = -100; i < 100; i += 25) { | 847 for (int i = -100; i < 100; i += 25) { |
| 850 CHECK_EQ(0, m.Call(i)); | 848 CHECK_EQ(0, m.Call(i)); |
| 851 } | 849 } |
| 852 } | 850 } |
| 853 | 851 |
| 854 | 852 |
| 855 TEST(RunSwitch3) { | 853 TEST(RunSwitch3) { |
| 856 RawMachineAssemblerTester<int32_t> m(kMachInt32); | 854 RawMachineAssemblerTester<int32_t> m(kMachInt32); |
| 857 | 855 |
| 858 MLabel blocka, blockb, blockc; | 856 RawMachineLabel blocka, blockb, blockc; |
| 859 MLabel* case_labels[] = {&blocka, &blockb}; | 857 RawMachineLabel* case_labels[] = {&blocka, &blockb}; |
| 860 int32_t case_values[] = {std::numeric_limits<int32_t>::min() + 0, | 858 int32_t case_values[] = {std::numeric_limits<int32_t>::min() + 0, |
| 861 std::numeric_limits<int32_t>::min() + 1}; | 859 std::numeric_limits<int32_t>::min() + 1}; |
| 862 m.Switch(m.Parameter(0), &blockc, case_values, case_labels, | 860 m.Switch(m.Parameter(0), &blockc, case_values, case_labels, |
| 863 arraysize(case_labels)); | 861 arraysize(case_labels)); |
| 864 m.Bind(&blocka); | 862 m.Bind(&blocka); |
| 865 m.Return(m.Int32Constant(0)); | 863 m.Return(m.Int32Constant(0)); |
| 866 m.Bind(&blockb); | 864 m.Bind(&blockb); |
| 867 m.Return(m.Int32Constant(1)); | 865 m.Return(m.Int32Constant(1)); |
| 868 m.Bind(&blockc); | 866 m.Bind(&blockc); |
| 869 m.Return(m.Int32Constant(2)); | 867 m.Return(m.Int32Constant(2)); |
| 870 | 868 |
| 871 CHECK_EQ(0, m.Call(std::numeric_limits<int32_t>::min() + 0)); | 869 CHECK_EQ(0, m.Call(std::numeric_limits<int32_t>::min() + 0)); |
| 872 CHECK_EQ(1, m.Call(std::numeric_limits<int32_t>::min() + 1)); | 870 CHECK_EQ(1, m.Call(std::numeric_limits<int32_t>::min() + 1)); |
| 873 for (int i = -100; i < 100; i += 25) { | 871 for (int i = -100; i < 100; i += 25) { |
| 874 CHECK_EQ(2, m.Call(i)); | 872 CHECK_EQ(2, m.Call(i)); |
| 875 } | 873 } |
| 876 } | 874 } |
| 877 | 875 |
| 878 | 876 |
| 879 TEST(RunSwitch4) { | 877 TEST(RunSwitch4) { |
| 880 RawMachineAssemblerTester<int32_t> m(kMachInt32); | 878 RawMachineAssemblerTester<int32_t> m(kMachInt32); |
| 881 | 879 |
| 882 const size_t kNumCases = 512; | 880 const size_t kNumCases = 512; |
| 883 const size_t kNumValues = kNumCases + 1; | 881 const size_t kNumValues = kNumCases + 1; |
| 884 int32_t values[kNumValues]; | 882 int32_t values[kNumValues]; |
| 885 m.main_isolate()->random_number_generator()->NextBytes(values, | 883 m.main_isolate()->random_number_generator()->NextBytes(values, |
| 886 sizeof(values)); | 884 sizeof(values)); |
| 887 MLabel end, def; | 885 RawMachineLabel end, def; |
| 888 int32_t case_values[kNumCases]; | 886 int32_t case_values[kNumCases]; |
| 889 MLabel* case_labels[kNumCases]; | 887 RawMachineLabel* case_labels[kNumCases]; |
| 890 Node* results[kNumValues]; | 888 Node* results[kNumValues]; |
| 891 for (size_t i = 0; i < kNumCases; ++i) { | 889 for (size_t i = 0; i < kNumCases; ++i) { |
| 892 case_values[i] = static_cast<int32_t>(i); | 890 case_values[i] = static_cast<int32_t>(i); |
| 893 case_labels[i] = new (m.main_zone()->New(sizeof(MLabel))) MLabel; | 891 case_labels[i] = |
| 892 new (m.main_zone()->New(sizeof(RawMachineLabel))) RawMachineLabel; |
| 894 } | 893 } |
| 895 m.Switch(m.Parameter(0), &def, case_values, case_labels, | 894 m.Switch(m.Parameter(0), &def, case_values, case_labels, |
| 896 arraysize(case_labels)); | 895 arraysize(case_labels)); |
| 897 for (size_t i = 0; i < kNumCases; ++i) { | 896 for (size_t i = 0; i < kNumCases; ++i) { |
| 898 m.Bind(case_labels[i]); | 897 m.Bind(case_labels[i]); |
| 899 results[i] = m.Int32Constant(values[i]); | 898 results[i] = m.Int32Constant(values[i]); |
| 900 m.Goto(&end); | 899 m.Goto(&end); |
| 901 } | 900 } |
| 902 m.Bind(&def); | 901 m.Bind(&def); |
| 903 results[kNumCases] = m.Int32Constant(values[kNumCases]); | 902 results[kNumCases] = m.Int32Constant(values[kNumCases]); |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1248 } | 1247 } |
| 1249 } | 1248 } |
| 1250 } | 1249 } |
| 1251 | 1250 |
| 1252 | 1251 |
| 1253 TEST(RunInt32AddInBranch) { | 1252 TEST(RunInt32AddInBranch) { |
| 1254 static const int32_t constant = 987654321; | 1253 static const int32_t constant = 987654321; |
| 1255 { | 1254 { |
| 1256 RawMachineAssemblerTester<int32_t> m; | 1255 RawMachineAssemblerTester<int32_t> m; |
| 1257 Int32BinopTester bt(&m); | 1256 Int32BinopTester bt(&m); |
| 1258 MLabel blocka, blockb; | 1257 RawMachineLabel blocka, blockb; |
| 1259 m.Branch( | 1258 m.Branch( |
| 1260 m.Word32Equal(m.Int32Add(bt.param0, bt.param1), m.Int32Constant(0)), | 1259 m.Word32Equal(m.Int32Add(bt.param0, bt.param1), m.Int32Constant(0)), |
| 1261 &blocka, &blockb); | 1260 &blocka, &blockb); |
| 1262 m.Bind(&blocka); | 1261 m.Bind(&blocka); |
| 1263 bt.AddReturn(m.Int32Constant(constant)); | 1262 bt.AddReturn(m.Int32Constant(constant)); |
| 1264 m.Bind(&blockb); | 1263 m.Bind(&blockb); |
| 1265 bt.AddReturn(m.Int32Constant(0 - constant)); | 1264 bt.AddReturn(m.Int32Constant(0 - constant)); |
| 1266 FOR_UINT32_INPUTS(i) { | 1265 FOR_UINT32_INPUTS(i) { |
| 1267 FOR_UINT32_INPUTS(j) { | 1266 FOR_UINT32_INPUTS(j) { |
| 1268 int32_t expected = (*i + *j) == 0 ? constant : 0 - constant; | 1267 int32_t expected = (*i + *j) == 0 ? constant : 0 - constant; |
| 1269 CHECK_EQ(expected, bt.call(*i, *j)); | 1268 CHECK_EQ(expected, bt.call(*i, *j)); |
| 1270 } | 1269 } |
| 1271 } | 1270 } |
| 1272 } | 1271 } |
| 1273 { | 1272 { |
| 1274 RawMachineAssemblerTester<int32_t> m; | 1273 RawMachineAssemblerTester<int32_t> m; |
| 1275 Int32BinopTester bt(&m); | 1274 Int32BinopTester bt(&m); |
| 1276 MLabel blocka, blockb; | 1275 RawMachineLabel blocka, blockb; |
| 1277 m.Branch( | 1276 m.Branch( |
| 1278 m.Word32NotEqual(m.Int32Add(bt.param0, bt.param1), m.Int32Constant(0)), | 1277 m.Word32NotEqual(m.Int32Add(bt.param0, bt.param1), m.Int32Constant(0)), |
| 1279 &blocka, &blockb); | 1278 &blocka, &blockb); |
| 1280 m.Bind(&blocka); | 1279 m.Bind(&blocka); |
| 1281 bt.AddReturn(m.Int32Constant(constant)); | 1280 bt.AddReturn(m.Int32Constant(constant)); |
| 1282 m.Bind(&blockb); | 1281 m.Bind(&blockb); |
| 1283 bt.AddReturn(m.Int32Constant(0 - constant)); | 1282 bt.AddReturn(m.Int32Constant(0 - constant)); |
| 1284 FOR_UINT32_INPUTS(i) { | 1283 FOR_UINT32_INPUTS(i) { |
| 1285 FOR_UINT32_INPUTS(j) { | 1284 FOR_UINT32_INPUTS(j) { |
| 1286 int32_t expected = (*i + *j) != 0 ? constant : 0 - constant; | 1285 int32_t expected = (*i + *j) != 0 ? constant : 0 - constant; |
| 1287 CHECK_EQ(expected, bt.call(*i, *j)); | 1286 CHECK_EQ(expected, bt.call(*i, *j)); |
| 1288 } | 1287 } |
| 1289 } | 1288 } |
| 1290 } | 1289 } |
| 1291 { | 1290 { |
| 1292 FOR_UINT32_INPUTS(i) { | 1291 FOR_UINT32_INPUTS(i) { |
| 1293 RawMachineAssemblerTester<uint32_t> m(kMachUint32); | 1292 RawMachineAssemblerTester<uint32_t> m(kMachUint32); |
| 1294 MLabel blocka, blockb; | 1293 RawMachineLabel blocka, blockb; |
| 1295 m.Branch(m.Word32Equal(m.Int32Add(m.Int32Constant(*i), m.Parameter(0)), | 1294 m.Branch(m.Word32Equal(m.Int32Add(m.Int32Constant(*i), m.Parameter(0)), |
| 1296 m.Int32Constant(0)), | 1295 m.Int32Constant(0)), |
| 1297 &blocka, &blockb); | 1296 &blocka, &blockb); |
| 1298 m.Bind(&blocka); | 1297 m.Bind(&blocka); |
| 1299 m.Return(m.Int32Constant(constant)); | 1298 m.Return(m.Int32Constant(constant)); |
| 1300 m.Bind(&blockb); | 1299 m.Bind(&blockb); |
| 1301 m.Return(m.Int32Constant(0 - constant)); | 1300 m.Return(m.Int32Constant(0 - constant)); |
| 1302 FOR_UINT32_INPUTS(j) { | 1301 FOR_UINT32_INPUTS(j) { |
| 1303 uint32_t expected = (*i + *j) == 0 ? constant : 0 - constant; | 1302 uint32_t expected = (*i + *j) == 0 ? constant : 0 - constant; |
| 1304 CHECK_EQ(expected, m.Call(*j)); | 1303 CHECK_EQ(expected, m.Call(*j)); |
| 1305 } | 1304 } |
| 1306 } | 1305 } |
| 1307 } | 1306 } |
| 1308 { | 1307 { |
| 1309 FOR_UINT32_INPUTS(i) { | 1308 FOR_UINT32_INPUTS(i) { |
| 1310 RawMachineAssemblerTester<uint32_t> m(kMachUint32); | 1309 RawMachineAssemblerTester<uint32_t> m(kMachUint32); |
| 1311 MLabel blocka, blockb; | 1310 RawMachineLabel blocka, blockb; |
| 1312 m.Branch(m.Word32NotEqual(m.Int32Add(m.Int32Constant(*i), m.Parameter(0)), | 1311 m.Branch(m.Word32NotEqual(m.Int32Add(m.Int32Constant(*i), m.Parameter(0)), |
| 1313 m.Int32Constant(0)), | 1312 m.Int32Constant(0)), |
| 1314 &blocka, &blockb); | 1313 &blocka, &blockb); |
| 1315 m.Bind(&blocka); | 1314 m.Bind(&blocka); |
| 1316 m.Return(m.Int32Constant(constant)); | 1315 m.Return(m.Int32Constant(constant)); |
| 1317 m.Bind(&blockb); | 1316 m.Bind(&blockb); |
| 1318 m.Return(m.Int32Constant(0 - constant)); | 1317 m.Return(m.Int32Constant(0 - constant)); |
| 1319 FOR_UINT32_INPUTS(j) { | 1318 FOR_UINT32_INPUTS(j) { |
| 1320 uint32_t expected = (*i + *j) != 0 ? constant : 0 - constant; | 1319 uint32_t expected = (*i + *j) != 0 ? constant : 0 - constant; |
| 1321 CHECK_EQ(expected, m.Call(*j)); | 1320 CHECK_EQ(expected, m.Call(*j)); |
| 1322 } | 1321 } |
| 1323 } | 1322 } |
| 1324 } | 1323 } |
| 1325 { | 1324 { |
| 1326 RawMachineAssemblerTester<void> m; | 1325 RawMachineAssemblerTester<void> m; |
| 1327 const Operator* shops[] = {m.machine()->Word32Sar(), | 1326 const Operator* shops[] = {m.machine()->Word32Sar(), |
| 1328 m.machine()->Word32Shl(), | 1327 m.machine()->Word32Shl(), |
| 1329 m.machine()->Word32Shr()}; | 1328 m.machine()->Word32Shr()}; |
| 1330 for (size_t n = 0; n < arraysize(shops); n++) { | 1329 for (size_t n = 0; n < arraysize(shops); n++) { |
| 1331 RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32, | 1330 RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32, |
| 1332 kMachUint32); | 1331 kMachUint32); |
| 1333 MLabel blocka, blockb; | 1332 RawMachineLabel blocka, blockb; |
| 1334 m.Branch(m.Word32Equal(m.Int32Add(m.Parameter(0), | 1333 m.Branch(m.Word32Equal(m.Int32Add(m.Parameter(0), |
| 1335 m.AddNode(shops[n], m.Parameter(1), | 1334 m.AddNode(shops[n], m.Parameter(1), |
| 1336 m.Parameter(2))), | 1335 m.Parameter(2))), |
| 1337 m.Int32Constant(0)), | 1336 m.Int32Constant(0)), |
| 1338 &blocka, &blockb); | 1337 &blocka, &blockb); |
| 1339 m.Bind(&blocka); | 1338 m.Bind(&blocka); |
| 1340 m.Return(m.Int32Constant(constant)); | 1339 m.Return(m.Int32Constant(constant)); |
| 1341 m.Bind(&blockb); | 1340 m.Bind(&blockb); |
| 1342 m.Return(m.Int32Constant(0 - constant)); | 1341 m.Return(m.Int32Constant(0 - constant)); |
| 1343 FOR_UINT32_INPUTS(i) { | 1342 FOR_UINT32_INPUTS(i) { |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1585 } | 1584 } |
| 1586 } | 1585 } |
| 1587 } | 1586 } |
| 1588 | 1587 |
| 1589 | 1588 |
| 1590 TEST(RunInt32SubInBranch) { | 1589 TEST(RunInt32SubInBranch) { |
| 1591 static const int constant = 987654321; | 1590 static const int constant = 987654321; |
| 1592 { | 1591 { |
| 1593 RawMachineAssemblerTester<int32_t> m; | 1592 RawMachineAssemblerTester<int32_t> m; |
| 1594 Int32BinopTester bt(&m); | 1593 Int32BinopTester bt(&m); |
| 1595 MLabel blocka, blockb; | 1594 RawMachineLabel blocka, blockb; |
| 1596 m.Branch( | 1595 m.Branch( |
| 1597 m.Word32Equal(m.Int32Sub(bt.param0, bt.param1), m.Int32Constant(0)), | 1596 m.Word32Equal(m.Int32Sub(bt.param0, bt.param1), m.Int32Constant(0)), |
| 1598 &blocka, &blockb); | 1597 &blocka, &blockb); |
| 1599 m.Bind(&blocka); | 1598 m.Bind(&blocka); |
| 1600 bt.AddReturn(m.Int32Constant(constant)); | 1599 bt.AddReturn(m.Int32Constant(constant)); |
| 1601 m.Bind(&blockb); | 1600 m.Bind(&blockb); |
| 1602 bt.AddReturn(m.Int32Constant(0 - constant)); | 1601 bt.AddReturn(m.Int32Constant(0 - constant)); |
| 1603 FOR_UINT32_INPUTS(i) { | 1602 FOR_UINT32_INPUTS(i) { |
| 1604 FOR_UINT32_INPUTS(j) { | 1603 FOR_UINT32_INPUTS(j) { |
| 1605 int32_t expected = (*i - *j) == 0 ? constant : 0 - constant; | 1604 int32_t expected = (*i - *j) == 0 ? constant : 0 - constant; |
| 1606 CHECK_EQ(expected, bt.call(*i, *j)); | 1605 CHECK_EQ(expected, bt.call(*i, *j)); |
| 1607 } | 1606 } |
| 1608 } | 1607 } |
| 1609 } | 1608 } |
| 1610 { | 1609 { |
| 1611 RawMachineAssemblerTester<int32_t> m; | 1610 RawMachineAssemblerTester<int32_t> m; |
| 1612 Int32BinopTester bt(&m); | 1611 Int32BinopTester bt(&m); |
| 1613 MLabel blocka, blockb; | 1612 RawMachineLabel blocka, blockb; |
| 1614 m.Branch( | 1613 m.Branch( |
| 1615 m.Word32NotEqual(m.Int32Sub(bt.param0, bt.param1), m.Int32Constant(0)), | 1614 m.Word32NotEqual(m.Int32Sub(bt.param0, bt.param1), m.Int32Constant(0)), |
| 1616 &blocka, &blockb); | 1615 &blocka, &blockb); |
| 1617 m.Bind(&blocka); | 1616 m.Bind(&blocka); |
| 1618 bt.AddReturn(m.Int32Constant(constant)); | 1617 bt.AddReturn(m.Int32Constant(constant)); |
| 1619 m.Bind(&blockb); | 1618 m.Bind(&blockb); |
| 1620 bt.AddReturn(m.Int32Constant(0 - constant)); | 1619 bt.AddReturn(m.Int32Constant(0 - constant)); |
| 1621 FOR_UINT32_INPUTS(i) { | 1620 FOR_UINT32_INPUTS(i) { |
| 1622 FOR_UINT32_INPUTS(j) { | 1621 FOR_UINT32_INPUTS(j) { |
| 1623 int32_t expected = (*i - *j) != 0 ? constant : 0 - constant; | 1622 int32_t expected = (*i - *j) != 0 ? constant : 0 - constant; |
| 1624 CHECK_EQ(expected, bt.call(*i, *j)); | 1623 CHECK_EQ(expected, bt.call(*i, *j)); |
| 1625 } | 1624 } |
| 1626 } | 1625 } |
| 1627 } | 1626 } |
| 1628 { | 1627 { |
| 1629 FOR_UINT32_INPUTS(i) { | 1628 FOR_UINT32_INPUTS(i) { |
| 1630 RawMachineAssemblerTester<uint32_t> m(kMachUint32); | 1629 RawMachineAssemblerTester<uint32_t> m(kMachUint32); |
| 1631 MLabel blocka, blockb; | 1630 RawMachineLabel blocka, blockb; |
| 1632 m.Branch(m.Word32Equal(m.Int32Sub(m.Int32Constant(*i), m.Parameter(0)), | 1631 m.Branch(m.Word32Equal(m.Int32Sub(m.Int32Constant(*i), m.Parameter(0)), |
| 1633 m.Int32Constant(0)), | 1632 m.Int32Constant(0)), |
| 1634 &blocka, &blockb); | 1633 &blocka, &blockb); |
| 1635 m.Bind(&blocka); | 1634 m.Bind(&blocka); |
| 1636 m.Return(m.Int32Constant(constant)); | 1635 m.Return(m.Int32Constant(constant)); |
| 1637 m.Bind(&blockb); | 1636 m.Bind(&blockb); |
| 1638 m.Return(m.Int32Constant(0 - constant)); | 1637 m.Return(m.Int32Constant(0 - constant)); |
| 1639 FOR_UINT32_INPUTS(j) { | 1638 FOR_UINT32_INPUTS(j) { |
| 1640 uint32_t expected = (*i - *j) == 0 ? constant : 0 - constant; | 1639 uint32_t expected = (*i - *j) == 0 ? constant : 0 - constant; |
| 1641 CHECK_EQ(expected, m.Call(*j)); | 1640 CHECK_EQ(expected, m.Call(*j)); |
| 1642 } | 1641 } |
| 1643 } | 1642 } |
| 1644 } | 1643 } |
| 1645 { | 1644 { |
| 1646 FOR_UINT32_INPUTS(i) { | 1645 FOR_UINT32_INPUTS(i) { |
| 1647 RawMachineAssemblerTester<int32_t> m(kMachUint32); | 1646 RawMachineAssemblerTester<int32_t> m(kMachUint32); |
| 1648 MLabel blocka, blockb; | 1647 RawMachineLabel blocka, blockb; |
| 1649 m.Branch(m.Word32NotEqual(m.Int32Sub(m.Int32Constant(*i), m.Parameter(0)), | 1648 m.Branch(m.Word32NotEqual(m.Int32Sub(m.Int32Constant(*i), m.Parameter(0)), |
| 1650 m.Int32Constant(0)), | 1649 m.Int32Constant(0)), |
| 1651 &blocka, &blockb); | 1650 &blocka, &blockb); |
| 1652 m.Bind(&blocka); | 1651 m.Bind(&blocka); |
| 1653 m.Return(m.Int32Constant(constant)); | 1652 m.Return(m.Int32Constant(constant)); |
| 1654 m.Bind(&blockb); | 1653 m.Bind(&blockb); |
| 1655 m.Return(m.Int32Constant(0 - constant)); | 1654 m.Return(m.Int32Constant(0 - constant)); |
| 1656 FOR_UINT32_INPUTS(j) { | 1655 FOR_UINT32_INPUTS(j) { |
| 1657 int32_t expected = (*i - *j) != 0 ? constant : 0 - constant; | 1656 int32_t expected = (*i - *j) != 0 ? constant : 0 - constant; |
| 1658 CHECK_EQ(expected, m.Call(*j)); | 1657 CHECK_EQ(expected, m.Call(*j)); |
| 1659 } | 1658 } |
| 1660 } | 1659 } |
| 1661 } | 1660 } |
| 1662 { | 1661 { |
| 1663 RawMachineAssemblerTester<void> m; | 1662 RawMachineAssemblerTester<void> m; |
| 1664 const Operator* shops[] = {m.machine()->Word32Sar(), | 1663 const Operator* shops[] = {m.machine()->Word32Sar(), |
| 1665 m.machine()->Word32Shl(), | 1664 m.machine()->Word32Shl(), |
| 1666 m.machine()->Word32Shr()}; | 1665 m.machine()->Word32Shr()}; |
| 1667 for (size_t n = 0; n < arraysize(shops); n++) { | 1666 for (size_t n = 0; n < arraysize(shops); n++) { |
| 1668 RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32, | 1667 RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32, |
| 1669 kMachUint32); | 1668 kMachUint32); |
| 1670 MLabel blocka, blockb; | 1669 RawMachineLabel blocka, blockb; |
| 1671 m.Branch(m.Word32Equal(m.Int32Sub(m.Parameter(0), | 1670 m.Branch(m.Word32Equal(m.Int32Sub(m.Parameter(0), |
| 1672 m.AddNode(shops[n], m.Parameter(1), | 1671 m.AddNode(shops[n], m.Parameter(1), |
| 1673 m.Parameter(2))), | 1672 m.Parameter(2))), |
| 1674 m.Int32Constant(0)), | 1673 m.Int32Constant(0)), |
| 1675 &blocka, &blockb); | 1674 &blocka, &blockb); |
| 1676 m.Bind(&blocka); | 1675 m.Bind(&blocka); |
| 1677 m.Return(m.Int32Constant(constant)); | 1676 m.Return(m.Int32Constant(constant)); |
| 1678 m.Bind(&blockb); | 1677 m.Bind(&blockb); |
| 1679 m.Return(m.Int32Constant(0 - constant)); | 1678 m.Return(m.Int32Constant(0 - constant)); |
| 1680 FOR_UINT32_INPUTS(i) { | 1679 FOR_UINT32_INPUTS(i) { |
| (...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2253 } | 2252 } |
| 2254 } | 2253 } |
| 2255 } | 2254 } |
| 2256 | 2255 |
| 2257 | 2256 |
| 2258 TEST(RunWord32AndInBranch) { | 2257 TEST(RunWord32AndInBranch) { |
| 2259 static const int constant = 987654321; | 2258 static const int constant = 987654321; |
| 2260 { | 2259 { |
| 2261 RawMachineAssemblerTester<int32_t> m; | 2260 RawMachineAssemblerTester<int32_t> m; |
| 2262 Int32BinopTester bt(&m); | 2261 Int32BinopTester bt(&m); |
| 2263 MLabel blocka, blockb; | 2262 RawMachineLabel blocka, blockb; |
| 2264 m.Branch( | 2263 m.Branch( |
| 2265 m.Word32Equal(m.Word32And(bt.param0, bt.param1), m.Int32Constant(0)), | 2264 m.Word32Equal(m.Word32And(bt.param0, bt.param1), m.Int32Constant(0)), |
| 2266 &blocka, &blockb); | 2265 &blocka, &blockb); |
| 2267 m.Bind(&blocka); | 2266 m.Bind(&blocka); |
| 2268 bt.AddReturn(m.Int32Constant(constant)); | 2267 bt.AddReturn(m.Int32Constant(constant)); |
| 2269 m.Bind(&blockb); | 2268 m.Bind(&blockb); |
| 2270 bt.AddReturn(m.Int32Constant(0 - constant)); | 2269 bt.AddReturn(m.Int32Constant(0 - constant)); |
| 2271 FOR_UINT32_INPUTS(i) { | 2270 FOR_UINT32_INPUTS(i) { |
| 2272 FOR_UINT32_INPUTS(j) { | 2271 FOR_UINT32_INPUTS(j) { |
| 2273 int32_t expected = (*i & *j) == 0 ? constant : 0 - constant; | 2272 int32_t expected = (*i & *j) == 0 ? constant : 0 - constant; |
| 2274 CHECK_EQ(expected, bt.call(*i, *j)); | 2273 CHECK_EQ(expected, bt.call(*i, *j)); |
| 2275 } | 2274 } |
| 2276 } | 2275 } |
| 2277 } | 2276 } |
| 2278 { | 2277 { |
| 2279 RawMachineAssemblerTester<int32_t> m; | 2278 RawMachineAssemblerTester<int32_t> m; |
| 2280 Int32BinopTester bt(&m); | 2279 Int32BinopTester bt(&m); |
| 2281 MLabel blocka, blockb; | 2280 RawMachineLabel blocka, blockb; |
| 2282 m.Branch( | 2281 m.Branch( |
| 2283 m.Word32NotEqual(m.Word32And(bt.param0, bt.param1), m.Int32Constant(0)), | 2282 m.Word32NotEqual(m.Word32And(bt.param0, bt.param1), m.Int32Constant(0)), |
| 2284 &blocka, &blockb); | 2283 &blocka, &blockb); |
| 2285 m.Bind(&blocka); | 2284 m.Bind(&blocka); |
| 2286 bt.AddReturn(m.Int32Constant(constant)); | 2285 bt.AddReturn(m.Int32Constant(constant)); |
| 2287 m.Bind(&blockb); | 2286 m.Bind(&blockb); |
| 2288 bt.AddReturn(m.Int32Constant(0 - constant)); | 2287 bt.AddReturn(m.Int32Constant(0 - constant)); |
| 2289 FOR_UINT32_INPUTS(i) { | 2288 FOR_UINT32_INPUTS(i) { |
| 2290 FOR_UINT32_INPUTS(j) { | 2289 FOR_UINT32_INPUTS(j) { |
| 2291 int32_t expected = (*i & *j) != 0 ? constant : 0 - constant; | 2290 int32_t expected = (*i & *j) != 0 ? constant : 0 - constant; |
| 2292 CHECK_EQ(expected, bt.call(*i, *j)); | 2291 CHECK_EQ(expected, bt.call(*i, *j)); |
| 2293 } | 2292 } |
| 2294 } | 2293 } |
| 2295 } | 2294 } |
| 2296 { | 2295 { |
| 2297 FOR_UINT32_INPUTS(i) { | 2296 FOR_UINT32_INPUTS(i) { |
| 2298 RawMachineAssemblerTester<int32_t> m(kMachUint32); | 2297 RawMachineAssemblerTester<int32_t> m(kMachUint32); |
| 2299 MLabel blocka, blockb; | 2298 RawMachineLabel blocka, blockb; |
| 2300 m.Branch(m.Word32Equal(m.Word32And(m.Int32Constant(*i), m.Parameter(0)), | 2299 m.Branch(m.Word32Equal(m.Word32And(m.Int32Constant(*i), m.Parameter(0)), |
| 2301 m.Int32Constant(0)), | 2300 m.Int32Constant(0)), |
| 2302 &blocka, &blockb); | 2301 &blocka, &blockb); |
| 2303 m.Bind(&blocka); | 2302 m.Bind(&blocka); |
| 2304 m.Return(m.Int32Constant(constant)); | 2303 m.Return(m.Int32Constant(constant)); |
| 2305 m.Bind(&blockb); | 2304 m.Bind(&blockb); |
| 2306 m.Return(m.Int32Constant(0 - constant)); | 2305 m.Return(m.Int32Constant(0 - constant)); |
| 2307 FOR_UINT32_INPUTS(j) { | 2306 FOR_UINT32_INPUTS(j) { |
| 2308 int32_t expected = (*i & *j) == 0 ? constant : 0 - constant; | 2307 int32_t expected = (*i & *j) == 0 ? constant : 0 - constant; |
| 2309 CHECK_EQ(expected, m.Call(*j)); | 2308 CHECK_EQ(expected, m.Call(*j)); |
| 2310 } | 2309 } |
| 2311 } | 2310 } |
| 2312 } | 2311 } |
| 2313 { | 2312 { |
| 2314 FOR_UINT32_INPUTS(i) { | 2313 FOR_UINT32_INPUTS(i) { |
| 2315 RawMachineAssemblerTester<int32_t> m(kMachUint32); | 2314 RawMachineAssemblerTester<int32_t> m(kMachUint32); |
| 2316 MLabel blocka, blockb; | 2315 RawMachineLabel blocka, blockb; |
| 2317 m.Branch( | 2316 m.Branch( |
| 2318 m.Word32NotEqual(m.Word32And(m.Int32Constant(*i), m.Parameter(0)), | 2317 m.Word32NotEqual(m.Word32And(m.Int32Constant(*i), m.Parameter(0)), |
| 2319 m.Int32Constant(0)), | 2318 m.Int32Constant(0)), |
| 2320 &blocka, &blockb); | 2319 &blocka, &blockb); |
| 2321 m.Bind(&blocka); | 2320 m.Bind(&blocka); |
| 2322 m.Return(m.Int32Constant(constant)); | 2321 m.Return(m.Int32Constant(constant)); |
| 2323 m.Bind(&blockb); | 2322 m.Bind(&blockb); |
| 2324 m.Return(m.Int32Constant(0 - constant)); | 2323 m.Return(m.Int32Constant(0 - constant)); |
| 2325 FOR_UINT32_INPUTS(j) { | 2324 FOR_UINT32_INPUTS(j) { |
| 2326 int32_t expected = (*i & *j) != 0 ? constant : 0 - constant; | 2325 int32_t expected = (*i & *j) != 0 ? constant : 0 - constant; |
| 2327 CHECK_EQ(expected, m.Call(*j)); | 2326 CHECK_EQ(expected, m.Call(*j)); |
| 2328 } | 2327 } |
| 2329 } | 2328 } |
| 2330 } | 2329 } |
| 2331 { | 2330 { |
| 2332 RawMachineAssemblerTester<void> m; | 2331 RawMachineAssemblerTester<void> m; |
| 2333 const Operator* shops[] = {m.machine()->Word32Sar(), | 2332 const Operator* shops[] = {m.machine()->Word32Sar(), |
| 2334 m.machine()->Word32Shl(), | 2333 m.machine()->Word32Shl(), |
| 2335 m.machine()->Word32Shr()}; | 2334 m.machine()->Word32Shr()}; |
| 2336 for (size_t n = 0; n < arraysize(shops); n++) { | 2335 for (size_t n = 0; n < arraysize(shops); n++) { |
| 2337 RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32, | 2336 RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32, |
| 2338 kMachUint32); | 2337 kMachUint32); |
| 2339 MLabel blocka, blockb; | 2338 RawMachineLabel blocka, blockb; |
| 2340 m.Branch(m.Word32Equal(m.Word32And(m.Parameter(0), | 2339 m.Branch(m.Word32Equal(m.Word32And(m.Parameter(0), |
| 2341 m.AddNode(shops[n], m.Parameter(1), | 2340 m.AddNode(shops[n], m.Parameter(1), |
| 2342 m.Parameter(2))), | 2341 m.Parameter(2))), |
| 2343 m.Int32Constant(0)), | 2342 m.Int32Constant(0)), |
| 2344 &blocka, &blockb); | 2343 &blocka, &blockb); |
| 2345 m.Bind(&blocka); | 2344 m.Bind(&blocka); |
| 2346 m.Return(m.Int32Constant(constant)); | 2345 m.Return(m.Int32Constant(constant)); |
| 2347 m.Bind(&blockb); | 2346 m.Bind(&blockb); |
| 2348 m.Return(m.Int32Constant(0 - constant)); | 2347 m.Return(m.Int32Constant(0 - constant)); |
| 2349 FOR_UINT32_INPUTS(i) { | 2348 FOR_UINT32_INPUTS(i) { |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2482 } | 2481 } |
| 2483 } | 2482 } |
| 2484 } | 2483 } |
| 2485 | 2484 |
| 2486 | 2485 |
| 2487 TEST(RunWord32OrInBranch) { | 2486 TEST(RunWord32OrInBranch) { |
| 2488 static const int constant = 987654321; | 2487 static const int constant = 987654321; |
| 2489 { | 2488 { |
| 2490 RawMachineAssemblerTester<int32_t> m; | 2489 RawMachineAssemblerTester<int32_t> m; |
| 2491 Int32BinopTester bt(&m); | 2490 Int32BinopTester bt(&m); |
| 2492 MLabel blocka, blockb; | 2491 RawMachineLabel blocka, blockb; |
| 2493 m.Branch( | 2492 m.Branch( |
| 2494 m.Word32Equal(m.Word32Or(bt.param0, bt.param1), m.Int32Constant(0)), | 2493 m.Word32Equal(m.Word32Or(bt.param0, bt.param1), m.Int32Constant(0)), |
| 2495 &blocka, &blockb); | 2494 &blocka, &blockb); |
| 2496 m.Bind(&blocka); | 2495 m.Bind(&blocka); |
| 2497 bt.AddReturn(m.Int32Constant(constant)); | 2496 bt.AddReturn(m.Int32Constant(constant)); |
| 2498 m.Bind(&blockb); | 2497 m.Bind(&blockb); |
| 2499 bt.AddReturn(m.Int32Constant(0 - constant)); | 2498 bt.AddReturn(m.Int32Constant(0 - constant)); |
| 2500 FOR_INT32_INPUTS(i) { | 2499 FOR_INT32_INPUTS(i) { |
| 2501 FOR_INT32_INPUTS(j) { | 2500 FOR_INT32_INPUTS(j) { |
| 2502 int32_t expected = (*i | *j) == 0 ? constant : 0 - constant; | 2501 int32_t expected = (*i | *j) == 0 ? constant : 0 - constant; |
| 2503 CHECK_EQ(expected, bt.call(*i, *j)); | 2502 CHECK_EQ(expected, bt.call(*i, *j)); |
| 2504 } | 2503 } |
| 2505 } | 2504 } |
| 2506 } | 2505 } |
| 2507 { | 2506 { |
| 2508 RawMachineAssemblerTester<int32_t> m; | 2507 RawMachineAssemblerTester<int32_t> m; |
| 2509 Int32BinopTester bt(&m); | 2508 Int32BinopTester bt(&m); |
| 2510 MLabel blocka, blockb; | 2509 RawMachineLabel blocka, blockb; |
| 2511 m.Branch( | 2510 m.Branch( |
| 2512 m.Word32NotEqual(m.Word32Or(bt.param0, bt.param1), m.Int32Constant(0)), | 2511 m.Word32NotEqual(m.Word32Or(bt.param0, bt.param1), m.Int32Constant(0)), |
| 2513 &blocka, &blockb); | 2512 &blocka, &blockb); |
| 2514 m.Bind(&blocka); | 2513 m.Bind(&blocka); |
| 2515 bt.AddReturn(m.Int32Constant(constant)); | 2514 bt.AddReturn(m.Int32Constant(constant)); |
| 2516 m.Bind(&blockb); | 2515 m.Bind(&blockb); |
| 2517 bt.AddReturn(m.Int32Constant(0 - constant)); | 2516 bt.AddReturn(m.Int32Constant(0 - constant)); |
| 2518 FOR_INT32_INPUTS(i) { | 2517 FOR_INT32_INPUTS(i) { |
| 2519 FOR_INT32_INPUTS(j) { | 2518 FOR_INT32_INPUTS(j) { |
| 2520 int32_t expected = (*i | *j) != 0 ? constant : 0 - constant; | 2519 int32_t expected = (*i | *j) != 0 ? constant : 0 - constant; |
| 2521 CHECK_EQ(expected, bt.call(*i, *j)); | 2520 CHECK_EQ(expected, bt.call(*i, *j)); |
| 2522 } | 2521 } |
| 2523 } | 2522 } |
| 2524 } | 2523 } |
| 2525 { | 2524 { |
| 2526 FOR_INT32_INPUTS(i) { | 2525 FOR_INT32_INPUTS(i) { |
| 2527 RawMachineAssemblerTester<int32_t> m(kMachInt32); | 2526 RawMachineAssemblerTester<int32_t> m(kMachInt32); |
| 2528 MLabel blocka, blockb; | 2527 RawMachineLabel blocka, blockb; |
| 2529 m.Branch(m.Word32Equal(m.Word32Or(m.Int32Constant(*i), m.Parameter(0)), | 2528 m.Branch(m.Word32Equal(m.Word32Or(m.Int32Constant(*i), m.Parameter(0)), |
| 2530 m.Int32Constant(0)), | 2529 m.Int32Constant(0)), |
| 2531 &blocka, &blockb); | 2530 &blocka, &blockb); |
| 2532 m.Bind(&blocka); | 2531 m.Bind(&blocka); |
| 2533 m.Return(m.Int32Constant(constant)); | 2532 m.Return(m.Int32Constant(constant)); |
| 2534 m.Bind(&blockb); | 2533 m.Bind(&blockb); |
| 2535 m.Return(m.Int32Constant(0 - constant)); | 2534 m.Return(m.Int32Constant(0 - constant)); |
| 2536 FOR_INT32_INPUTS(j) { | 2535 FOR_INT32_INPUTS(j) { |
| 2537 int32_t expected = (*i | *j) == 0 ? constant : 0 - constant; | 2536 int32_t expected = (*i | *j) == 0 ? constant : 0 - constant; |
| 2538 CHECK_EQ(expected, m.Call(*j)); | 2537 CHECK_EQ(expected, m.Call(*j)); |
| 2539 } | 2538 } |
| 2540 } | 2539 } |
| 2541 } | 2540 } |
| 2542 { | 2541 { |
| 2543 FOR_INT32_INPUTS(i) { | 2542 FOR_INT32_INPUTS(i) { |
| 2544 RawMachineAssemblerTester<int32_t> m(kMachInt32); | 2543 RawMachineAssemblerTester<int32_t> m(kMachInt32); |
| 2545 MLabel blocka, blockb; | 2544 RawMachineLabel blocka, blockb; |
| 2546 m.Branch(m.Word32NotEqual(m.Word32Or(m.Int32Constant(*i), m.Parameter(0)), | 2545 m.Branch(m.Word32NotEqual(m.Word32Or(m.Int32Constant(*i), m.Parameter(0)), |
| 2547 m.Int32Constant(0)), | 2546 m.Int32Constant(0)), |
| 2548 &blocka, &blockb); | 2547 &blocka, &blockb); |
| 2549 m.Bind(&blocka); | 2548 m.Bind(&blocka); |
| 2550 m.Return(m.Int32Constant(constant)); | 2549 m.Return(m.Int32Constant(constant)); |
| 2551 m.Bind(&blockb); | 2550 m.Bind(&blockb); |
| 2552 m.Return(m.Int32Constant(0 - constant)); | 2551 m.Return(m.Int32Constant(0 - constant)); |
| 2553 FOR_INT32_INPUTS(j) { | 2552 FOR_INT32_INPUTS(j) { |
| 2554 int32_t expected = (*i | *j) != 0 ? constant : 0 - constant; | 2553 int32_t expected = (*i | *j) != 0 ? constant : 0 - constant; |
| 2555 CHECK_EQ(expected, m.Call(*j)); | 2554 CHECK_EQ(expected, m.Call(*j)); |
| 2556 } | 2555 } |
| 2557 } | 2556 } |
| 2558 } | 2557 } |
| 2559 { | 2558 { |
| 2560 RawMachineAssemblerTester<void> m; | 2559 RawMachineAssemblerTester<void> m; |
| 2561 const Operator* shops[] = {m.machine()->Word32Sar(), | 2560 const Operator* shops[] = {m.machine()->Word32Sar(), |
| 2562 m.machine()->Word32Shl(), | 2561 m.machine()->Word32Shl(), |
| 2563 m.machine()->Word32Shr()}; | 2562 m.machine()->Word32Shr()}; |
| 2564 for (size_t n = 0; n < arraysize(shops); n++) { | 2563 for (size_t n = 0; n < arraysize(shops); n++) { |
| 2565 RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32, | 2564 RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32, |
| 2566 kMachUint32); | 2565 kMachUint32); |
| 2567 MLabel blocka, blockb; | 2566 RawMachineLabel blocka, blockb; |
| 2568 m.Branch(m.Word32Equal(m.Word32Or(m.Parameter(0), | 2567 m.Branch(m.Word32Equal(m.Word32Or(m.Parameter(0), |
| 2569 m.AddNode(shops[n], m.Parameter(1), | 2568 m.AddNode(shops[n], m.Parameter(1), |
| 2570 m.Parameter(2))), | 2569 m.Parameter(2))), |
| 2571 m.Int32Constant(0)), | 2570 m.Int32Constant(0)), |
| 2572 &blocka, &blockb); | 2571 &blocka, &blockb); |
| 2573 m.Bind(&blocka); | 2572 m.Bind(&blocka); |
| 2574 m.Return(m.Int32Constant(constant)); | 2573 m.Return(m.Int32Constant(constant)); |
| 2575 m.Bind(&blockb); | 2574 m.Bind(&blockb); |
| 2576 m.Return(m.Int32Constant(0 - constant)); | 2575 m.Return(m.Int32Constant(0 - constant)); |
| 2577 FOR_UINT32_INPUTS(i) { | 2576 FOR_UINT32_INPUTS(i) { |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2706 } | 2705 } |
| 2707 } | 2706 } |
| 2708 } | 2707 } |
| 2709 | 2708 |
| 2710 | 2709 |
| 2711 TEST(RunWord32XorInBranch) { | 2710 TEST(RunWord32XorInBranch) { |
| 2712 static const uint32_t constant = 987654321; | 2711 static const uint32_t constant = 987654321; |
| 2713 { | 2712 { |
| 2714 RawMachineAssemblerTester<int32_t> m; | 2713 RawMachineAssemblerTester<int32_t> m; |
| 2715 Uint32BinopTester bt(&m); | 2714 Uint32BinopTester bt(&m); |
| 2716 MLabel blocka, blockb; | 2715 RawMachineLabel blocka, blockb; |
| 2717 m.Branch( | 2716 m.Branch( |
| 2718 m.Word32Equal(m.Word32Xor(bt.param0, bt.param1), m.Int32Constant(0)), | 2717 m.Word32Equal(m.Word32Xor(bt.param0, bt.param1), m.Int32Constant(0)), |
| 2719 &blocka, &blockb); | 2718 &blocka, &blockb); |
| 2720 m.Bind(&blocka); | 2719 m.Bind(&blocka); |
| 2721 bt.AddReturn(m.Int32Constant(constant)); | 2720 bt.AddReturn(m.Int32Constant(constant)); |
| 2722 m.Bind(&blockb); | 2721 m.Bind(&blockb); |
| 2723 bt.AddReturn(m.Int32Constant(0 - constant)); | 2722 bt.AddReturn(m.Int32Constant(0 - constant)); |
| 2724 FOR_UINT32_INPUTS(i) { | 2723 FOR_UINT32_INPUTS(i) { |
| 2725 FOR_UINT32_INPUTS(j) { | 2724 FOR_UINT32_INPUTS(j) { |
| 2726 uint32_t expected = (*i ^ *j) == 0 ? constant : 0 - constant; | 2725 uint32_t expected = (*i ^ *j) == 0 ? constant : 0 - constant; |
| 2727 CHECK_EQ(expected, bt.call(*i, *j)); | 2726 CHECK_EQ(expected, bt.call(*i, *j)); |
| 2728 } | 2727 } |
| 2729 } | 2728 } |
| 2730 } | 2729 } |
| 2731 { | 2730 { |
| 2732 RawMachineAssemblerTester<int32_t> m; | 2731 RawMachineAssemblerTester<int32_t> m; |
| 2733 Uint32BinopTester bt(&m); | 2732 Uint32BinopTester bt(&m); |
| 2734 MLabel blocka, blockb; | 2733 RawMachineLabel blocka, blockb; |
| 2735 m.Branch( | 2734 m.Branch( |
| 2736 m.Word32NotEqual(m.Word32Xor(bt.param0, bt.param1), m.Int32Constant(0)), | 2735 m.Word32NotEqual(m.Word32Xor(bt.param0, bt.param1), m.Int32Constant(0)), |
| 2737 &blocka, &blockb); | 2736 &blocka, &blockb); |
| 2738 m.Bind(&blocka); | 2737 m.Bind(&blocka); |
| 2739 bt.AddReturn(m.Int32Constant(constant)); | 2738 bt.AddReturn(m.Int32Constant(constant)); |
| 2740 m.Bind(&blockb); | 2739 m.Bind(&blockb); |
| 2741 bt.AddReturn(m.Int32Constant(0 - constant)); | 2740 bt.AddReturn(m.Int32Constant(0 - constant)); |
| 2742 FOR_UINT32_INPUTS(i) { | 2741 FOR_UINT32_INPUTS(i) { |
| 2743 FOR_UINT32_INPUTS(j) { | 2742 FOR_UINT32_INPUTS(j) { |
| 2744 uint32_t expected = (*i ^ *j) != 0 ? constant : 0 - constant; | 2743 uint32_t expected = (*i ^ *j) != 0 ? constant : 0 - constant; |
| 2745 CHECK_EQ(expected, bt.call(*i, *j)); | 2744 CHECK_EQ(expected, bt.call(*i, *j)); |
| 2746 } | 2745 } |
| 2747 } | 2746 } |
| 2748 } | 2747 } |
| 2749 { | 2748 { |
| 2750 FOR_UINT32_INPUTS(i) { | 2749 FOR_UINT32_INPUTS(i) { |
| 2751 RawMachineAssemblerTester<uint32_t> m(kMachUint32); | 2750 RawMachineAssemblerTester<uint32_t> m(kMachUint32); |
| 2752 MLabel blocka, blockb; | 2751 RawMachineLabel blocka, blockb; |
| 2753 m.Branch(m.Word32Equal(m.Word32Xor(m.Int32Constant(*i), m.Parameter(0)), | 2752 m.Branch(m.Word32Equal(m.Word32Xor(m.Int32Constant(*i), m.Parameter(0)), |
| 2754 m.Int32Constant(0)), | 2753 m.Int32Constant(0)), |
| 2755 &blocka, &blockb); | 2754 &blocka, &blockb); |
| 2756 m.Bind(&blocka); | 2755 m.Bind(&blocka); |
| 2757 m.Return(m.Int32Constant(constant)); | 2756 m.Return(m.Int32Constant(constant)); |
| 2758 m.Bind(&blockb); | 2757 m.Bind(&blockb); |
| 2759 m.Return(m.Int32Constant(0 - constant)); | 2758 m.Return(m.Int32Constant(0 - constant)); |
| 2760 FOR_UINT32_INPUTS(j) { | 2759 FOR_UINT32_INPUTS(j) { |
| 2761 uint32_t expected = (*i ^ *j) == 0 ? constant : 0 - constant; | 2760 uint32_t expected = (*i ^ *j) == 0 ? constant : 0 - constant; |
| 2762 CHECK_EQ(expected, m.Call(*j)); | 2761 CHECK_EQ(expected, m.Call(*j)); |
| 2763 } | 2762 } |
| 2764 } | 2763 } |
| 2765 } | 2764 } |
| 2766 { | 2765 { |
| 2767 FOR_UINT32_INPUTS(i) { | 2766 FOR_UINT32_INPUTS(i) { |
| 2768 RawMachineAssemblerTester<uint32_t> m(kMachUint32); | 2767 RawMachineAssemblerTester<uint32_t> m(kMachUint32); |
| 2769 MLabel blocka, blockb; | 2768 RawMachineLabel blocka, blockb; |
| 2770 m.Branch( | 2769 m.Branch( |
| 2771 m.Word32NotEqual(m.Word32Xor(m.Int32Constant(*i), m.Parameter(0)), | 2770 m.Word32NotEqual(m.Word32Xor(m.Int32Constant(*i), m.Parameter(0)), |
| 2772 m.Int32Constant(0)), | 2771 m.Int32Constant(0)), |
| 2773 &blocka, &blockb); | 2772 &blocka, &blockb); |
| 2774 m.Bind(&blocka); | 2773 m.Bind(&blocka); |
| 2775 m.Return(m.Int32Constant(constant)); | 2774 m.Return(m.Int32Constant(constant)); |
| 2776 m.Bind(&blockb); | 2775 m.Bind(&blockb); |
| 2777 m.Return(m.Int32Constant(0 - constant)); | 2776 m.Return(m.Int32Constant(0 - constant)); |
| 2778 FOR_UINT32_INPUTS(j) { | 2777 FOR_UINT32_INPUTS(j) { |
| 2779 uint32_t expected = (*i ^ *j) != 0 ? constant : 0 - constant; | 2778 uint32_t expected = (*i ^ *j) != 0 ? constant : 0 - constant; |
| 2780 CHECK_EQ(expected, m.Call(*j)); | 2779 CHECK_EQ(expected, m.Call(*j)); |
| 2781 } | 2780 } |
| 2782 } | 2781 } |
| 2783 } | 2782 } |
| 2784 { | 2783 { |
| 2785 RawMachineAssemblerTester<void> m; | 2784 RawMachineAssemblerTester<void> m; |
| 2786 const Operator* shops[] = {m.machine()->Word32Sar(), | 2785 const Operator* shops[] = {m.machine()->Word32Sar(), |
| 2787 m.machine()->Word32Shl(), | 2786 m.machine()->Word32Shl(), |
| 2788 m.machine()->Word32Shr()}; | 2787 m.machine()->Word32Shr()}; |
| 2789 for (size_t n = 0; n < arraysize(shops); n++) { | 2788 for (size_t n = 0; n < arraysize(shops); n++) { |
| 2790 RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32, | 2789 RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32, |
| 2791 kMachUint32); | 2790 kMachUint32); |
| 2792 MLabel blocka, blockb; | 2791 RawMachineLabel blocka, blockb; |
| 2793 m.Branch(m.Word32Equal(m.Word32Xor(m.Parameter(0), | 2792 m.Branch(m.Word32Equal(m.Word32Xor(m.Parameter(0), |
| 2794 m.AddNode(shops[n], m.Parameter(1), | 2793 m.AddNode(shops[n], m.Parameter(1), |
| 2795 m.Parameter(2))), | 2794 m.Parameter(2))), |
| 2796 m.Int32Constant(0)), | 2795 m.Int32Constant(0)), |
| 2797 &blocka, &blockb); | 2796 &blocka, &blockb); |
| 2798 m.Bind(&blocka); | 2797 m.Bind(&blocka); |
| 2799 m.Return(m.Int32Constant(constant)); | 2798 m.Return(m.Int32Constant(constant)); |
| 2800 m.Bind(&blockb); | 2799 m.Bind(&blockb); |
| 2801 m.Return(m.Int32Constant(0 - constant)); | 2800 m.Return(m.Int32Constant(0 - constant)); |
| 2802 FOR_UINT32_INPUTS(i) { | 2801 FOR_UINT32_INPUTS(i) { |
| (...skipping 1157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3960 CHECK_EQ(magic, m.Call()); | 3959 CHECK_EQ(magic, m.Call()); |
| 3961 } | 3960 } |
| 3962 | 3961 |
| 3963 | 3962 |
| 3964 TEST(RunLoopPhiInduction2) { | 3963 TEST(RunLoopPhiInduction2) { |
| 3965 RawMachineAssemblerTester<int32_t> m; | 3964 RawMachineAssemblerTester<int32_t> m; |
| 3966 | 3965 |
| 3967 int false_val = 0x10777; | 3966 int false_val = 0x10777; |
| 3968 | 3967 |
| 3969 // x = false_val; while(false) { x++; } return x; | 3968 // x = false_val; while(false) { x++; } return x; |
| 3970 MLabel header, body, end; | 3969 RawMachineLabel header, body, end; |
| 3971 Node* false_node = m.Int32Constant(false_val); | 3970 Node* false_node = m.Int32Constant(false_val); |
| 3972 m.Goto(&header); | 3971 m.Goto(&header); |
| 3973 m.Bind(&header); | 3972 m.Bind(&header); |
| 3974 Node* phi = m.Phi(kMachInt32, false_node, false_node); | 3973 Node* phi = m.Phi(kMachInt32, false_node, false_node); |
| 3975 m.Branch(m.Int32Constant(0), &body, &end); | 3974 m.Branch(m.Int32Constant(0), &body, &end); |
| 3976 m.Bind(&body); | 3975 m.Bind(&body); |
| 3977 Node* add = m.Int32Add(phi, m.Int32Constant(1)); | 3976 Node* add = m.Int32Add(phi, m.Int32Constant(1)); |
| 3978 phi->ReplaceInput(1, add); | 3977 phi->ReplaceInput(1, add); |
| 3979 m.Goto(&header); | 3978 m.Goto(&header); |
| 3980 m.Bind(&end); | 3979 m.Bind(&end); |
| 3981 m.Return(phi); | 3980 m.Return(phi); |
| 3982 | 3981 |
| 3983 CHECK_EQ(false_val, m.Call()); | 3982 CHECK_EQ(false_val, m.Call()); |
| 3984 } | 3983 } |
| 3985 | 3984 |
| 3986 | 3985 |
| 3987 TEST(RunFloatDiamond) { | 3986 TEST(RunFloatDiamond) { |
| 3988 RawMachineAssemblerTester<int32_t> m; | 3987 RawMachineAssemblerTester<int32_t> m; |
| 3989 | 3988 |
| 3990 const int magic = 99645; | 3989 const int magic = 99645; |
| 3991 float buffer = 0.1f; | 3990 float buffer = 0.1f; |
| 3992 float constant = 99.99f; | 3991 float constant = 99.99f; |
| 3993 | 3992 |
| 3994 MLabel blocka, blockb, end; | 3993 RawMachineLabel blocka, blockb, end; |
| 3995 Node* k1 = m.Float32Constant(constant); | 3994 Node* k1 = m.Float32Constant(constant); |
| 3996 Node* k2 = m.Float32Constant(0 - constant); | 3995 Node* k2 = m.Float32Constant(0 - constant); |
| 3997 m.Branch(m.Int32Constant(0), &blocka, &blockb); | 3996 m.Branch(m.Int32Constant(0), &blocka, &blockb); |
| 3998 m.Bind(&blocka); | 3997 m.Bind(&blocka); |
| 3999 m.Goto(&end); | 3998 m.Goto(&end); |
| 4000 m.Bind(&blockb); | 3999 m.Bind(&blockb); |
| 4001 m.Goto(&end); | 4000 m.Goto(&end); |
| 4002 m.Bind(&end); | 4001 m.Bind(&end); |
| 4003 Node* phi = m.Phi(kMachFloat32, k2, k1); | 4002 Node* phi = m.Phi(kMachFloat32, k2, k1); |
| 4004 m.Store(kMachFloat32, m.PointerConstant(&buffer), m.IntPtrConstant(0), phi, | 4003 m.Store(kMachFloat32, m.PointerConstant(&buffer), m.IntPtrConstant(0), phi, |
| 4005 kNoWriteBarrier); | 4004 kNoWriteBarrier); |
| 4006 m.Return(m.Int32Constant(magic)); | 4005 m.Return(m.Int32Constant(magic)); |
| 4007 | 4006 |
| 4008 CHECK_EQ(magic, m.Call()); | 4007 CHECK_EQ(magic, m.Call()); |
| 4009 CHECK(constant == buffer); | 4008 CHECK(constant == buffer); |
| 4010 } | 4009 } |
| 4011 | 4010 |
| 4012 | 4011 |
| 4013 TEST(RunDoubleDiamond) { | 4012 TEST(RunDoubleDiamond) { |
| 4014 RawMachineAssemblerTester<int32_t> m; | 4013 RawMachineAssemblerTester<int32_t> m; |
| 4015 | 4014 |
| 4016 const int magic = 99645; | 4015 const int magic = 99645; |
| 4017 double buffer = 0.1; | 4016 double buffer = 0.1; |
| 4018 double constant = 99.99; | 4017 double constant = 99.99; |
| 4019 | 4018 |
| 4020 MLabel blocka, blockb, end; | 4019 RawMachineLabel blocka, blockb, end; |
| 4021 Node* k1 = m.Float64Constant(constant); | 4020 Node* k1 = m.Float64Constant(constant); |
| 4022 Node* k2 = m.Float64Constant(0 - constant); | 4021 Node* k2 = m.Float64Constant(0 - constant); |
| 4023 m.Branch(m.Int32Constant(0), &blocka, &blockb); | 4022 m.Branch(m.Int32Constant(0), &blocka, &blockb); |
| 4024 m.Bind(&blocka); | 4023 m.Bind(&blocka); |
| 4025 m.Goto(&end); | 4024 m.Goto(&end); |
| 4026 m.Bind(&blockb); | 4025 m.Bind(&blockb); |
| 4027 m.Goto(&end); | 4026 m.Goto(&end); |
| 4028 m.Bind(&end); | 4027 m.Bind(&end); |
| 4029 Node* phi = m.Phi(kMachFloat64, k2, k1); | 4028 Node* phi = m.Phi(kMachFloat64, k2, k1); |
| 4030 m.Store(kMachFloat64, m.PointerConstant(&buffer), m.Int32Constant(0), phi, | 4029 m.Store(kMachFloat64, m.PointerConstant(&buffer), m.Int32Constant(0), phi, |
| 4031 kNoWriteBarrier); | 4030 kNoWriteBarrier); |
| 4032 m.Return(m.Int32Constant(magic)); | 4031 m.Return(m.Int32Constant(magic)); |
| 4033 | 4032 |
| 4034 CHECK_EQ(magic, m.Call()); | 4033 CHECK_EQ(magic, m.Call()); |
| 4035 CHECK_EQ(constant, buffer); | 4034 CHECK_EQ(constant, buffer); |
| 4036 } | 4035 } |
| 4037 | 4036 |
| 4038 | 4037 |
| 4039 TEST(RunRefDiamond) { | 4038 TEST(RunRefDiamond) { |
| 4040 RawMachineAssemblerTester<int32_t> m; | 4039 RawMachineAssemblerTester<int32_t> m; |
| 4041 | 4040 |
| 4042 const int magic = 99644; | 4041 const int magic = 99644; |
| 4043 Handle<String> rexpected = | 4042 Handle<String> rexpected = |
| 4044 CcTest::i_isolate()->factory()->InternalizeUtf8String("A"); | 4043 CcTest::i_isolate()->factory()->InternalizeUtf8String("A"); |
| 4045 String* buffer; | 4044 String* buffer; |
| 4046 | 4045 |
| 4047 MLabel blocka, blockb, end; | 4046 RawMachineLabel blocka, blockb, end; |
| 4048 Node* k1 = m.StringConstant("A"); | 4047 Node* k1 = m.StringConstant("A"); |
| 4049 Node* k2 = m.StringConstant("B"); | 4048 Node* k2 = m.StringConstant("B"); |
| 4050 m.Branch(m.Int32Constant(0), &blocka, &blockb); | 4049 m.Branch(m.Int32Constant(0), &blocka, &blockb); |
| 4051 m.Bind(&blocka); | 4050 m.Bind(&blocka); |
| 4052 m.Goto(&end); | 4051 m.Goto(&end); |
| 4053 m.Bind(&blockb); | 4052 m.Bind(&blockb); |
| 4054 m.Goto(&end); | 4053 m.Goto(&end); |
| 4055 m.Bind(&end); | 4054 m.Bind(&end); |
| 4056 Node* phi = m.Phi(kMachAnyTagged, k2, k1); | 4055 Node* phi = m.Phi(kMachAnyTagged, k2, k1); |
| 4057 m.Store(kMachAnyTagged, m.PointerConstant(&buffer), m.Int32Constant(0), phi, | 4056 m.Store(kMachAnyTagged, m.PointerConstant(&buffer), m.Int32Constant(0), phi, |
| 4058 kNoWriteBarrier); | 4057 kNoWriteBarrier); |
| 4059 m.Return(m.Int32Constant(magic)); | 4058 m.Return(m.Int32Constant(magic)); |
| 4060 | 4059 |
| 4061 CHECK_EQ(magic, m.Call()); | 4060 CHECK_EQ(magic, m.Call()); |
| 4062 CHECK(rexpected->SameValue(buffer)); | 4061 CHECK(rexpected->SameValue(buffer)); |
| 4063 } | 4062 } |
| 4064 | 4063 |
| 4065 | 4064 |
| 4066 TEST(RunDoubleRefDiamond) { | 4065 TEST(RunDoubleRefDiamond) { |
| 4067 RawMachineAssemblerTester<int32_t> m; | 4066 RawMachineAssemblerTester<int32_t> m; |
| 4068 | 4067 |
| 4069 const int magic = 99648; | 4068 const int magic = 99648; |
| 4070 double dbuffer = 0.1; | 4069 double dbuffer = 0.1; |
| 4071 double dconstant = 99.99; | 4070 double dconstant = 99.99; |
| 4072 Handle<String> rexpected = | 4071 Handle<String> rexpected = |
| 4073 CcTest::i_isolate()->factory()->InternalizeUtf8String("AX"); | 4072 CcTest::i_isolate()->factory()->InternalizeUtf8String("AX"); |
| 4074 String* rbuffer; | 4073 String* rbuffer; |
| 4075 | 4074 |
| 4076 MLabel blocka, blockb, end; | 4075 RawMachineLabel blocka, blockb, end; |
| 4077 Node* d1 = m.Float64Constant(dconstant); | 4076 Node* d1 = m.Float64Constant(dconstant); |
| 4078 Node* d2 = m.Float64Constant(0 - dconstant); | 4077 Node* d2 = m.Float64Constant(0 - dconstant); |
| 4079 Node* r1 = m.StringConstant("AX"); | 4078 Node* r1 = m.StringConstant("AX"); |
| 4080 Node* r2 = m.StringConstant("BX"); | 4079 Node* r2 = m.StringConstant("BX"); |
| 4081 m.Branch(m.Int32Constant(0), &blocka, &blockb); | 4080 m.Branch(m.Int32Constant(0), &blocka, &blockb); |
| 4082 m.Bind(&blocka); | 4081 m.Bind(&blocka); |
| 4083 m.Goto(&end); | 4082 m.Goto(&end); |
| 4084 m.Bind(&blockb); | 4083 m.Bind(&blockb); |
| 4085 m.Goto(&end); | 4084 m.Goto(&end); |
| 4086 m.Bind(&end); | 4085 m.Bind(&end); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 4101 TEST(RunDoubleRefDoubleDiamond) { | 4100 TEST(RunDoubleRefDoubleDiamond) { |
| 4102 RawMachineAssemblerTester<int32_t> m; | 4101 RawMachineAssemblerTester<int32_t> m; |
| 4103 | 4102 |
| 4104 const int magic = 99649; | 4103 const int magic = 99649; |
| 4105 double dbuffer = 0.1; | 4104 double dbuffer = 0.1; |
| 4106 double dconstant = 99.997; | 4105 double dconstant = 99.997; |
| 4107 Handle<String> rexpected = | 4106 Handle<String> rexpected = |
| 4108 CcTest::i_isolate()->factory()->InternalizeUtf8String("AD"); | 4107 CcTest::i_isolate()->factory()->InternalizeUtf8String("AD"); |
| 4109 String* rbuffer; | 4108 String* rbuffer; |
| 4110 | 4109 |
| 4111 MLabel blocka, blockb, mid, blockd, blocke, end; | 4110 RawMachineLabel blocka, blockb, mid, blockd, blocke, end; |
| 4112 Node* d1 = m.Float64Constant(dconstant); | 4111 Node* d1 = m.Float64Constant(dconstant); |
| 4113 Node* d2 = m.Float64Constant(0 - dconstant); | 4112 Node* d2 = m.Float64Constant(0 - dconstant); |
| 4114 Node* r1 = m.StringConstant("AD"); | 4113 Node* r1 = m.StringConstant("AD"); |
| 4115 Node* r2 = m.StringConstant("BD"); | 4114 Node* r2 = m.StringConstant("BD"); |
| 4116 m.Branch(m.Int32Constant(0), &blocka, &blockb); | 4115 m.Branch(m.Int32Constant(0), &blocka, &blockb); |
| 4117 m.Bind(&blocka); | 4116 m.Bind(&blocka); |
| 4118 m.Goto(&mid); | 4117 m.Goto(&mid); |
| 4119 m.Bind(&blockb); | 4118 m.Bind(&blockb); |
| 4120 m.Goto(&mid); | 4119 m.Goto(&mid); |
| 4121 m.Bind(&mid); | 4120 m.Bind(&mid); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 4138 m.Return(m.Int32Constant(magic)); | 4137 m.Return(m.Int32Constant(magic)); |
| 4139 | 4138 |
| 4140 CHECK_EQ(magic, m.Call()); | 4139 CHECK_EQ(magic, m.Call()); |
| 4141 CHECK_EQ(dconstant, dbuffer); | 4140 CHECK_EQ(dconstant, dbuffer); |
| 4142 CHECK(rexpected->SameValue(rbuffer)); | 4141 CHECK(rexpected->SameValue(rbuffer)); |
| 4143 } | 4142 } |
| 4144 | 4143 |
| 4145 | 4144 |
| 4146 TEST(RunDoubleLoopPhi) { | 4145 TEST(RunDoubleLoopPhi) { |
| 4147 RawMachineAssemblerTester<int32_t> m; | 4146 RawMachineAssemblerTester<int32_t> m; |
| 4148 MLabel header, body, end; | 4147 RawMachineLabel header, body, end; |
| 4149 | 4148 |
| 4150 int magic = 99773; | 4149 int magic = 99773; |
| 4151 double buffer = 0.99; | 4150 double buffer = 0.99; |
| 4152 double dconstant = 777.1; | 4151 double dconstant = 777.1; |
| 4153 | 4152 |
| 4154 Node* zero = m.Int32Constant(0); | 4153 Node* zero = m.Int32Constant(0); |
| 4155 Node* dk = m.Float64Constant(dconstant); | 4154 Node* dk = m.Float64Constant(dconstant); |
| 4156 | 4155 |
| 4157 m.Goto(&header); | 4156 m.Goto(&header); |
| 4158 m.Bind(&header); | 4157 m.Bind(&header); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 4170 } | 4169 } |
| 4171 | 4170 |
| 4172 | 4171 |
| 4173 TEST(RunCountToTenAccRaw) { | 4172 TEST(RunCountToTenAccRaw) { |
| 4174 RawMachineAssemblerTester<int32_t> m; | 4173 RawMachineAssemblerTester<int32_t> m; |
| 4175 | 4174 |
| 4176 Node* zero = m.Int32Constant(0); | 4175 Node* zero = m.Int32Constant(0); |
| 4177 Node* ten = m.Int32Constant(10); | 4176 Node* ten = m.Int32Constant(10); |
| 4178 Node* one = m.Int32Constant(1); | 4177 Node* one = m.Int32Constant(1); |
| 4179 | 4178 |
| 4180 MLabel header, body, body_cont, end; | 4179 RawMachineLabel header, body, body_cont, end; |
| 4181 | 4180 |
| 4182 m.Goto(&header); | 4181 m.Goto(&header); |
| 4183 | 4182 |
| 4184 m.Bind(&header); | 4183 m.Bind(&header); |
| 4185 Node* i = m.Phi(kMachInt32, zero, zero); | 4184 Node* i = m.Phi(kMachInt32, zero, zero); |
| 4186 Node* j = m.Phi(kMachInt32, zero, zero); | 4185 Node* j = m.Phi(kMachInt32, zero, zero); |
| 4187 m.Goto(&body); | 4186 m.Goto(&body); |
| 4188 | 4187 |
| 4189 m.Bind(&body); | 4188 m.Bind(&body); |
| 4190 Node* next_i = m.Int32Add(i, one); | 4189 Node* next_i = m.Int32Add(i, one); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 4203 } | 4202 } |
| 4204 | 4203 |
| 4205 | 4204 |
| 4206 TEST(RunCountToTenAccRaw2) { | 4205 TEST(RunCountToTenAccRaw2) { |
| 4207 RawMachineAssemblerTester<int32_t> m; | 4206 RawMachineAssemblerTester<int32_t> m; |
| 4208 | 4207 |
| 4209 Node* zero = m.Int32Constant(0); | 4208 Node* zero = m.Int32Constant(0); |
| 4210 Node* ten = m.Int32Constant(10); | 4209 Node* ten = m.Int32Constant(10); |
| 4211 Node* one = m.Int32Constant(1); | 4210 Node* one = m.Int32Constant(1); |
| 4212 | 4211 |
| 4213 MLabel header, body, body_cont, end; | 4212 RawMachineLabel header, body, body_cont, end; |
| 4214 | 4213 |
| 4215 m.Goto(&header); | 4214 m.Goto(&header); |
| 4216 | 4215 |
| 4217 m.Bind(&header); | 4216 m.Bind(&header); |
| 4218 Node* i = m.Phi(kMachInt32, zero, zero); | 4217 Node* i = m.Phi(kMachInt32, zero, zero); |
| 4219 Node* j = m.Phi(kMachInt32, zero, zero); | 4218 Node* j = m.Phi(kMachInt32, zero, zero); |
| 4220 Node* k = m.Phi(kMachInt32, zero, zero); | 4219 Node* k = m.Phi(kMachInt32, zero, zero); |
| 4221 m.Goto(&body); | 4220 m.Goto(&body); |
| 4222 | 4221 |
| 4223 m.Bind(&body); | 4222 m.Bind(&body); |
| (...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4633 | 4632 |
| 4634 TEST(RunNewSpaceConstantsInPhi) { | 4633 TEST(RunNewSpaceConstantsInPhi) { |
| 4635 RawMachineAssemblerTester<Object*> m(kMachInt32); | 4634 RawMachineAssemblerTester<Object*> m(kMachInt32); |
| 4636 | 4635 |
| 4637 Isolate* isolate = CcTest::i_isolate(); | 4636 Isolate* isolate = CcTest::i_isolate(); |
| 4638 Handle<HeapNumber> true_val = isolate->factory()->NewHeapNumber(11.2); | 4637 Handle<HeapNumber> true_val = isolate->factory()->NewHeapNumber(11.2); |
| 4639 Handle<HeapNumber> false_val = isolate->factory()->NewHeapNumber(11.3); | 4638 Handle<HeapNumber> false_val = isolate->factory()->NewHeapNumber(11.3); |
| 4640 Node* true_node = m.HeapConstant(true_val); | 4639 Node* true_node = m.HeapConstant(true_val); |
| 4641 Node* false_node = m.HeapConstant(false_val); | 4640 Node* false_node = m.HeapConstant(false_val); |
| 4642 | 4641 |
| 4643 MLabel blocka, blockb, end; | 4642 RawMachineLabel blocka, blockb, end; |
| 4644 m.Branch(m.Parameter(0), &blocka, &blockb); | 4643 m.Branch(m.Parameter(0), &blocka, &blockb); |
| 4645 m.Bind(&blocka); | 4644 m.Bind(&blocka); |
| 4646 m.Goto(&end); | 4645 m.Goto(&end); |
| 4647 m.Bind(&blockb); | 4646 m.Bind(&blockb); |
| 4648 m.Goto(&end); | 4647 m.Goto(&end); |
| 4649 | 4648 |
| 4650 m.Bind(&end); | 4649 m.Bind(&end); |
| 4651 Node* phi = m.Phi(kMachAnyTagged, true_node, false_node); | 4650 Node* phi = m.Phi(kMachAnyTagged, true_node, false_node); |
| 4652 m.Return(phi); | 4651 m.Return(phi); |
| 4653 | 4652 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4716 int expected_ovf = bits::SignedAddOverflow32(*i, *j, &expected_val); | 4715 int expected_ovf = bits::SignedAddOverflow32(*i, *j, &expected_val); |
| 4717 CHECK_EQ(expected_ovf, m.Call()); | 4716 CHECK_EQ(expected_ovf, m.Call()); |
| 4718 CHECK_EQ(expected_val, actual_val); | 4717 CHECK_EQ(expected_val, actual_val); |
| 4719 } | 4718 } |
| 4720 } | 4719 } |
| 4721 } | 4720 } |
| 4722 | 4721 |
| 4723 | 4722 |
| 4724 TEST(RunInt32AddWithOverflowInBranchP) { | 4723 TEST(RunInt32AddWithOverflowInBranchP) { |
| 4725 int constant = 911777; | 4724 int constant = 911777; |
| 4726 MLabel blocka, blockb; | 4725 RawMachineLabel blocka, blockb; |
| 4727 RawMachineAssemblerTester<int32_t> m; | 4726 RawMachineAssemblerTester<int32_t> m; |
| 4728 Int32BinopTester bt(&m); | 4727 Int32BinopTester bt(&m); |
| 4729 Node* add = m.Int32AddWithOverflow(bt.param0, bt.param1); | 4728 Node* add = m.Int32AddWithOverflow(bt.param0, bt.param1); |
| 4730 Node* ovf = m.Projection(1, add); | 4729 Node* ovf = m.Projection(1, add); |
| 4731 m.Branch(ovf, &blocka, &blockb); | 4730 m.Branch(ovf, &blocka, &blockb); |
| 4732 m.Bind(&blocka); | 4731 m.Bind(&blocka); |
| 4733 bt.AddReturn(m.Int32Constant(constant)); | 4732 bt.AddReturn(m.Int32Constant(constant)); |
| 4734 m.Bind(&blockb); | 4733 m.Bind(&blockb); |
| 4735 Node* val = m.Projection(0, add); | 4734 Node* val = m.Projection(0, add); |
| 4736 bt.AddReturn(val); | 4735 bt.AddReturn(val); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4804 int expected_ovf = bits::SignedSubOverflow32(*i, *j, &expected_val); | 4803 int expected_ovf = bits::SignedSubOverflow32(*i, *j, &expected_val); |
| 4805 CHECK_EQ(expected_ovf, m.Call()); | 4804 CHECK_EQ(expected_ovf, m.Call()); |
| 4806 CHECK_EQ(expected_val, actual_val); | 4805 CHECK_EQ(expected_val, actual_val); |
| 4807 } | 4806 } |
| 4808 } | 4807 } |
| 4809 } | 4808 } |
| 4810 | 4809 |
| 4811 | 4810 |
| 4812 TEST(RunInt32SubWithOverflowInBranchP) { | 4811 TEST(RunInt32SubWithOverflowInBranchP) { |
| 4813 int constant = 911999; | 4812 int constant = 911999; |
| 4814 MLabel blocka, blockb; | 4813 RawMachineLabel blocka, blockb; |
| 4815 RawMachineAssemblerTester<int32_t> m; | 4814 RawMachineAssemblerTester<int32_t> m; |
| 4816 Int32BinopTester bt(&m); | 4815 Int32BinopTester bt(&m); |
| 4817 Node* sub = m.Int32SubWithOverflow(bt.param0, bt.param1); | 4816 Node* sub = m.Int32SubWithOverflow(bt.param0, bt.param1); |
| 4818 Node* ovf = m.Projection(1, sub); | 4817 Node* ovf = m.Projection(1, sub); |
| 4819 m.Branch(ovf, &blocka, &blockb); | 4818 m.Branch(ovf, &blocka, &blockb); |
| 4820 m.Bind(&blocka); | 4819 m.Bind(&blocka); |
| 4821 bt.AddReturn(m.Int32Constant(constant)); | 4820 bt.AddReturn(m.Int32Constant(constant)); |
| 4822 m.Bind(&blockb); | 4821 m.Bind(&blockb); |
| 4823 Node* val = m.Projection(0, sub); | 4822 Node* val = m.Projection(0, sub); |
| 4824 bt.AddReturn(val); | 4823 bt.AddReturn(val); |
| 4825 FOR_INT32_INPUTS(i) { | 4824 FOR_INT32_INPUTS(i) { |
| 4826 FOR_INT32_INPUTS(j) { | 4825 FOR_INT32_INPUTS(j) { |
| 4827 int32_t expected; | 4826 int32_t expected; |
| 4828 if (bits::SignedSubOverflow32(*i, *j, &expected)) expected = constant; | 4827 if (bits::SignedSubOverflow32(*i, *j, &expected)) expected = constant; |
| 4829 CHECK_EQ(expected, bt.call(*i, *j)); | 4828 CHECK_EQ(expected, bt.call(*i, *j)); |
| 4830 } | 4829 } |
| 4831 } | 4830 } |
| 4832 } | 4831 } |
| 4833 | 4832 |
| 4834 | 4833 |
| 4835 TEST(RunWord64EqualInBranchP) { | 4834 TEST(RunWord64EqualInBranchP) { |
| 4836 int64_t input; | 4835 int64_t input; |
| 4837 MLabel blocka, blockb; | 4836 RawMachineLabel blocka, blockb; |
| 4838 RawMachineAssemblerTester<int64_t> m; | 4837 RawMachineAssemblerTester<int64_t> m; |
| 4839 if (!m.machine()->Is64()) return; | 4838 if (!m.machine()->Is64()) return; |
| 4840 Node* value = m.LoadFromPointer(&input, kMachInt64); | 4839 Node* value = m.LoadFromPointer(&input, kMachInt64); |
| 4841 m.Branch(m.Word64Equal(value, m.Int64Constant(0)), &blocka, &blockb); | 4840 m.Branch(m.Word64Equal(value, m.Int64Constant(0)), &blocka, &blockb); |
| 4842 m.Bind(&blocka); | 4841 m.Bind(&blocka); |
| 4843 m.Return(m.Int32Constant(1)); | 4842 m.Return(m.Int32Constant(1)); |
| 4844 m.Bind(&blockb); | 4843 m.Bind(&blockb); |
| 4845 m.Return(m.Int32Constant(2)); | 4844 m.Return(m.Int32Constant(2)); |
| 4846 input = V8_INT64_C(0); | 4845 input = V8_INT64_C(0); |
| 4847 CHECK_EQ(1, m.Call()); | 4846 CHECK_EQ(1, m.Call()); |
| (...skipping 822 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5670 a.Return(a.Int32Constant(33)); | 5669 a.Return(a.Int32Constant(33)); |
| 5671 a.End(); | 5670 a.End(); |
| 5672 Handle<Code> code_a = a.GetCode(); | 5671 Handle<Code> code_a = a.GetCode(); |
| 5673 | 5672 |
| 5674 GraphBuilderTester<int32_t> b; | 5673 GraphBuilderTester<int32_t> b; |
| 5675 b.Return(b.Int32Constant(44)); | 5674 b.Return(b.Int32Constant(44)); |
| 5676 b.End(); | 5675 b.End(); |
| 5677 Handle<Code> code_b = b.GetCode(); | 5676 Handle<Code> code_b = b.GetCode(); |
| 5678 | 5677 |
| 5679 RawMachineAssemblerTester<int32_t> r(kMachInt32); | 5678 RawMachineAssemblerTester<int32_t> r(kMachInt32); |
| 5680 RawMachineAssembler::Label tlabel; | 5679 RawMachineLabel tlabel; |
| 5681 RawMachineAssembler::Label flabel; | 5680 RawMachineLabel flabel; |
| 5682 RawMachineAssembler::Label merge; | 5681 RawMachineLabel merge; |
| 5683 r.Branch(r.Parameter(0), &tlabel, &flabel); | 5682 r.Branch(r.Parameter(0), &tlabel, &flabel); |
| 5684 r.Bind(&tlabel); | 5683 r.Bind(&tlabel); |
| 5685 Node* fa = r.HeapConstant(code_a); | 5684 Node* fa = r.HeapConstant(code_a); |
| 5686 r.Goto(&merge); | 5685 r.Goto(&merge); |
| 5687 r.Bind(&flabel); | 5686 r.Bind(&flabel); |
| 5688 Node* fb = r.HeapConstant(code_b); | 5687 Node* fb = r.HeapConstant(code_b); |
| 5689 r.Goto(&merge); | 5688 r.Goto(&merge); |
| 5690 r.Bind(&merge); | 5689 r.Bind(&merge); |
| 5691 Node* phi = r.Phi(kMachInt32, fa, fb); | 5690 Node* phi = r.Phi(kMachInt32, fa, fb); |
| 5692 | 5691 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 5711 Node* call = r.AddNode(r.common()->Call(desc), phi); | 5710 Node* call = r.AddNode(r.common()->Call(desc), phi); |
| 5712 r.Return(call); | 5711 r.Return(call); |
| 5713 | 5712 |
| 5714 CHECK_EQ(33, r.Call(1)); | 5713 CHECK_EQ(33, r.Call(1)); |
| 5715 CHECK_EQ(44, r.Call(0)); | 5714 CHECK_EQ(44, r.Call(0)); |
| 5716 } | 5715 } |
| 5717 | 5716 |
| 5718 } // namespace compiler | 5717 } // namespace compiler |
| 5719 } // namespace internal | 5718 } // namespace internal |
| 5720 } // namespace v8 | 5719 } // namespace v8 |
| OLD | NEW |