| 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)); |
| 117 } | 117 } |
| 118 } | 118 } |
| 119 | 119 |
| 120 void Bitset() { | 120 void Bitset() { |
| 121 // None and Any are bitsets. | 121 // None and Any are bitsets. |
| 122 CHECK(this->IsBitset(T.None)); | 122 CHECK(this->IsBitset(T.None)); |
| 123 CHECK(this->IsBitset(T.Any)); | 123 CHECK(this->IsBitset(T.Any)); |
| 124 | 124 |
| 125 CHECK(bitset(0) == this->AsBitset(T.None)); | 125 CHECK(bitset(0) == this->AsBitset(T.None)); |
| 126 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... |
| 371 if (min2 > max2) std::swap(min2, max2); | 371 if (min2 > max2) std::swap(min2, max2); |
| 372 Type* type1 = T.Range(min1, max1); | 372 Type* type1 = T.Range(min1, max1); |
| 373 Type* type2 = T.Range(min2, max2); | 373 Type* type2 = T.Range(min2, max2); |
| 374 CHECK(Equal(type1, type2) == (min1 == min2 && max1 == max2)); | 374 CHECK(Equal(type1, type2) == (min1 == min2 && max1 == max2)); |
| 375 } | 375 } |
| 376 } | 376 } |
| 377 } | 377 } |
| 378 } | 378 } |
| 379 } | 379 } |
| 380 | 380 |
| 381 void Array() { | |
| 382 // Constructor | |
| 383 for (int i = 0; i < 20; ++i) { | |
| 384 Type* type = T.Random(); | |
| 385 Type* array = T.Array1(type); | |
| 386 CHECK(array->IsArray()); | |
| 387 } | |
| 388 | |
| 389 // Attributes | |
| 390 for (int i = 0; i < 20; ++i) { | |
| 391 Type* type = T.Random(); | |
| 392 Type* array = T.Array1(type); | |
| 393 CheckEqual(type, array->AsArray()->Element()); | |
| 394 } | |
| 395 | |
| 396 // Functionality & Injectivity: Array(T1) = Array(T2) iff T1 = T2 | |
| 397 for (int i = 0; i < 20; ++i) { | |
| 398 for (int j = 0; j < 20; ++j) { | |
| 399 Type* type1 = T.Random(); | |
| 400 Type* type2 = T.Random(); | |
| 401 Type* array1 = T.Array1(type1); | |
| 402 Type* array2 = T.Array1(type2); | |
| 403 CHECK(Equal(array1, array2) == Equal(type1, type2)); | |
| 404 } | |
| 405 } | |
| 406 } | |
| 407 | |
| 408 void Function() { | |
| 409 // Constructors | |
| 410 for (int i = 0; i < 20; ++i) { | |
| 411 for (int j = 0; j < 20; ++j) { | |
| 412 for (int k = 0; k < 20; ++k) { | |
| 413 Type* type1 = T.Random(); | |
| 414 Type* type2 = T.Random(); | |
| 415 Type* type3 = T.Random(); | |
| 416 Type* function0 = T.Function0(type1, type2); | |
| 417 Type* function1 = T.Function1(type1, type2, type3); | |
| 418 Type* function2 = T.Function2(type1, type2, type3); | |
| 419 CHECK(function0->IsFunction()); | |
| 420 CHECK(function1->IsFunction()); | |
| 421 CHECK(function2->IsFunction()); | |
| 422 } | |
| 423 } | |
| 424 } | |
| 425 | |
| 426 // Attributes | |
| 427 for (int i = 0; i < 20; ++i) { | |
| 428 for (int j = 0; j < 20; ++j) { | |
| 429 for (int k = 0; k < 20; ++k) { | |
| 430 Type* type1 = T.Random(); | |
| 431 Type* type2 = T.Random(); | |
| 432 Type* type3 = T.Random(); | |
| 433 Type* function0 = T.Function0(type1, type2); | |
| 434 Type* function1 = T.Function1(type1, type2, type3); | |
| 435 Type* function2 = T.Function2(type1, type2, type3); | |
| 436 CHECK_EQ(0, function0->AsFunction()->Arity()); | |
| 437 CHECK_EQ(1, function1->AsFunction()->Arity()); | |
| 438 CHECK_EQ(2, function2->AsFunction()->Arity()); | |
| 439 CheckEqual(type1, function0->AsFunction()->Result()); | |
| 440 CheckEqual(type1, function1->AsFunction()->Result()); | |
| 441 CheckEqual(type1, function2->AsFunction()->Result()); | |
| 442 CheckEqual(type2, function0->AsFunction()->Receiver()); | |
| 443 CheckEqual(type2, function1->AsFunction()->Receiver()); | |
| 444 CheckEqual(T.Any, function2->AsFunction()->Receiver()); | |
| 445 CheckEqual(type3, function1->AsFunction()->Parameter(0)); | |
| 446 CheckEqual(type2, function2->AsFunction()->Parameter(0)); | |
| 447 CheckEqual(type3, function2->AsFunction()->Parameter(1)); | |
| 448 } | |
| 449 } | |
| 450 } | |
| 451 | |
| 452 // Functionality & Injectivity: Function(Ts1) = Function(Ts2) iff Ts1 = Ts2 | |
| 453 for (int i = 0; i < 20; ++i) { | |
| 454 for (int j = 0; j < 20; ++j) { | |
| 455 for (int k = 0; k < 20; ++k) { | |
| 456 Type* type1 = T.Random(); | |
| 457 Type* type2 = T.Random(); | |
| 458 Type* type3 = T.Random(); | |
| 459 Type* function01 = T.Function0(type1, type2); | |
| 460 Type* function02 = T.Function0(type1, type3); | |
| 461 Type* function03 = T.Function0(type3, type2); | |
| 462 Type* function11 = T.Function1(type1, type2, type2); | |
| 463 Type* function12 = T.Function1(type1, type2, type3); | |
| 464 Type* function21 = T.Function2(type1, type2, type2); | |
| 465 Type* function22 = T.Function2(type1, type2, type3); | |
| 466 Type* function23 = T.Function2(type1, type3, type2); | |
| 467 CHECK(Equal(function01, function02) == Equal(type2, type3)); | |
| 468 CHECK(Equal(function01, function03) == Equal(type1, type3)); | |
| 469 CHECK(Equal(function11, function12) == Equal(type2, type3)); | |
| 470 CHECK(Equal(function21, function22) == Equal(type2, type3)); | |
| 471 CHECK(Equal(function21, function23) == Equal(type2, type3)); | |
| 472 } | |
| 473 } | |
| 474 } | |
| 475 } | |
| 476 | |
| 477 void Of() { | 381 void Of() { |
| 478 // Constant(V)->Is(Of(V)) | 382 // Constant(V)->Is(Of(V)) |
| 479 for (ValueIterator vt = T.values.begin(); vt != T.values.end(); ++vt) { | 383 for (ValueIterator vt = T.values.begin(); vt != T.values.end(); ++vt) { |
| 480 Handle<i::Object> value = *vt; | 384 Handle<i::Object> value = *vt; |
| 481 Type* const_type = T.Constant(value); | 385 Type* const_type = T.Constant(value); |
| 482 Type* of_type = T.Of(value); | 386 Type* of_type = T.Of(value); |
| 483 CHECK(const_type->Is(of_type)); | 387 CHECK(const_type->Is(of_type)); |
| 484 } | 388 } |
| 485 | 389 |
| 486 // If Of(V)->Is(T), then Constant(V)->Is(T) | 390 // If Of(V)->Is(T), then Constant(V)->Is(T) |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 679 for (TypeIterator i = T.types.begin(); i != T.types.end(); ++i) { | 583 for (TypeIterator i = T.types.begin(); i != T.types.end(); ++i) { |
| 680 for (TypeIterator j = T.types.begin(); j != T.types.end(); ++j) { | 584 for (TypeIterator j = T.types.begin(); j != T.types.end(); ++j) { |
| 681 Type* type1 = *i; | 585 Type* type1 = *i; |
| 682 Type* type2 = *j; | 586 Type* type2 = *j; |
| 683 CHECK(!type1->Is(type2) || this->IsBitset(type2) || | 587 CHECK(!type1->Is(type2) || this->IsBitset(type2) || |
| 684 this->IsUnion(type2) || this->IsUnion(type1) || | 588 this->IsUnion(type2) || this->IsUnion(type1) || |
| 685 (type1->IsConstant() && type2->IsConstant()) || | 589 (type1->IsConstant() && type2->IsConstant()) || |
| 686 (type1->IsConstant() && type2->IsRange()) || | 590 (type1->IsConstant() && type2->IsRange()) || |
| 687 (this->IsBitset(type1) && type2->IsRange()) || | 591 (this->IsBitset(type1) && type2->IsRange()) || |
| 688 (type1->IsRange() && type2->IsRange()) || | 592 (type1->IsRange() && type2->IsRange()) || |
| 689 (type1->IsArray() && type2->IsArray()) || | |
| 690 (type1->IsFunction() && type2->IsFunction()) || | |
| 691 !type1->IsInhabited()); | 593 !type1->IsInhabited()); |
| 692 } | 594 } |
| 693 } | 595 } |
| 694 } | 596 } |
| 695 | 597 |
| 696 void Is2() { | 598 void Is2() { |
| 697 // Range(X1, Y1)->Is(Range(X2, Y2)) iff X1 >= X2 /\ Y1 <= Y2 | 599 // Range(X1, Y1)->Is(Range(X2, Y2)) iff X1 >= X2 /\ Y1 <= Y2 |
| 698 for (ValueIterator i1 = T.integers.begin(); | 600 for (ValueIterator i1 = T.integers.begin(); |
| 699 i1 != T.integers.end(); ++i1) { | 601 i1 != T.integers.end(); ++i1) { |
| 700 for (ValueIterator j1 = i1; | 602 for (ValueIterator j1 = i1; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 721 for (ValueIterator vt1 = T.values.begin(); vt1 != T.values.end(); ++vt1) { | 623 for (ValueIterator vt1 = T.values.begin(); vt1 != T.values.end(); ++vt1) { |
| 722 for (ValueIterator vt2 = T.values.begin(); vt2 != T.values.end(); ++vt2) { | 624 for (ValueIterator vt2 = T.values.begin(); vt2 != T.values.end(); ++vt2) { |
| 723 Handle<i::Object> value1 = *vt1; | 625 Handle<i::Object> value1 = *vt1; |
| 724 Handle<i::Object> value2 = *vt2; | 626 Handle<i::Object> value2 = *vt2; |
| 725 Type* const_type1 = T.Constant(value1); | 627 Type* const_type1 = T.Constant(value1); |
| 726 Type* const_type2 = T.Constant(value2); | 628 Type* const_type2 = T.Constant(value2); |
| 727 CHECK(const_type1->Is(const_type2) == (*value1 == *value2)); | 629 CHECK(const_type1->Is(const_type2) == (*value1 == *value2)); |
| 728 } | 630 } |
| 729 } | 631 } |
| 730 | 632 |
| 731 // Array(T1)->Is(Array(T2)) iff T1 = T2 | |
| 732 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { | |
| 733 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { | |
| 734 Type* element1 = *it1; | |
| 735 Type* element2 = *it2; | |
| 736 Type* type1 = T.Array1(element1); | |
| 737 Type* type2 = T.Array1(element2); | |
| 738 CHECK(type1->Is(type2) == element1->Equals(element2)); | |
| 739 } | |
| 740 } | |
| 741 | |
| 742 // Function0(S1, T1)->Is(Function0(S2, T2)) iff S1 = S2 and T1 = T2 | |
| 743 for (TypeIterator i = T.types.begin(); i != T.types.end(); ++i) { | |
| 744 for (TypeIterator j = T.types.begin(); j != T.types.end(); ++j) { | |
| 745 Type* result1 = *i; | |
| 746 Type* receiver1 = *j; | |
| 747 Type* type1 = T.Function0(result1, receiver1); | |
| 748 Type* result2 = T.Random(); | |
| 749 Type* receiver2 = T.Random(); | |
| 750 Type* type2 = T.Function0(result2, receiver2); | |
| 751 CHECK(type1->Is(type2) == | |
| 752 (result1->Equals(result2) && receiver1->Equals(receiver2))); | |
| 753 } | |
| 754 } | |
| 755 | |
| 756 | |
| 757 // Range-specific subtyping | 633 // Range-specific subtyping |
| 758 | 634 |
| 759 // If IsInteger(v) then Constant(v)->Is(Range(v, v)). | 635 // If IsInteger(v) then Constant(v)->Is(Range(v, v)). |
| 760 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { | 636 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { |
| 761 Type* type = *it; | 637 Type* type = *it; |
| 762 if (type->IsConstant() && IsInteger(*type->AsConstant()->Value())) { | 638 if (type->IsConstant() && IsInteger(*type->AsConstant()->Value())) { |
| 763 CHECK(type->Is(T.Range(type->AsConstant()->Value()->Number(), | 639 CHECK(type->Is(T.Range(type->AsConstant()->Value()->Number(), |
| 764 type->AsConstant()->Value()->Number()))); | 640 type->AsConstant()->Value()->Number()))); |
| 765 } | 641 } |
| 766 } | 642 } |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 829 CheckSub(T.ObjectConstant1, T.Object); | 705 CheckSub(T.ObjectConstant1, T.Object); |
| 830 CheckSub(T.ObjectConstant2, T.Object); | 706 CheckSub(T.ObjectConstant2, T.Object); |
| 831 CheckSub(T.ArrayConstant, T.Object); | 707 CheckSub(T.ArrayConstant, T.Object); |
| 832 CheckSub(T.ArrayConstant, T.OtherObject); | 708 CheckSub(T.ArrayConstant, T.OtherObject); |
| 833 CheckSub(T.ArrayConstant, T.Receiver); | 709 CheckSub(T.ArrayConstant, T.Receiver); |
| 834 CheckSub(T.UninitializedConstant, T.Internal); | 710 CheckSub(T.UninitializedConstant, T.Internal); |
| 835 CheckUnordered(T.ObjectConstant1, T.ObjectConstant2); | 711 CheckUnordered(T.ObjectConstant1, T.ObjectConstant2); |
| 836 CheckUnordered(T.ObjectConstant1, T.ArrayConstant); | 712 CheckUnordered(T.ObjectConstant1, T.ArrayConstant); |
| 837 CheckUnordered(T.UninitializedConstant, T.Null); | 713 CheckUnordered(T.UninitializedConstant, T.Null); |
| 838 CheckUnordered(T.UninitializedConstant, T.Undefined); | 714 CheckUnordered(T.UninitializedConstant, T.Undefined); |
| 839 | |
| 840 CheckSub(T.NumberArray, T.OtherObject); | |
| 841 CheckSub(T.NumberArray, T.Receiver); | |
| 842 CheckSub(T.NumberArray, T.Object); | |
| 843 CheckUnordered(T.StringArray, T.AnyArray); | |
| 844 | |
| 845 CheckSub(T.MethodFunction, T.Object); | |
| 846 CheckSub(T.NumberFunction1, T.Object); | |
| 847 CheckUnordered(T.SignedFunction1, T.NumberFunction1); | |
| 848 CheckUnordered(T.NumberFunction1, T.NumberFunction2); | |
| 849 } | 715 } |
| 850 | 716 |
| 851 void Contains() { | 717 void Contains() { |
| 852 // T->Contains(V) iff Constant(V)->Is(T) | 718 // T->Contains(V) iff Constant(V)->Is(T) |
| 853 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { | 719 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { |
| 854 for (ValueIterator vt = T.values.begin(); vt != T.values.end(); ++vt) { | 720 for (ValueIterator vt = T.values.begin(); vt != T.values.end(); ++vt) { |
| 855 Type* type = *it; | 721 Type* type = *it; |
| 856 Handle<i::Object> value = *vt; | 722 Handle<i::Object> value = *vt; |
| 857 Type* const_type = T.Constant(value); | 723 Type* const_type = T.Constant(value); |
| 858 CHECK(type->Contains(value) == const_type->Is(type)); | 724 CHECK(type->Contains(value) == const_type->Is(type)); |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 955 CheckOverlap(T.SmiConstant, T.SignedSmall); | 821 CheckOverlap(T.SmiConstant, T.SignedSmall); |
| 956 CheckOverlap(T.SmiConstant, T.Signed32); | 822 CheckOverlap(T.SmiConstant, T.Signed32); |
| 957 CheckOverlap(T.SmiConstant, T.Number); | 823 CheckOverlap(T.SmiConstant, T.Number); |
| 958 CheckOverlap(T.ObjectConstant1, T.Object); | 824 CheckOverlap(T.ObjectConstant1, T.Object); |
| 959 CheckOverlap(T.ObjectConstant2, T.Object); | 825 CheckOverlap(T.ObjectConstant2, T.Object); |
| 960 CheckOverlap(T.ArrayConstant, T.Object); | 826 CheckOverlap(T.ArrayConstant, T.Object); |
| 961 CheckOverlap(T.ArrayConstant, T.Receiver); | 827 CheckOverlap(T.ArrayConstant, T.Receiver); |
| 962 CheckOverlap(T.ObjectConstant1, T.ObjectConstant1); | 828 CheckOverlap(T.ObjectConstant1, T.ObjectConstant1); |
| 963 CheckDisjoint(T.ObjectConstant1, T.ObjectConstant2); | 829 CheckDisjoint(T.ObjectConstant1, T.ObjectConstant2); |
| 964 CheckDisjoint(T.ObjectConstant1, T.ArrayConstant); | 830 CheckDisjoint(T.ObjectConstant1, T.ArrayConstant); |
| 965 CheckOverlap(T.NumberArray, T.Receiver); | |
| 966 CheckDisjoint(T.NumberArray, T.AnyArray); | |
| 967 CheckDisjoint(T.NumberArray, T.StringArray); | |
| 968 CheckOverlap(T.MethodFunction, T.Object); | |
| 969 CheckDisjoint(T.SignedFunction1, T.NumberFunction1); | |
| 970 CheckDisjoint(T.SignedFunction1, T.NumberFunction2); | |
| 971 CheckDisjoint(T.NumberFunction1, T.NumberFunction2); | |
| 972 CheckDisjoint(T.SignedFunction1, T.MethodFunction); | |
| 973 } | 831 } |
| 974 | 832 |
| 975 void Union1() { | 833 void Union1() { |
| 976 // Identity: Union(T, None) = T | 834 // Identity: Union(T, None) = T |
| 977 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { | 835 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { |
| 978 Type* type = *it; | 836 Type* type = *it; |
| 979 Type* union_type = T.Union(type, T.None); | 837 Type* union_type = T.Union(type, T.None); |
| 980 CheckEqual(union_type, type); | 838 CheckEqual(union_type, type); |
| 981 } | 839 } |
| 982 | 840 |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1105 } | 963 } |
| 1106 | 964 |
| 1107 void Union4() { | 965 void Union4() { |
| 1108 // Constant-constant | 966 // Constant-constant |
| 1109 CheckSub(T.Union(T.ObjectConstant1, T.ObjectConstant2), T.Object); | 967 CheckSub(T.Union(T.ObjectConstant1, T.ObjectConstant2), T.Object); |
| 1110 CheckOverlap(T.Union(T.ObjectConstant1, T.ArrayConstant), T.OtherObject); | 968 CheckOverlap(T.Union(T.ObjectConstant1, T.ArrayConstant), T.OtherObject); |
| 1111 CheckOverlap(T.Union(T.ObjectConstant1, T.ArrayConstant), T.OtherObject); | 969 CheckOverlap(T.Union(T.ObjectConstant1, T.ArrayConstant), T.OtherObject); |
| 1112 CheckDisjoint( | 970 CheckDisjoint( |
| 1113 T.Union(T.ObjectConstant1, T.ArrayConstant), T.Number); | 971 T.Union(T.ObjectConstant1, T.ArrayConstant), T.Number); |
| 1114 | 972 |
| 1115 // Bitset-array | |
| 1116 CHECK(this->IsBitset(T.Union(T.AnyArray, T.Receiver))); | |
| 1117 CHECK(this->IsUnion(T.Union(T.NumberArray, T.Number))); | |
| 1118 | |
| 1119 CheckEqual(T.Union(T.AnyArray, T.Receiver), T.Receiver); | |
| 1120 CheckEqual(T.Union(T.AnyArray, T.OtherObject), T.OtherObject); | |
| 1121 CheckUnordered(T.Union(T.AnyArray, T.String), T.Receiver); | |
| 1122 CheckOverlap(T.Union(T.NumberArray, T.String), T.Object); | |
| 1123 CheckDisjoint(T.Union(T.NumberArray, T.String), T.Number); | |
| 1124 | |
| 1125 // Bitset-function | |
| 1126 CHECK(this->IsBitset(T.Union(T.MethodFunction, T.Object))); | |
| 1127 CHECK(this->IsUnion(T.Union(T.NumberFunction1, T.Number))); | |
| 1128 | |
| 1129 CheckEqual(T.Union(T.MethodFunction, T.Object), T.Object); | |
| 1130 CheckUnordered(T.Union(T.NumberFunction1, T.String), T.Object); | |
| 1131 CheckOverlap(T.Union(T.NumberFunction2, T.String), T.Object); | |
| 1132 CheckDisjoint(T.Union(T.NumberFunction1, T.String), T.Number); | |
| 1133 | |
| 1134 // Bitset-constant | 973 // Bitset-constant |
| 1135 CheckSub( | 974 CheckSub( |
| 1136 T.Union(T.ObjectConstant1, T.Signed32), T.Union(T.Object, T.Number)); | 975 T.Union(T.ObjectConstant1, T.Signed32), T.Union(T.Object, T.Number)); |
| 1137 CheckSub(T.Union(T.ObjectConstant1, T.OtherObject), T.Object); | 976 CheckSub(T.Union(T.ObjectConstant1, T.OtherObject), T.Object); |
| 1138 CheckUnordered(T.Union(T.ObjectConstant1, T.String), T.OtherObject); | 977 CheckUnordered(T.Union(T.ObjectConstant1, T.String), T.OtherObject); |
| 1139 CheckOverlap(T.Union(T.ObjectConstant1, T.String), T.Object); | 978 CheckOverlap(T.Union(T.ObjectConstant1, T.String), T.Object); |
| 1140 CheckDisjoint(T.Union(T.ObjectConstant1, T.String), T.Number); | 979 CheckDisjoint(T.Union(T.ObjectConstant1, T.String), T.Number); |
| 1141 | 980 |
| 1142 // Constant-union | 981 // Constant-union |
| 1143 CheckEqual( | 982 CheckEqual( |
| 1144 T.Union( | 983 T.Union( |
| 1145 T.ObjectConstant1, T.Union(T.ObjectConstant1, T.ObjectConstant2)), | 984 T.ObjectConstant1, T.Union(T.ObjectConstant1, T.ObjectConstant2)), |
| 1146 T.Union(T.ObjectConstant2, T.ObjectConstant1)); | 985 T.Union(T.ObjectConstant2, T.ObjectConstant1)); |
| 1147 CheckEqual( | 986 CheckEqual( |
| 1148 T.Union( | 987 T.Union( |
| 1149 T.Union(T.ArrayConstant, T.ObjectConstant2), T.ObjectConstant1), | 988 T.Union(T.ArrayConstant, T.ObjectConstant2), T.ObjectConstant1), |
| 1150 T.Union( | 989 T.Union( |
| 1151 T.ObjectConstant2, T.Union(T.ArrayConstant, T.ObjectConstant1))); | 990 T.ObjectConstant2, T.Union(T.ArrayConstant, T.ObjectConstant1))); |
| 1152 | 991 |
| 1153 // Array-union | |
| 1154 CheckEqual( | |
| 1155 T.Union(T.AnyArray, T.Union(T.NumberArray, T.AnyArray)), | |
| 1156 T.Union(T.AnyArray, T.NumberArray)); | |
| 1157 CheckSub(T.Union(T.AnyArray, T.NumberArray), T.OtherObject); | |
| 1158 | |
| 1159 // Function-union | |
| 1160 CheckEqual( | |
| 1161 T.Union(T.NumberFunction1, T.NumberFunction2), | |
| 1162 T.Union(T.NumberFunction2, T.NumberFunction1)); | |
| 1163 CheckSub(T.Union(T.SignedFunction1, T.MethodFunction), T.Object); | |
| 1164 | |
| 1165 // Union-union | 992 // Union-union |
| 1166 CheckEqual( | 993 CheckEqual( |
| 1167 T.Union( | 994 T.Union( |
| 1168 T.Union(T.ObjectConstant2, T.ObjectConstant1), | 995 T.Union(T.ObjectConstant2, T.ObjectConstant1), |
| 1169 T.Union(T.ObjectConstant1, T.ObjectConstant2)), | 996 T.Union(T.ObjectConstant1, T.ObjectConstant2)), |
| 1170 T.Union(T.ObjectConstant2, T.ObjectConstant1)); | 997 T.Union(T.ObjectConstant2, T.ObjectConstant1)); |
| 1171 } | 998 } |
| 1172 | 999 |
| 1173 void Intersect() { | 1000 void Intersect() { |
| 1174 // Identity: Intersect(T, Any) = T | 1001 // Identity: Intersect(T, Any) = T |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1221 Type* type1 = *it1; | 1048 Type* type1 = *it1; |
| 1222 Type* type2 = *it2; | 1049 Type* type2 = *it2; |
| 1223 Type* type3 = *it3; | 1050 Type* type3 = *it3; |
| 1224 Type* intersect23 = T.Intersect(type2, type3); | 1051 Type* intersect23 = T.Intersect(type2, type3); |
| 1225 CHECK(!(type1->Is(type2) && type1->Is(type3)) || | 1052 CHECK(!(type1->Is(type2) && type1->Is(type3)) || |
| 1226 type1->Is(intersect23)); | 1053 type1->Is(intersect23)); |
| 1227 } | 1054 } |
| 1228 } | 1055 } |
| 1229 } | 1056 } |
| 1230 | 1057 |
| 1231 // Bitset-array | |
| 1232 CheckEqual(T.Intersect(T.NumberArray, T.Object), T.NumberArray); | |
| 1233 CheckEqual(T.Semantic(T.Intersect(T.AnyArray, T.Proxy)), T.None); | |
| 1234 | |
| 1235 // Bitset-function | |
| 1236 CheckEqual(T.Intersect(T.MethodFunction, T.Object), T.MethodFunction); | |
| 1237 CheckEqual(T.Semantic(T.Intersect(T.NumberFunction1, T.Proxy)), T.None); | |
| 1238 | |
| 1239 // Array-union | |
| 1240 CheckEqual( | |
| 1241 T.Intersect(T.AnyArray, T.Union(T.Object, T.SmiConstant)), | |
| 1242 T.AnyArray); | |
| 1243 CHECK( | |
| 1244 !T.Intersect(T.Union(T.AnyArray, T.ArrayConstant), T.NumberArray) | |
| 1245 ->IsInhabited()); | |
| 1246 | |
| 1247 // Function-union | |
| 1248 CheckEqual( | |
| 1249 T.Intersect(T.MethodFunction, T.Union(T.String, T.MethodFunction)), | |
| 1250 T.MethodFunction); | |
| 1251 CheckEqual( | |
| 1252 T.Intersect(T.NumberFunction1, T.Union(T.Object, T.SmiConstant)), | |
| 1253 T.NumberFunction1); | |
| 1254 CHECK( | |
| 1255 !T.Intersect(T.Union(T.MethodFunction, T.Name), T.NumberFunction2) | |
| 1256 ->IsInhabited()); | |
| 1257 | |
| 1258 // Constant-union | 1058 // Constant-union |
| 1259 CheckEqual( | 1059 CheckEqual( |
| 1260 T.Intersect( | 1060 T.Intersect( |
| 1261 T.ObjectConstant1, T.Union(T.ObjectConstant1, T.ObjectConstant2)), | 1061 T.ObjectConstant1, T.Union(T.ObjectConstant1, T.ObjectConstant2)), |
| 1262 T.ObjectConstant1); | 1062 T.ObjectConstant1); |
| 1263 CheckEqual( | 1063 CheckEqual( |
| 1264 T.Intersect(T.SmiConstant, T.Union(T.Number, T.ObjectConstant2)), | 1064 T.Intersect(T.SmiConstant, T.Union(T.Number, T.ObjectConstant2)), |
| 1265 T.SmiConstant); | 1065 T.SmiConstant); |
| 1266 | 1066 |
| 1267 // Union-union | 1067 // Union-union |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1353 TEST(IsSomeType) { Tests().IsSomeType(); } | 1153 TEST(IsSomeType) { Tests().IsSomeType(); } |
| 1354 | 1154 |
| 1355 TEST(PointwiseRepresentation) { Tests().PointwiseRepresentation(); } | 1155 TEST(PointwiseRepresentation) { Tests().PointwiseRepresentation(); } |
| 1356 | 1156 |
| 1357 TEST(BitsetType) { Tests().Bitset(); } | 1157 TEST(BitsetType) { Tests().Bitset(); } |
| 1358 | 1158 |
| 1359 TEST(ConstantType) { Tests().Constant(); } | 1159 TEST(ConstantType) { Tests().Constant(); } |
| 1360 | 1160 |
| 1361 TEST(RangeType) { Tests().Range(); } | 1161 TEST(RangeType) { Tests().Range(); } |
| 1362 | 1162 |
| 1363 TEST(ArrayType) { Tests().Array(); } | |
| 1364 | |
| 1365 TEST(FunctionType) { Tests().Function(); } | |
| 1366 | |
| 1367 TEST(Of) { Tests().Of(); } | 1163 TEST(Of) { Tests().Of(); } |
| 1368 | 1164 |
| 1369 TEST(MinMax) { Tests().MinMax(); } | 1165 TEST(MinMax) { Tests().MinMax(); } |
| 1370 | 1166 |
| 1371 TEST(BitsetGlb) { Tests().BitsetGlb(); } | 1167 TEST(BitsetGlb) { Tests().BitsetGlb(); } |
| 1372 | 1168 |
| 1373 TEST(BitsetLub) { Tests().BitsetLub(); } | 1169 TEST(BitsetLub) { Tests().BitsetLub(); } |
| 1374 | 1170 |
| 1375 TEST(Is1) { Tests().Is1(); } | 1171 TEST(Is1) { Tests().Is1(); } |
| 1376 | 1172 |
| 1377 TEST(Is2) { Tests().Is2(); } | 1173 TEST(Is2) { Tests().Is2(); } |
| 1378 | 1174 |
| 1379 TEST(Contains) { Tests().Contains(); } | 1175 TEST(Contains) { Tests().Contains(); } |
| 1380 | 1176 |
| 1381 TEST(Maybe) { Tests().Maybe(); } | 1177 TEST(Maybe) { Tests().Maybe(); } |
| 1382 | 1178 |
| 1383 TEST(Union1) { Tests().Union1(); } | 1179 TEST(Union1) { Tests().Union1(); } |
| 1384 | 1180 |
| 1385 TEST(Union2) { Tests().Union2(); } | 1181 TEST(Union2) { Tests().Union2(); } |
| 1386 | 1182 |
| 1387 TEST(Union3) { Tests().Union3(); } | 1183 TEST(Union3) { Tests().Union3(); } |
| 1388 | 1184 |
| 1389 TEST(Union4) { Tests().Union4(); } | 1185 TEST(Union4) { Tests().Union4(); } |
| 1390 | 1186 |
| 1391 TEST(Intersect) { Tests().Intersect(); } | 1187 TEST(Intersect) { Tests().Intersect(); } |
| 1392 | 1188 |
| 1393 TEST(Distributivity) { Tests().Distributivity(); } | 1189 TEST(Distributivity) { Tests().Distributivity(); } |
| 1394 | 1190 |
| 1395 TEST(GetRange) { Tests().GetRange(); } | 1191 TEST(GetRange) { Tests().GetRange(); } |
| OLD | NEW |