| OLD | NEW |
| 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/crankshaft/hydrogen-types.h" | 7 #include "src/crankshaft/hydrogen-types.h" |
| 8 #include "src/factory.h" | 8 #include "src/factory.h" |
| 9 #include "src/heap/heap.h" | 9 #include "src/heap/heap.h" |
| 10 #include "src/isolate.h" | 10 #include "src/isolate.h" |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 CHECK(!type2->Is(type1)); | 106 CHECK(!type2->Is(type1)); |
| 107 CHECK(!type1->Maybe(type2)); | 107 CHECK(!type1->Maybe(type2)); |
| 108 CHECK(!type2->Maybe(type1)); | 108 CHECK(!type2->Maybe(type1)); |
| 109 } | 109 } |
| 110 | 110 |
| 111 void IsSomeType() { | 111 void IsSomeType() { |
| 112 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { | 112 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { |
| 113 Type* t = *it; | 113 Type* t = *it; |
| 114 CHECK(1 == | 114 CHECK(1 == |
| 115 this->IsBitset(t) + t->IsConstant() + t->IsRange() + | 115 this->IsBitset(t) + t->IsConstant() + t->IsRange() + |
| 116 this->IsUnion(t) + t->IsArray() + t->IsFunction() + | 116 this->IsUnion(t) + t->IsArray() + t->IsFunction()); |
| 117 t->IsContext()); | |
| 118 } | 117 } |
| 119 } | 118 } |
| 120 | 119 |
| 121 void Bitset() { | 120 void Bitset() { |
| 122 // None and Any are bitsets. | 121 // None and Any are bitsets. |
| 123 CHECK(this->IsBitset(T.None)); | 122 CHECK(this->IsBitset(T.None)); |
| 124 CHECK(this->IsBitset(T.Any)); | 123 CHECK(this->IsBitset(T.Any)); |
| 125 | 124 |
| 126 CHECK(bitset(0) == this->AsBitset(T.None)); | 125 CHECK(bitset(0) == this->AsBitset(T.None)); |
| 127 CHECK(bitset(0xfffffffeu) == this->AsBitset(T.Any)); | 126 CHECK(bitset(0xfffffffeu) == this->AsBitset(T.Any)); |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 if (min2 > max2) std::swap(min2, max2); | 371 if (min2 > max2) std::swap(min2, max2); |
| 373 Type* type1 = T.Range(min1, max1); | 372 Type* type1 = T.Range(min1, max1); |
| 374 Type* type2 = T.Range(min2, max2); | 373 Type* type2 = T.Range(min2, max2); |
| 375 CHECK(Equal(type1, type2) == (min1 == min2 && max1 == max2)); | 374 CHECK(Equal(type1, type2) == (min1 == min2 && max1 == max2)); |
| 376 } | 375 } |
| 377 } | 376 } |
| 378 } | 377 } |
| 379 } | 378 } |
| 380 } | 379 } |
| 381 | 380 |
| 382 void Context() { | |
| 383 // Constructor | |
| 384 for (int i = 0; i < 20; ++i) { | |
| 385 Type* type = T.Random(); | |
| 386 Type* context = T.Context(type); | |
| 387 CHECK(context->IsContext()); | |
| 388 } | |
| 389 | |
| 390 // Attributes | |
| 391 for (int i = 0; i < 20; ++i) { | |
| 392 Type* type = T.Random(); | |
| 393 Type* context = T.Context(type); | |
| 394 CheckEqual(type, context->AsContext()->Outer()); | |
| 395 } | |
| 396 | |
| 397 // Functionality & Injectivity: Context(T1) = Context(T2) iff T1 = T2 | |
| 398 for (int i = 0; i < 20; ++i) { | |
| 399 for (int j = 0; j < 20; ++j) { | |
| 400 Type* type1 = T.Random(); | |
| 401 Type* type2 = T.Random(); | |
| 402 Type* context1 = T.Context(type1); | |
| 403 Type* context2 = T.Context(type2); | |
| 404 CHECK(Equal(context1, context2) == Equal(type1, type2)); | |
| 405 } | |
| 406 } | |
| 407 } | |
| 408 | |
| 409 void Array() { | 381 void Array() { |
| 410 // Constructor | 382 // Constructor |
| 411 for (int i = 0; i < 20; ++i) { | 383 for (int i = 0; i < 20; ++i) { |
| 412 Type* type = T.Random(); | 384 Type* type = T.Random(); |
| 413 Type* array = T.Array1(type); | 385 Type* array = T.Array1(type); |
| 414 CHECK(array->IsArray()); | 386 CHECK(array->IsArray()); |
| 415 } | 387 } |
| 416 | 388 |
| 417 // Attributes | 389 // Attributes |
| 418 for (int i = 0; i < 20; ++i) { | 390 for (int i = 0; i < 20; ++i) { |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 707 for (TypeIterator i = T.types.begin(); i != T.types.end(); ++i) { | 679 for (TypeIterator i = T.types.begin(); i != T.types.end(); ++i) { |
| 708 for (TypeIterator j = T.types.begin(); j != T.types.end(); ++j) { | 680 for (TypeIterator j = T.types.begin(); j != T.types.end(); ++j) { |
| 709 Type* type1 = *i; | 681 Type* type1 = *i; |
| 710 Type* type2 = *j; | 682 Type* type2 = *j; |
| 711 CHECK(!type1->Is(type2) || this->IsBitset(type2) || | 683 CHECK(!type1->Is(type2) || this->IsBitset(type2) || |
| 712 this->IsUnion(type2) || this->IsUnion(type1) || | 684 this->IsUnion(type2) || this->IsUnion(type1) || |
| 713 (type1->IsConstant() && type2->IsConstant()) || | 685 (type1->IsConstant() && type2->IsConstant()) || |
| 714 (type1->IsConstant() && type2->IsRange()) || | 686 (type1->IsConstant() && type2->IsRange()) || |
| 715 (this->IsBitset(type1) && type2->IsRange()) || | 687 (this->IsBitset(type1) && type2->IsRange()) || |
| 716 (type1->IsRange() && type2->IsRange()) || | 688 (type1->IsRange() && type2->IsRange()) || |
| 717 (type1->IsContext() && type2->IsContext()) || | |
| 718 (type1->IsArray() && type2->IsArray()) || | 689 (type1->IsArray() && type2->IsArray()) || |
| 719 (type1->IsFunction() && type2->IsFunction()) || | 690 (type1->IsFunction() && type2->IsFunction()) || |
| 720 !type1->IsInhabited()); | 691 !type1->IsInhabited()); |
| 721 } | 692 } |
| 722 } | 693 } |
| 723 } | 694 } |
| 724 | 695 |
| 725 void Is2() { | 696 void Is2() { |
| 726 // Range(X1, Y1)->Is(Range(X2, Y2)) iff X1 >= X2 /\ Y1 <= Y2 | 697 // Range(X1, Y1)->Is(Range(X2, Y2)) iff X1 >= X2 /\ Y1 <= Y2 |
| 727 for (ValueIterator i1 = T.integers.begin(); | 698 for (ValueIterator i1 = T.integers.begin(); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 750 for (ValueIterator vt1 = T.values.begin(); vt1 != T.values.end(); ++vt1) { | 721 for (ValueIterator vt1 = T.values.begin(); vt1 != T.values.end(); ++vt1) { |
| 751 for (ValueIterator vt2 = T.values.begin(); vt2 != T.values.end(); ++vt2) { | 722 for (ValueIterator vt2 = T.values.begin(); vt2 != T.values.end(); ++vt2) { |
| 752 Handle<i::Object> value1 = *vt1; | 723 Handle<i::Object> value1 = *vt1; |
| 753 Handle<i::Object> value2 = *vt2; | 724 Handle<i::Object> value2 = *vt2; |
| 754 Type* const_type1 = T.Constant(value1); | 725 Type* const_type1 = T.Constant(value1); |
| 755 Type* const_type2 = T.Constant(value2); | 726 Type* const_type2 = T.Constant(value2); |
| 756 CHECK(const_type1->Is(const_type2) == (*value1 == *value2)); | 727 CHECK(const_type1->Is(const_type2) == (*value1 == *value2)); |
| 757 } | 728 } |
| 758 } | 729 } |
| 759 | 730 |
| 760 // Context(T1)->Is(Context(T2)) iff T1 = T2 | |
| 761 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { | |
| 762 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { | |
| 763 Type* outer1 = *it1; | |
| 764 Type* outer2 = *it2; | |
| 765 Type* type1 = T.Context(outer1); | |
| 766 Type* type2 = T.Context(outer2); | |
| 767 CHECK(type1->Is(type2) == outer1->Equals(outer2)); | |
| 768 } | |
| 769 } | |
| 770 | |
| 771 // Array(T1)->Is(Array(T2)) iff T1 = T2 | 731 // Array(T1)->Is(Array(T2)) iff T1 = T2 |
| 772 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { | 732 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { |
| 773 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { | 733 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { |
| 774 Type* element1 = *it1; | 734 Type* element1 = *it1; |
| 775 Type* element2 = *it2; | 735 Type* element2 = *it2; |
| 776 Type* type1 = T.Array1(element1); | 736 Type* type1 = T.Array1(element1); |
| 777 Type* type2 = T.Array1(element2); | 737 Type* type2 = T.Array1(element2); |
| 778 CHECK(type1->Is(type2) == element1->Equals(element2)); | 738 CHECK(type1->Is(type2) == element1->Equals(element2)); |
| 779 } | 739 } |
| 780 } | 740 } |
| (...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1426 | 1386 |
| 1427 TEST(Union3) { Tests().Union3(); } | 1387 TEST(Union3) { Tests().Union3(); } |
| 1428 | 1388 |
| 1429 TEST(Union4) { Tests().Union4(); } | 1389 TEST(Union4) { Tests().Union4(); } |
| 1430 | 1390 |
| 1431 TEST(Intersect) { Tests().Intersect(); } | 1391 TEST(Intersect) { Tests().Intersect(); } |
| 1432 | 1392 |
| 1433 TEST(Distributivity) { Tests().Distributivity(); } | 1393 TEST(Distributivity) { Tests().Distributivity(); } |
| 1434 | 1394 |
| 1435 TEST(GetRange) { Tests().GetRange(); } | 1395 TEST(GetRange) { Tests().GetRange(); } |
| OLD | NEW |