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

Side by Side Diff: test/cctest/test-types.cc

Issue 636283009: [turbofan] Use range types to type and lower arithmetic ops. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rename MaybeWeaken and rebase Created 6 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « test/cctest/compiler/test-typer.cc ('k') | test/cctest/types-fuzz.h » ('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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 <vector> 5 #include <vector>
6 6
7 #include "src/hydrogen-types.h" 7 #include "src/hydrogen-types.h"
8 #include "src/isolate-inl.h" 8 #include "src/isolate-inl.h"
9 #include "src/types.h" 9 #include "src/types.h"
10 #include "test/cctest/cctest.h" 10 #include "test/cctest/cctest.h"
(...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 TypeHandle type = *it; 583 TypeHandle type = *it;
584 TypeHandle const_type = T.Constant(value); 584 TypeHandle const_type = T.Constant(value);
585 TypeHandle nowof_type = T.NowOf(value); 585 TypeHandle nowof_type = T.NowOf(value);
586 CHECK(!const_type->Is(type) || 586 CHECK(!const_type->Is(type) ||
587 nowof_type->Is(type) || type->Maybe(const_type)); 587 nowof_type->Is(type) || type->Maybe(const_type));
588 } 588 }
589 } 589 }
590 } 590 }
591 591
592 void MinMax() { 592 void MinMax() {
593 Factory* fac = isolate->factory();
594
593 // If b is regular numeric bitset, then Range(b->Min(), b->Max())->Is(b). 595 // If b is regular numeric bitset, then Range(b->Min(), b->Max())->Is(b).
594 // TODO(neis): Need to ignore representation for this to be true. 596 // TODO(neis): Need to ignore representation for this to be true.
595 /* 597 /*
596 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { 598 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) {
597 TypeHandle type = *it; 599 TypeHandle type = *it;
598 if (this->IsBitset(type) && type->Is(T.Number) && 600 if (this->IsBitset(type) && type->Is(T.Number) &&
599 !type->Is(T.None) && !type->Is(T.NaN)) { 601 !type->Is(T.None) && !type->Is(T.NaN)) {
600 TypeHandle range = T.Range( 602 TypeHandle range = T.Range(
601 isolate->factory()->NewNumber(type->Min()), 603 isolate->factory()->NewNumber(type->Min()),
602 isolate->factory()->NewNumber(type->Max())); 604 isolate->factory()->NewNumber(type->Max()));
603 CHECK(range->Is(type)); 605 CHECK(range->Is(type));
604 } 606 }
605 } 607 }
606 */ 608 */
607 609
608 // If b is regular numeric bitset, then b->Min() and b->Max() are integers. 610 // If b is regular numeric bitset, then b->Min() and b->Max() are integers.
609 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { 611 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) {
610 TypeHandle type = *it; 612 TypeHandle type = *it;
611 if (this->IsBitset(type) && type->Is(T.Number) && 613 if (this->IsBitset(type) && type->Is(T.Number) && !type->Is(T.NaN)) {
612 !type->Is(T.None) && !type->Is(T.NaN)) {
613 CHECK(IsInteger(type->Min()) && IsInteger(type->Max())); 614 CHECK(IsInteger(type->Min()) && IsInteger(type->Max()));
614 } 615 }
615 } 616 }
616 617
617 // If b1 and b2 are regular numeric bitsets with b1->Is(b2), then 618 // If b1 and b2 are regular numeric bitsets with b1->Is(b2), then
618 // b1->Min() >= b2->Min() and b1->Max() <= b2->Max(). 619 // b1->Min() >= b2->Min() and b1->Max() <= b2->Max().
619 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { 620 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) {
620 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { 621 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) {
621 TypeHandle type1 = *it1; 622 TypeHandle type1 = *it1;
622 TypeHandle type2 = *it2; 623 TypeHandle type2 = *it2;
623 if (this->IsBitset(type1) && type1->Is(type2) && type2->Is(T.Number) && 624 if (this->IsBitset(type1) && type1->Is(type2) && type2->Is(T.Number) &&
624 !type1->Is(T.NaN) && !type2->Is(T.NaN)) { 625 !type1->Is(T.NaN) && !type2->Is(T.NaN)) {
625 CHECK(type1->Min() >= type2->Min()); 626 CHECK(type1->Min() >= type2->Min());
626 CHECK(type1->Max() <= type2->Max()); 627 CHECK(type1->Max() <= type2->Max());
627 } 628 }
628 } 629 }
629 } 630 }
630 631
631 // Lub(Range(x,y))->Min() <= x and y <= Lub(Range(x,y))->Max() 632 // Lub(Range(x,y))->Min() <= x and y <= Lub(Range(x,y))->Max()
632 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { 633 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) {
633 TypeHandle type = *it; 634 TypeHandle type = *it;
634 if (type->IsRange()) { 635 if (type->IsRange()) {
635 TypeHandle lub = Rep::BitsetType::New( 636 TypeHandle lub = Rep::BitsetType::New(
636 Rep::BitsetType::Lub(type), T.region()); 637 Rep::BitsetType::Lub(type), T.region());
637 CHECK(lub->Min() <= type->Min() && type->Max() <= lub->Max()); 638 CHECK(lub->Min() <= type->Min() && type->Max() <= lub->Max());
638 } 639 }
639 } 640 }
641
642 // Rangification: If T->Is(Range(-inf,+inf)) and !T->Is(None), then
643 // T->Is(Range(T->Min(), T->Max())).
644 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) {
645 TypeHandle type = *it;
646 CHECK(!(type->Is(T.Integer) && !type->Is(T.None)) ||
647 type->Is(T.Range(fac->NewNumber(type->Min()),
648 fac->NewNumber(type->Max()))));
649 }
640 } 650 }
641 651
642 void BitsetGlb() { 652 void BitsetGlb() {
643 // Lower: (T->BitsetGlb())->Is(T) 653 // Lower: (T->BitsetGlb())->Is(T)
644 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { 654 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) {
645 TypeHandle type = *it; 655 TypeHandle type = *it;
646 TypeHandle glb = 656 TypeHandle glb =
647 Rep::BitsetType::New(Rep::BitsetType::Glb(type), T.region()); 657 Rep::BitsetType::New(Rep::BitsetType::Glb(type), T.region());
648 CHECK(glb->Is(type)); 658 CHECK(glb->Is(type));
649 } 659 }
(...skipping 1375 matching lines...) Expand 10 before | Expand all | Expand 10 after
2025 ZoneTests().Convert<HeapType, Handle<HeapType>, Isolate, HeapRep>(); 2035 ZoneTests().Convert<HeapType, Handle<HeapType>, Isolate, HeapRep>();
2026 HeapTests().Convert<Type, Type*, Zone, ZoneRep>(); 2036 HeapTests().Convert<Type, Type*, Zone, ZoneRep>();
2027 } 2037 }
2028 2038
2029 2039
2030 TEST(HTypeFromType) { 2040 TEST(HTypeFromType) {
2031 CcTest::InitializeVM(); 2041 CcTest::InitializeVM();
2032 ZoneTests().HTypeFromType(); 2042 ZoneTests().HTypeFromType();
2033 HeapTests().HTypeFromType(); 2043 HeapTests().HTypeFromType();
2034 } 2044 }
OLDNEW
« no previous file with comments | « test/cctest/compiler/test-typer.cc ('k') | test/cctest/types-fuzz.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698