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

Side by Side Diff: test/cctest/compiler/test-representation-change.cc

Issue 2277283002: Reland of [turbofan] Insert dummy values when changing from None type. (Closed)
Patch Set: Workaround for uninhabited representations. Created 4 years, 3 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
« no previous file with comments | « src/compiler/x87/code-generator-x87.cc ('k') | test/mjsunit/compiler/regress-638132.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <limits> 5 #include <limits>
6 6
7 #include "test/cctest/cctest.h" 7 #include "test/cctest/cctest.h"
8 #include "test/cctest/compiler/codegen-tester.h" 8 #include "test/cctest/compiler/codegen-tester.h"
9 #include "test/cctest/compiler/graph-builder-tester.h" 9 #include "test/cctest/compiler/graph-builder-tester.h"
10 #include "test/cctest/compiler/value-helper.h" 10 #include "test/cctest/compiler/value-helper.h"
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 Node* c = 486 Node* c =
487 r.changer()->GetRepresentationFor(n, from, from_type, use, use_info); 487 r.changer()->GetRepresentationFor(n, from, from_type, use, use_info);
488 488
489 CHECK_NE(c, n); 489 CHECK_NE(c, n);
490 CHECK_EQ(expected, c->opcode()); 490 CHECK_EQ(expected, c->opcode());
491 CHECK_EQ(n, c->InputAt(0)); 491 CHECK_EQ(n, c->InputAt(0));
492 } 492 }
493 493
494 TEST(SingleChanges) { 494 TEST(SingleChanges) {
495 CheckChange(IrOpcode::kChangeTaggedToBit, MachineRepresentation::kTagged, 495 CheckChange(IrOpcode::kChangeTaggedToBit, MachineRepresentation::kTagged,
496 Type::None(), MachineRepresentation::kBit); 496 Type::Boolean(), MachineRepresentation::kBit);
497 CheckChange(IrOpcode::kChangeBitToTagged, MachineRepresentation::kBit, 497 CheckChange(IrOpcode::kChangeBitToTagged, MachineRepresentation::kBit,
498 Type::None(), MachineRepresentation::kTagged); 498 Type::Boolean(), MachineRepresentation::kTagged);
499 499
500 CheckChange(IrOpcode::kChangeInt31ToTaggedSigned, 500 CheckChange(IrOpcode::kChangeInt31ToTaggedSigned,
501 MachineRepresentation::kWord32, Type::Signed31(), 501 MachineRepresentation::kWord32, Type::Signed31(),
502 MachineRepresentation::kTagged); 502 MachineRepresentation::kTagged);
503 CheckChange(IrOpcode::kChangeInt32ToTagged, MachineRepresentation::kWord32, 503 CheckChange(IrOpcode::kChangeInt32ToTagged, MachineRepresentation::kWord32,
504 Type::Signed32(), MachineRepresentation::kTagged); 504 Type::Signed32(), MachineRepresentation::kTagged);
505 CheckChange(IrOpcode::kChangeUint32ToTagged, MachineRepresentation::kWord32, 505 CheckChange(IrOpcode::kChangeUint32ToTagged, MachineRepresentation::kWord32,
506 Type::Unsigned32(), MachineRepresentation::kTagged); 506 Type::Unsigned32(), MachineRepresentation::kTagged);
507 CheckChange(IrOpcode::kChangeFloat64ToTagged, MachineRepresentation::kFloat64, 507 CheckChange(IrOpcode::kChangeFloat64ToTagged, MachineRepresentation::kFloat64,
508 Type::Number(), MachineRepresentation::kTagged); 508 Type::Number(), MachineRepresentation::kTagged);
(...skipping 30 matching lines...) Expand all
539 CheckChange(IrOpcode::kChangeInt32ToFloat64, MachineRepresentation::kWord32, 539 CheckChange(IrOpcode::kChangeInt32ToFloat64, MachineRepresentation::kWord32,
540 Type::Signed32(), MachineRepresentation::kFloat64); 540 Type::Signed32(), MachineRepresentation::kFloat64);
541 CheckChange(IrOpcode::kChangeUint32ToFloat64, MachineRepresentation::kWord32, 541 CheckChange(IrOpcode::kChangeUint32ToFloat64, MachineRepresentation::kWord32,
542 Type::Unsigned32(), MachineRepresentation::kFloat64); 542 Type::Unsigned32(), MachineRepresentation::kFloat64);
543 CheckChange(IrOpcode::kChangeFloat64ToInt32, MachineRepresentation::kFloat64, 543 CheckChange(IrOpcode::kChangeFloat64ToInt32, MachineRepresentation::kFloat64,
544 Type::Signed32(), MachineRepresentation::kWord32); 544 Type::Signed32(), MachineRepresentation::kWord32);
545 CheckChange(IrOpcode::kChangeFloat64ToUint32, MachineRepresentation::kFloat64, 545 CheckChange(IrOpcode::kChangeFloat64ToUint32, MachineRepresentation::kFloat64,
546 Type::Unsigned32(), MachineRepresentation::kWord32); 546 Type::Unsigned32(), MachineRepresentation::kWord32);
547 547
548 CheckChange(IrOpcode::kTruncateFloat64ToFloat32, 548 CheckChange(IrOpcode::kTruncateFloat64ToFloat32,
549 MachineRepresentation::kFloat64, Type::None(), 549 MachineRepresentation::kFloat64, Type::Number(),
550 MachineRepresentation::kFloat32); 550 MachineRepresentation::kFloat32);
551 551
552 // Int32,Uint32 <-> Float32 require two changes. 552 // Int32,Uint32 <-> Float32 require two changes.
553 CheckTwoChanges(IrOpcode::kChangeInt32ToFloat64, 553 CheckTwoChanges(IrOpcode::kChangeInt32ToFloat64,
554 IrOpcode::kTruncateFloat64ToFloat32, 554 IrOpcode::kTruncateFloat64ToFloat32,
555 MachineRepresentation::kWord32, Type::Signed32(), 555 MachineRepresentation::kWord32, Type::Signed32(),
556 MachineRepresentation::kFloat32); 556 MachineRepresentation::kFloat32);
557 CheckTwoChanges(IrOpcode::kChangeUint32ToFloat64, 557 CheckTwoChanges(IrOpcode::kChangeUint32ToFloat64,
558 IrOpcode::kTruncateFloat64ToFloat32, 558 IrOpcode::kTruncateFloat64ToFloat32,
559 MachineRepresentation::kWord32, Type::Unsigned32(), 559 MachineRepresentation::kWord32, Type::Unsigned32(),
560 MachineRepresentation::kFloat32); 560 MachineRepresentation::kFloat32);
561 CheckTwoChanges(IrOpcode::kChangeFloat32ToFloat64, 561 CheckTwoChanges(IrOpcode::kChangeFloat32ToFloat64,
562 IrOpcode::kChangeFloat64ToInt32, 562 IrOpcode::kChangeFloat64ToInt32,
563 MachineRepresentation::kFloat32, Type::Signed32(), 563 MachineRepresentation::kFloat32, Type::Signed32(),
564 MachineRepresentation::kWord32); 564 MachineRepresentation::kWord32);
565 CheckTwoChanges(IrOpcode::kChangeFloat32ToFloat64, 565 CheckTwoChanges(IrOpcode::kChangeFloat32ToFloat64,
566 IrOpcode::kChangeFloat64ToUint32, 566 IrOpcode::kChangeFloat64ToUint32,
567 MachineRepresentation::kFloat32, Type::Unsigned32(), 567 MachineRepresentation::kFloat32, Type::Unsigned32(),
568 MachineRepresentation::kWord32); 568 MachineRepresentation::kWord32);
569 569
570 // Float32 <-> Tagged require two changes. 570 // Float32 <-> Tagged require two changes.
571 CheckTwoChanges(IrOpcode::kChangeFloat32ToFloat64, 571 CheckTwoChanges(IrOpcode::kChangeFloat32ToFloat64,
572 IrOpcode::kChangeFloat64ToTagged, 572 IrOpcode::kChangeFloat64ToTagged,
573 MachineRepresentation::kFloat32, Type::None(), 573 MachineRepresentation::kFloat32, Type::Number(),
574 MachineRepresentation::kTagged); 574 MachineRepresentation::kTagged);
575 CheckTwoChanges(IrOpcode::kChangeTaggedToFloat64, 575 CheckTwoChanges(IrOpcode::kChangeTaggedToFloat64,
576 IrOpcode::kTruncateFloat64ToFloat32, 576 IrOpcode::kTruncateFloat64ToFloat32,
577 MachineRepresentation::kTagged, Type::None(), 577 MachineRepresentation::kTagged, Type::Number(),
578 MachineRepresentation::kFloat32); 578 MachineRepresentation::kFloat32);
579 } 579 }
580 580
581 581
582 TEST(SignednessInWord32) { 582 TEST(SignednessInWord32) {
583 RepresentationChangerTester r; 583 RepresentationChangerTester r;
584 584
585 CheckChange(IrOpcode::kChangeTaggedToInt32, MachineRepresentation::kTagged, 585 CheckChange(IrOpcode::kChangeTaggedToInt32, MachineRepresentation::kTagged,
586 Type::Signed32(), MachineRepresentation::kWord32); 586 Type::Signed32(), MachineRepresentation::kWord32);
587 CheckChange(IrOpcode::kChangeTaggedToUint32, MachineRepresentation::kTagged, 587 CheckChange(IrOpcode::kChangeTaggedToUint32, MachineRepresentation::kTagged,
588 Type::Unsigned32(), MachineRepresentation::kWord32); 588 Type::Unsigned32(), MachineRepresentation::kWord32);
589 CheckChange(IrOpcode::kChangeInt32ToFloat64, MachineRepresentation::kWord32, 589 CheckChange(IrOpcode::kChangeInt32ToFloat64, MachineRepresentation::kWord32,
590 Type::None(), MachineRepresentation::kFloat64); 590 Type::Signed32(), MachineRepresentation::kFloat64);
591 CheckChange(IrOpcode::kChangeFloat64ToInt32, MachineRepresentation::kFloat64, 591 CheckChange(IrOpcode::kChangeFloat64ToInt32, MachineRepresentation::kFloat64,
592 Type::Signed32(), MachineRepresentation::kWord32); 592 Type::Signed32(), MachineRepresentation::kWord32);
593 CheckChange(IrOpcode::kTruncateFloat64ToWord32, 593 CheckChange(IrOpcode::kTruncateFloat64ToWord32,
594 MachineRepresentation::kFloat64, Type::Number(), 594 MachineRepresentation::kFloat64, Type::Number(),
595 MachineRepresentation::kWord32); 595 MachineRepresentation::kWord32);
596 CheckChange(IrOpcode::kCheckedTruncateTaggedToWord32, 596 CheckChange(IrOpcode::kCheckedTruncateTaggedToWord32,
597 MachineRepresentation::kTagged, Type::NumberOrOddball(), 597 MachineRepresentation::kTagged, Type::NumberOrOddball(),
598 MachineRepresentation::kWord32, 598 MachineRepresentation::kWord32,
599 UseInfo::CheckedNumberOrOddballAsWord32()); 599 UseInfo::CheckedNumberOrOddballAsWord32());
600 600
601 CheckTwoChanges(IrOpcode::kChangeInt32ToFloat64, 601 CheckTwoChanges(IrOpcode::kChangeInt32ToFloat64,
602 IrOpcode::kTruncateFloat64ToFloat32, 602 IrOpcode::kTruncateFloat64ToFloat32,
603 MachineRepresentation::kWord32, Type::None(), 603 MachineRepresentation::kWord32, Type::Signed32(),
604 MachineRepresentation::kFloat32); 604 MachineRepresentation::kFloat32);
605 CheckTwoChanges(IrOpcode::kChangeFloat32ToFloat64, 605 CheckTwoChanges(IrOpcode::kChangeFloat32ToFloat64,
606 IrOpcode::kTruncateFloat64ToWord32, 606 IrOpcode::kTruncateFloat64ToWord32,
607 MachineRepresentation::kFloat32, Type::Number(), 607 MachineRepresentation::kFloat32, Type::Number(),
608 MachineRepresentation::kWord32); 608 MachineRepresentation::kWord32);
609 } 609 }
610 610
611 611
612 TEST(Nops) { 612 TEST(Nops) {
613 RepresentationChangerTester r; 613 RepresentationChangerTester r;
614 614
615 // X -> X is always a nop for any single representation X. 615 // X -> X is always a nop for any single representation X.
616 for (size_t i = 0; i < arraysize(kMachineTypes); i++) { 616 for (size_t i = 0; i < arraysize(kMachineTypes); i++) {
617 r.CheckNop(kMachineTypes[i].representation(), Type::None(), 617 r.CheckNop(kMachineTypes[i].representation(), Type::Number(),
618 kMachineTypes[i].representation()); 618 kMachineTypes[i].representation());
619 } 619 }
620 620
621 // 32-bit floats. 621 // 32-bit floats.
622 r.CheckNop(MachineRepresentation::kFloat32, Type::None(),
623 MachineRepresentation::kFloat32);
624 r.CheckNop(MachineRepresentation::kFloat32, Type::Number(), 622 r.CheckNop(MachineRepresentation::kFloat32, Type::Number(),
625 MachineRepresentation::kFloat32); 623 MachineRepresentation::kFloat32);
626 624
627 // 32-bit words can be used as smaller word sizes and vice versa, because 625 // 32-bit words can be used as smaller word sizes and vice versa, because
628 // loads from memory implicitly sign or zero extend the value to the 626 // loads from memory implicitly sign or zero extend the value to the
629 // full machine word size, and stores implicitly truncate. 627 // full machine word size, and stores implicitly truncate.
630 r.CheckNop(MachineRepresentation::kWord32, Type::Signed32(), 628 r.CheckNop(MachineRepresentation::kWord32, Type::Signed32(),
631 MachineRepresentation::kWord8); 629 MachineRepresentation::kWord8);
632 r.CheckNop(MachineRepresentation::kWord32, Type::Signed32(), 630 r.CheckNop(MachineRepresentation::kWord32, Type::Signed32(),
633 MachineRepresentation::kWord16); 631 MachineRepresentation::kWord16);
634 r.CheckNop(MachineRepresentation::kWord32, Type::Signed32(), 632 r.CheckNop(MachineRepresentation::kWord32, Type::Signed32(),
635 MachineRepresentation::kWord32); 633 MachineRepresentation::kWord32);
636 r.CheckNop(MachineRepresentation::kWord8, Type::Signed32(), 634 r.CheckNop(MachineRepresentation::kWord8, Type::Signed32(),
637 MachineRepresentation::kWord32); 635 MachineRepresentation::kWord32);
638 r.CheckNop(MachineRepresentation::kWord16, Type::Signed32(), 636 r.CheckNop(MachineRepresentation::kWord16, Type::Signed32(),
639 MachineRepresentation::kWord32); 637 MachineRepresentation::kWord32);
640 638
641 // kRepBit (result of comparison) is implicitly a wordish thing. 639 // kRepBit (result of comparison) is implicitly a wordish thing.
642 r.CheckNop(MachineRepresentation::kBit, Type::None(),
643 MachineRepresentation::kWord8);
644 r.CheckNop(MachineRepresentation::kBit, Type::None(),
645 MachineRepresentation::kWord16);
646 r.CheckNop(MachineRepresentation::kBit, Type::None(),
647 MachineRepresentation::kWord32);
648 r.CheckNop(MachineRepresentation::kBit, Type::None(),
649 MachineRepresentation::kWord64);
650 r.CheckNop(MachineRepresentation::kBit, Type::Boolean(), 640 r.CheckNop(MachineRepresentation::kBit, Type::Boolean(),
651 MachineRepresentation::kWord8); 641 MachineRepresentation::kWord8);
652 r.CheckNop(MachineRepresentation::kBit, Type::Boolean(), 642 r.CheckNop(MachineRepresentation::kBit, Type::Boolean(),
653 MachineRepresentation::kWord16); 643 MachineRepresentation::kWord16);
654 r.CheckNop(MachineRepresentation::kBit, Type::Boolean(), 644 r.CheckNop(MachineRepresentation::kBit, Type::Boolean(),
655 MachineRepresentation::kWord32); 645 MachineRepresentation::kWord32);
656 r.CheckNop(MachineRepresentation::kBit, Type::Boolean(), 646 r.CheckNop(MachineRepresentation::kBit, Type::Boolean(),
657 MachineRepresentation::kWord64); 647 MachineRepresentation::kWord64);
658 } 648 }
659 649
660 650
661 TEST(TypeErrors) { 651 TEST(TypeErrors) {
662 RepresentationChangerTester r; 652 RepresentationChangerTester r;
663 653
664 // Wordish cannot be implicitly converted to/from comparison conditions. 654 // Wordish cannot be implicitly converted to/from comparison conditions.
665 r.CheckTypeError(MachineRepresentation::kWord8, Type::None(), 655 r.CheckTypeError(MachineRepresentation::kWord8, Type::Number(),
666 MachineRepresentation::kBit); 656 MachineRepresentation::kBit);
667 r.CheckTypeError(MachineRepresentation::kWord16, Type::None(), 657 r.CheckTypeError(MachineRepresentation::kWord16, Type::Number(),
668 MachineRepresentation::kBit); 658 MachineRepresentation::kBit);
669 r.CheckTypeError(MachineRepresentation::kWord32, Type::None(), 659 r.CheckTypeError(MachineRepresentation::kWord32, Type::Number(),
670 MachineRepresentation::kBit); 660 MachineRepresentation::kBit);
671 r.CheckTypeError(MachineRepresentation::kWord64, Type::None(), 661 r.CheckTypeError(MachineRepresentation::kWord64, Type::Number(),
672 MachineRepresentation::kBit); 662 MachineRepresentation::kBit);
673 663
674 // Floats cannot be implicitly converted to/from comparison conditions. 664 // Floats cannot be implicitly converted to/from comparison conditions.
675 r.CheckTypeError(MachineRepresentation::kFloat64, Type::None(), 665 r.CheckTypeError(MachineRepresentation::kFloat64, Type::Number(),
676 MachineRepresentation::kBit); 666 MachineRepresentation::kBit);
677 667
678 // Floats cannot be implicitly converted to/from comparison conditions. 668 // Floats cannot be implicitly converted to/from comparison conditions.
679 r.CheckTypeError(MachineRepresentation::kFloat32, Type::None(), 669 r.CheckTypeError(MachineRepresentation::kFloat32, Type::Number(),
680 MachineRepresentation::kBit); 670 MachineRepresentation::kBit);
681 r.CheckTypeError(MachineRepresentation::kBit, Type::None(), 671 r.CheckTypeError(MachineRepresentation::kBit, Type::Number(),
682 MachineRepresentation::kFloat32); 672 MachineRepresentation::kFloat32);
683 r.CheckTypeError(MachineRepresentation::kBit, Type::Boolean(), 673 r.CheckTypeError(MachineRepresentation::kBit, Type::Boolean(),
684 MachineRepresentation::kFloat32); 674 MachineRepresentation::kFloat32);
685 675
686 // Word64 is internal and shouldn't be implicitly converted. 676 // Word64 is internal and shouldn't be implicitly converted.
687 r.CheckTypeError(MachineRepresentation::kWord64, Type::None(), 677 r.CheckTypeError(MachineRepresentation::kWord64, Type::Internal(),
688 MachineRepresentation::kTagged); 678 MachineRepresentation::kTagged);
689 r.CheckTypeError(MachineRepresentation::kTagged, Type::None(), 679 r.CheckTypeError(MachineRepresentation::kTagged, Type::Number(),
690 MachineRepresentation::kWord64); 680 MachineRepresentation::kWord64);
691 r.CheckTypeError(MachineRepresentation::kTagged, Type::Boolean(), 681 r.CheckTypeError(MachineRepresentation::kTagged, Type::Boolean(),
692 MachineRepresentation::kWord64); 682 MachineRepresentation::kWord64);
693 683
694 // Word64 / Word32 shouldn't be implicitly converted. 684 // Word64 / Word32 shouldn't be implicitly converted.
695 r.CheckTypeError(MachineRepresentation::kWord64, Type::None(), 685 r.CheckTypeError(MachineRepresentation::kWord64, Type::Internal(),
696 MachineRepresentation::kWord32); 686 MachineRepresentation::kWord32);
697 r.CheckTypeError(MachineRepresentation::kWord32, Type::None(), 687 r.CheckTypeError(MachineRepresentation::kWord32, Type::Number(),
698 MachineRepresentation::kWord64); 688 MachineRepresentation::kWord64);
699 r.CheckTypeError(MachineRepresentation::kWord32, Type::Signed32(), 689 r.CheckTypeError(MachineRepresentation::kWord32, Type::Signed32(),
700 MachineRepresentation::kWord64); 690 MachineRepresentation::kWord64);
701 r.CheckTypeError(MachineRepresentation::kWord32, Type::Unsigned32(), 691 r.CheckTypeError(MachineRepresentation::kWord32, Type::Unsigned32(),
702 MachineRepresentation::kWord64); 692 MachineRepresentation::kWord64);
703 } 693 }
704 694
705 } // namespace compiler 695 } // namespace compiler
706 } // namespace internal 696 } // namespace internal
707 } // namespace v8 697 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/x87/code-generator-x87.cc ('k') | test/mjsunit/compiler/regress-638132.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698