| 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" |
| 11 // FIXME(mstarzinger, marja): This is weird, but required because of the missing | 11 // FIXME(mstarzinger, marja): This is weird, but required because of the missing |
| 12 // (disallowed) include: src/factory.h -> src/objects-inl.h | 12 // (disallowed) include: src/factory.h -> src/objects-inl.h |
| 13 #include "src/objects-inl.h" | 13 #include "src/objects-inl.h" |
| 14 #include "src/types.h" | 14 #include "src/types.h" |
| 15 // FIXME(mstarzinger, marja): This is weird, but required because of the missing | 15 // FIXME(mstarzinger, marja): This is weird, but required because of the missing |
| 16 // (disallowed) include: src/type-feedback-vector.h -> | 16 // (disallowed) include: src/type-feedback-vector.h -> |
| 17 // src/type-feedback-vector-inl.h | 17 // src/type-feedback-vector-inl.h |
| 18 #include "src/type-feedback-vector-inl.h" | 18 #include "src/type-feedback-vector-inl.h" |
| 19 #include "test/cctest/cctest.h" | 19 #include "test/cctest/cctest.h" |
| 20 #include "test/cctest/types-fuzz.h" | 20 #include "test/cctest/types-fuzz.h" |
| 21 | 21 |
| 22 using namespace v8::internal; | 22 using namespace v8::internal; |
| 23 | 23 |
| 24 namespace { |
| 24 | 25 |
| 25 // Testing auxiliaries (breaking the Type abstraction). | 26 // Testing auxiliaries (breaking the Type abstraction). |
| 26 | 27 |
| 27 | 28 |
| 28 static bool IsInteger(double x) { | 29 static bool IsInteger(double x) { |
| 29 return nearbyint(x) == x && !i::IsMinusZero(x); // Allows for infinities. | 30 return nearbyint(x) == x && !i::IsMinusZero(x); // Allows for infinities. |
| 30 } | 31 } |
| 31 | 32 |
| 32 | 33 |
| 33 static bool IsInteger(i::Object* x) { | 34 static bool IsInteger(i::Object* x) { |
| 34 return x->IsNumber() && IsInteger(x->Number()); | 35 return x->IsNumber() && IsInteger(x->Number()); |
| 35 } | 36 } |
| 36 | 37 |
| 37 | 38 |
| 38 typedef uint32_t bitset; | 39 typedef uint32_t bitset; |
| 39 | 40 |
| 40 struct Tests { | 41 struct Tests { |
| 41 typedef Types::TypeVector::iterator TypeIterator; | 42 typedef Types::TypeVector::iterator TypeIterator; |
| 42 typedef Types::MapVector::iterator MapIterator; | |
| 43 typedef Types::ValueVector::iterator ValueIterator; | 43 typedef Types::ValueVector::iterator ValueIterator; |
| 44 | 44 |
| 45 Isolate* isolate; | 45 Isolate* isolate; |
| 46 HandleScope scope; | 46 HandleScope scope; |
| 47 Zone zone; | 47 Zone zone; |
| 48 Types T; | 48 Types T; |
| 49 | 49 |
| 50 Tests() | 50 Tests() |
| 51 : isolate(CcTest::InitIsolateOnce()), | 51 : isolate(CcTest::InitIsolateOnce()), |
| 52 scope(isolate), | 52 scope(isolate), |
| 53 zone(isolate->allocator()), | 53 zone(isolate->allocator()), |
| 54 T(&zone, isolate, isolate->random_number_generator()) {} | 54 T(&zone, isolate, isolate->random_number_generator()) {} |
| 55 | 55 |
| 56 bool IsBitset(Type* type) { return type->IsBitsetForTesting(); } | 56 bool IsBitset(Type* type) { return type->IsBitsetForTesting(); } |
| 57 bool IsUnion(Type* type) { return type->IsUnionForTesting(); } | 57 bool IsUnion(Type* type) { return type->IsUnionForTesting(); } |
| 58 BitsetType::bitset AsBitset(Type* type) { return type->AsBitsetForTesting(); } | 58 BitsetType::bitset AsBitset(Type* type) { return type->AsBitsetForTesting(); } |
| 59 UnionType* AsUnion(Type* type) { return type->AsUnionForTesting(); } | 59 UnionType* AsUnion(Type* type) { return type->AsUnionForTesting(); } |
| 60 | 60 |
| 61 bool Equal(Type* type1, Type* type2) { | 61 bool Equal(Type* type1, Type* type2) { |
| 62 return type1->Equals(type2) && | 62 return type1->Equals(type2) && |
| 63 this->IsBitset(type1) == this->IsBitset(type2) && | 63 this->IsBitset(type1) == this->IsBitset(type2) && |
| 64 this->IsUnion(type1) == this->IsUnion(type2) && | 64 this->IsUnion(type1) == this->IsUnion(type2) && |
| 65 type1->NumClasses() == type2->NumClasses() && | |
| 66 type1->NumConstants() == type2->NumConstants() && | 65 type1->NumConstants() == type2->NumConstants() && |
| 67 (!this->IsBitset(type1) || | 66 (!this->IsBitset(type1) || |
| 68 this->AsBitset(type1) == this->AsBitset(type2)) && | 67 this->AsBitset(type1) == this->AsBitset(type2)) && |
| 69 (!this->IsUnion(type1) || | 68 (!this->IsUnion(type1) || |
| 70 this->AsUnion(type1)->LengthForTesting() == | 69 this->AsUnion(type1)->LengthForTesting() == |
| 71 this->AsUnion(type2)->LengthForTesting()); | 70 this->AsUnion(type2)->LengthForTesting()); |
| 72 } | 71 } |
| 73 | 72 |
| 74 void CheckEqual(Type* type1, Type* type2) { CHECK(Equal(type1, type2)); } | 73 void CheckEqual(Type* type1, Type* type2) { CHECK(Equal(type1, type2)); } |
| 75 | 74 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 106 CHECK(!type1->Is(type2)); | 105 CHECK(!type1->Is(type2)); |
| 107 CHECK(!type2->Is(type1)); | 106 CHECK(!type2->Is(type1)); |
| 108 CHECK(!type1->Maybe(type2)); | 107 CHECK(!type1->Maybe(type2)); |
| 109 CHECK(!type2->Maybe(type1)); | 108 CHECK(!type2->Maybe(type1)); |
| 110 } | 109 } |
| 111 | 110 |
| 112 void IsSomeType() { | 111 void IsSomeType() { |
| 113 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { | 112 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { |
| 114 Type* t = *it; | 113 Type* t = *it; |
| 115 CHECK(1 == | 114 CHECK(1 == |
| 116 this->IsBitset(t) + t->IsClass() + t->IsConstant() + t->IsRange() + | 115 this->IsBitset(t) + t->IsConstant() + t->IsRange() + |
| 117 this->IsUnion(t) + t->IsArray() + t->IsFunction() + t->IsContext()); | 116 this->IsUnion(t) + t->IsArray() + t->IsFunction() + |
| 117 t->IsContext()); |
| 118 } | 118 } |
| 119 } | 119 } |
| 120 | 120 |
| 121 void Bitset() { | 121 void Bitset() { |
| 122 // None and Any are bitsets. | 122 // None and Any are bitsets. |
| 123 CHECK(this->IsBitset(T.None)); | 123 CHECK(this->IsBitset(T.None)); |
| 124 CHECK(this->IsBitset(T.Any)); | 124 CHECK(this->IsBitset(T.Any)); |
| 125 | 125 |
| 126 CHECK(bitset(0) == this->AsBitset(T.None)); | 126 CHECK(bitset(0) == this->AsBitset(T.None)); |
| 127 CHECK(bitset(0xfffffffeu) == this->AsBitset(T.Any)); | 127 CHECK(bitset(0xfffffffeu) == this->AsBitset(T.Any)); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 } | 186 } |
| 187 } | 187 } |
| 188 } | 188 } |
| 189 | 189 |
| 190 void PointwiseRepresentation() { | 190 void PointwiseRepresentation() { |
| 191 // Check we can decompose type into semantics and representation and | 191 // Check we can decompose type into semantics and representation and |
| 192 // then compose it back to get an equivalent type. | 192 // then compose it back to get an equivalent type. |
| 193 int counter = 0; | 193 int counter = 0; |
| 194 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { | 194 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { |
| 195 counter++; | 195 counter++; |
| 196 printf("Counter: %i\n", counter); | |
| 197 fflush(stdout); | |
| 198 Type* type1 = *it1; | 196 Type* type1 = *it1; |
| 199 Type* representation = T.Representation(type1); | 197 Type* representation = T.Representation(type1); |
| 200 Type* semantic = T.Semantic(type1); | 198 Type* semantic = T.Semantic(type1); |
| 201 Type* composed = T.Union(representation, semantic); | 199 Type* composed = T.Union(representation, semantic); |
| 202 CHECK(type1->Equals(composed)); | 200 CHECK(type1->Equals(composed)); |
| 203 } | 201 } |
| 204 | 202 |
| 205 // Pointwiseness of Union. | 203 // Pointwiseness of Union. |
| 206 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { | 204 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { |
| 207 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { | 205 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 Type* representation2 = T.Representation(type2); | 246 Type* representation2 = T.Representation(type2); |
| 249 Type* semantic2 = T.Semantic(type2); | 247 Type* semantic2 = T.Semantic(type2); |
| 250 bool representation_is = representation1->Is(representation2); | 248 bool representation_is = representation1->Is(representation2); |
| 251 bool semantic_is = semantic1->Is(semantic2); | 249 bool semantic_is = semantic1->Is(semantic2); |
| 252 bool direct_is = type1->Is(type2); | 250 bool direct_is = type1->Is(type2); |
| 253 CHECK(direct_is == (semantic_is && representation_is)); | 251 CHECK(direct_is == (semantic_is && representation_is)); |
| 254 } | 252 } |
| 255 } | 253 } |
| 256 } | 254 } |
| 257 | 255 |
| 258 void Class() { | |
| 259 // Constructor | |
| 260 for (MapIterator mt = T.maps.begin(); mt != T.maps.end(); ++mt) { | |
| 261 Handle<i::Map> map = *mt; | |
| 262 Type* type = T.Class(map); | |
| 263 CHECK(type->IsClass()); | |
| 264 } | |
| 265 | |
| 266 // Map attribute | |
| 267 for (MapIterator mt = T.maps.begin(); mt != T.maps.end(); ++mt) { | |
| 268 Handle<i::Map> map = *mt; | |
| 269 Type* type = T.Class(map); | |
| 270 CHECK(*map == *type->AsClass()->Map()); | |
| 271 } | |
| 272 | |
| 273 // Functionality & Injectivity: Class(M1) = Class(M2) iff M1 = M2 | |
| 274 for (MapIterator mt1 = T.maps.begin(); mt1 != T.maps.end(); ++mt1) { | |
| 275 for (MapIterator mt2 = T.maps.begin(); mt2 != T.maps.end(); ++mt2) { | |
| 276 Handle<i::Map> map1 = *mt1; | |
| 277 Handle<i::Map> map2 = *mt2; | |
| 278 Type* type1 = T.Class(map1); | |
| 279 Type* type2 = T.Class(map2); | |
| 280 CHECK(Equal(type1, type2) == (*map1 == *map2)); | |
| 281 } | |
| 282 } | |
| 283 } | |
| 284 | |
| 285 void Constant() { | 256 void Constant() { |
| 286 // Constructor | 257 // Constructor |
| 287 for (ValueIterator vt = T.values.begin(); vt != T.values.end(); ++vt) { | 258 for (ValueIterator vt = T.values.begin(); vt != T.values.end(); ++vt) { |
| 288 Handle<i::Object> value = *vt; | 259 Handle<i::Object> value = *vt; |
| 289 Type* type = T.Constant(value); | 260 Type* type = T.Constant(value); |
| 290 CHECK(type->IsConstant()); | 261 CHECK(type->IsConstant()); |
| 291 } | 262 } |
| 292 | 263 |
| 293 // Value attribute | 264 // Value attribute |
| 294 for (ValueIterator vt = T.values.begin(); vt != T.values.end(); ++vt) { | 265 for (ValueIterator vt = T.values.begin(); vt != T.values.end(); ++vt) { |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 557 Handle<i::Object> value = *vt; | 528 Handle<i::Object> value = *vt; |
| 558 Type* type = *it; | 529 Type* type = *it; |
| 559 Type* const_type = T.Constant(value); | 530 Type* const_type = T.Constant(value); |
| 560 Type* of_type = T.Of(value); | 531 Type* of_type = T.Of(value); |
| 561 CHECK(!const_type->Is(type) || | 532 CHECK(!const_type->Is(type) || |
| 562 of_type->Is(type) || type->Maybe(const_type)); | 533 of_type->Is(type) || type->Maybe(const_type)); |
| 563 } | 534 } |
| 564 } | 535 } |
| 565 } | 536 } |
| 566 | 537 |
| 567 void NowOf() { | |
| 568 // Constant(V)->NowIs(NowOf(V)) | |
| 569 for (ValueIterator vt = T.values.begin(); vt != T.values.end(); ++vt) { | |
| 570 Handle<i::Object> value = *vt; | |
| 571 Type* const_type = T.Constant(value); | |
| 572 Type* nowof_type = T.NowOf(value); | |
| 573 CHECK(const_type->NowIs(nowof_type)); | |
| 574 } | |
| 575 | |
| 576 // NowOf(V)->Is(Of(V)) | |
| 577 for (ValueIterator vt = T.values.begin(); vt != T.values.end(); ++vt) { | |
| 578 Handle<i::Object> value = *vt; | |
| 579 Type* nowof_type = T.NowOf(value); | |
| 580 Type* of_type = T.Of(value); | |
| 581 CHECK(nowof_type->Is(of_type)); | |
| 582 } | |
| 583 | |
| 584 // If NowOf(V)->NowIs(T), then Constant(V)->NowIs(T) | |
| 585 for (ValueIterator vt = T.values.begin(); vt != T.values.end(); ++vt) { | |
| 586 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { | |
| 587 Handle<i::Object> value = *vt; | |
| 588 Type* type = *it; | |
| 589 Type* const_type = T.Constant(value); | |
| 590 Type* nowof_type = T.NowOf(value); | |
| 591 CHECK(!nowof_type->NowIs(type) || const_type->NowIs(type)); | |
| 592 } | |
| 593 } | |
| 594 | |
| 595 // If Constant(V)->NowIs(T), | |
| 596 // then NowOf(V)->NowIs(T) or T->Maybe(Constant(V)) | |
| 597 for (ValueIterator vt = T.values.begin(); vt != T.values.end(); ++vt) { | |
| 598 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { | |
| 599 Handle<i::Object> value = *vt; | |
| 600 Type* type = *it; | |
| 601 Type* const_type = T.Constant(value); | |
| 602 Type* nowof_type = T.NowOf(value); | |
| 603 CHECK(!const_type->NowIs(type) || | |
| 604 nowof_type->NowIs(type) || type->Maybe(const_type)); | |
| 605 } | |
| 606 } | |
| 607 | |
| 608 // If Constant(V)->Is(T), | |
| 609 // then NowOf(V)->Is(T) or T->Maybe(Constant(V)) | |
| 610 for (ValueIterator vt = T.values.begin(); vt != T.values.end(); ++vt) { | |
| 611 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { | |
| 612 Handle<i::Object> value = *vt; | |
| 613 Type* type = *it; | |
| 614 Type* const_type = T.Constant(value); | |
| 615 Type* nowof_type = T.NowOf(value); | |
| 616 CHECK(!const_type->Is(type) || | |
| 617 nowof_type->Is(type) || type->Maybe(const_type)); | |
| 618 } | |
| 619 } | |
| 620 } | |
| 621 | |
| 622 void MinMax() { | 538 void MinMax() { |
| 623 // If b is regular numeric bitset, then Range(b->Min(), b->Max())->Is(b). | 539 // If b is regular numeric bitset, then Range(b->Min(), b->Max())->Is(b). |
| 624 // TODO(neis): Need to ignore representation for this to be true. | 540 // TODO(neis): Need to ignore representation for this to be true. |
| 625 /* | 541 /* |
| 626 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { | 542 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { |
| 627 Type* type = *it; | 543 Type* type = *it; |
| 628 if (this->IsBitset(type) && type->Is(T.Number) && | 544 if (this->IsBitset(type) && type->Is(T.Number) && |
| 629 !type->Is(T.None) && !type->Is(T.NaN)) { | 545 !type->Is(T.None) && !type->Is(T.NaN)) { |
| 630 Type* range = T.Range( | 546 Type* range = T.Range( |
| 631 isolate->factory()->NewNumber(type->Min()), | 547 isolate->factory()->NewNumber(type->Min()), |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 787 } | 703 } |
| 788 } | 704 } |
| 789 | 705 |
| 790 // (In-)Compatibilities. | 706 // (In-)Compatibilities. |
| 791 for (TypeIterator i = T.types.begin(); i != T.types.end(); ++i) { | 707 for (TypeIterator i = T.types.begin(); i != T.types.end(); ++i) { |
| 792 for (TypeIterator j = T.types.begin(); j != T.types.end(); ++j) { | 708 for (TypeIterator j = T.types.begin(); j != T.types.end(); ++j) { |
| 793 Type* type1 = *i; | 709 Type* type1 = *i; |
| 794 Type* type2 = *j; | 710 Type* type2 = *j; |
| 795 CHECK(!type1->Is(type2) || this->IsBitset(type2) || | 711 CHECK(!type1->Is(type2) || this->IsBitset(type2) || |
| 796 this->IsUnion(type2) || this->IsUnion(type1) || | 712 this->IsUnion(type2) || this->IsUnion(type1) || |
| 797 (type1->IsClass() && type2->IsClass()) || | |
| 798 (type1->IsConstant() && type2->IsConstant()) || | 713 (type1->IsConstant() && type2->IsConstant()) || |
| 799 (type1->IsConstant() && type2->IsRange()) || | 714 (type1->IsConstant() && type2->IsRange()) || |
| 800 (this->IsBitset(type1) && type2->IsRange()) || | 715 (this->IsBitset(type1) && type2->IsRange()) || |
| 801 (type1->IsRange() && type2->IsRange()) || | 716 (type1->IsRange() && type2->IsRange()) || |
| 802 (type1->IsContext() && type2->IsContext()) || | 717 (type1->IsContext() && type2->IsContext()) || |
| 803 (type1->IsArray() && type2->IsArray()) || | 718 (type1->IsArray() && type2->IsArray()) || |
| 804 (type1->IsFunction() && type2->IsFunction()) || | 719 (type1->IsFunction() && type2->IsFunction()) || |
| 805 !type1->IsInhabited()); | 720 !type1->IsInhabited()); |
| 806 } | 721 } |
| 807 } | 722 } |
| 808 } | 723 } |
| 809 | 724 |
| 810 void Is2() { | 725 void Is2() { |
| 811 // Class(M1)->Is(Class(M2)) iff M1 = M2 | |
| 812 for (MapIterator mt1 = T.maps.begin(); mt1 != T.maps.end(); ++mt1) { | |
| 813 for (MapIterator mt2 = T.maps.begin(); mt2 != T.maps.end(); ++mt2) { | |
| 814 Handle<i::Map> map1 = *mt1; | |
| 815 Handle<i::Map> map2 = *mt2; | |
| 816 Type* class_type1 = T.Class(map1); | |
| 817 Type* class_type2 = T.Class(map2); | |
| 818 CHECK(class_type1->Is(class_type2) == (*map1 == *map2)); | |
| 819 } | |
| 820 } | |
| 821 | |
| 822 // Range(X1, Y1)->Is(Range(X2, Y2)) iff X1 >= X2 /\ Y1 <= Y2 | 726 // Range(X1, Y1)->Is(Range(X2, Y2)) iff X1 >= X2 /\ Y1 <= Y2 |
| 823 for (ValueIterator i1 = T.integers.begin(); | 727 for (ValueIterator i1 = T.integers.begin(); |
| 824 i1 != T.integers.end(); ++i1) { | 728 i1 != T.integers.end(); ++i1) { |
| 825 for (ValueIterator j1 = i1; | 729 for (ValueIterator j1 = i1; |
| 826 j1 != T.integers.end(); ++j1) { | 730 j1 != T.integers.end(); ++j1) { |
| 827 for (ValueIterator i2 = T.integers.begin(); | 731 for (ValueIterator i2 = T.integers.begin(); |
| 828 i2 != T.integers.end(); ++i2) { | 732 i2 != T.integers.end(); ++i2) { |
| 829 for (ValueIterator j2 = i2; | 733 for (ValueIterator j2 = i2; |
| 830 j2 != T.integers.end(); ++j2) { | 734 j2 != T.integers.end(); ++j2) { |
| 831 double min1 = (*i1)->Number(); | 735 double min1 = (*i1)->Number(); |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 952 CheckSub(T.Proxy, T.Receiver); | 856 CheckSub(T.Proxy, T.Receiver); |
| 953 CheckSub(T.OtherObject, T.Object); | 857 CheckSub(T.OtherObject, T.Object); |
| 954 CheckSub(T.OtherUndetectable, T.Object); | 858 CheckSub(T.OtherUndetectable, T.Object); |
| 955 CheckSub(T.OtherObject, T.Object); | 859 CheckSub(T.OtherObject, T.Object); |
| 956 | 860 |
| 957 CheckUnordered(T.Object, T.Proxy); | 861 CheckUnordered(T.Object, T.Proxy); |
| 958 CheckUnordered(T.OtherObject, T.Undetectable); | 862 CheckUnordered(T.OtherObject, T.Undetectable); |
| 959 | 863 |
| 960 // Subtyping between concrete structural types | 864 // Subtyping between concrete structural types |
| 961 | 865 |
| 962 CheckSub(T.ObjectClass, T.Object); | |
| 963 CheckSub(T.ArrayClass, T.OtherObject); | |
| 964 CheckSub(T.UninitializedClass, T.Internal); | |
| 965 CheckUnordered(T.ObjectClass, T.ArrayClass); | |
| 966 CheckUnordered(T.UninitializedClass, T.Null); | |
| 967 CheckUnordered(T.UninitializedClass, T.Undefined); | |
| 968 | |
| 969 CheckSub(T.SmiConstant, T.SignedSmall); | 866 CheckSub(T.SmiConstant, T.SignedSmall); |
| 970 CheckSub(T.SmiConstant, T.Signed32); | 867 CheckSub(T.SmiConstant, T.Signed32); |
| 971 CheckSub(T.SmiConstant, T.Number); | 868 CheckSub(T.SmiConstant, T.Number); |
| 972 CheckSub(T.ObjectConstant1, T.Object); | 869 CheckSub(T.ObjectConstant1, T.Object); |
| 973 CheckSub(T.ObjectConstant2, T.Object); | 870 CheckSub(T.ObjectConstant2, T.Object); |
| 974 CheckSub(T.ArrayConstant, T.Object); | 871 CheckSub(T.ArrayConstant, T.Object); |
| 975 CheckSub(T.ArrayConstant, T.OtherObject); | 872 CheckSub(T.ArrayConstant, T.OtherObject); |
| 976 CheckSub(T.ArrayConstant, T.Receiver); | 873 CheckSub(T.ArrayConstant, T.Receiver); |
| 977 CheckSub(T.UninitializedConstant, T.Internal); | 874 CheckSub(T.UninitializedConstant, T.Internal); |
| 978 CheckUnordered(T.ObjectConstant1, T.ObjectConstant2); | 875 CheckUnordered(T.ObjectConstant1, T.ObjectConstant2); |
| 979 CheckUnordered(T.ObjectConstant1, T.ArrayConstant); | 876 CheckUnordered(T.ObjectConstant1, T.ArrayConstant); |
| 980 CheckUnordered(T.UninitializedConstant, T.Null); | 877 CheckUnordered(T.UninitializedConstant, T.Null); |
| 981 CheckUnordered(T.UninitializedConstant, T.Undefined); | 878 CheckUnordered(T.UninitializedConstant, T.Undefined); |
| 982 | 879 |
| 983 CheckUnordered(T.ObjectConstant1, T.ObjectClass); | |
| 984 CheckUnordered(T.ObjectConstant2, T.ObjectClass); | |
| 985 CheckUnordered(T.ObjectConstant1, T.ArrayClass); | |
| 986 CheckUnordered(T.ObjectConstant2, T.ArrayClass); | |
| 987 CheckUnordered(T.ArrayConstant, T.ObjectClass); | |
| 988 | |
| 989 CheckSub(T.NumberArray, T.OtherObject); | 880 CheckSub(T.NumberArray, T.OtherObject); |
| 990 CheckSub(T.NumberArray, T.Receiver); | 881 CheckSub(T.NumberArray, T.Receiver); |
| 991 CheckSub(T.NumberArray, T.Object); | 882 CheckSub(T.NumberArray, T.Object); |
| 992 CheckUnordered(T.StringArray, T.AnyArray); | 883 CheckUnordered(T.StringArray, T.AnyArray); |
| 993 | 884 |
| 994 CheckSub(T.MethodFunction, T.Object); | 885 CheckSub(T.MethodFunction, T.Object); |
| 995 CheckSub(T.NumberFunction1, T.Object); | 886 CheckSub(T.NumberFunction1, T.Object); |
| 996 CheckUnordered(T.SignedFunction1, T.NumberFunction1); | 887 CheckUnordered(T.SignedFunction1, T.NumberFunction1); |
| 997 CheckUnordered(T.NumberFunction1, T.NumberFunction2); | 888 CheckUnordered(T.NumberFunction1, T.NumberFunction2); |
| 998 } | 889 } |
| 999 | 890 |
| 1000 void NowIs() { | |
| 1001 // Least Element (Bottom): None->NowIs(T) | |
| 1002 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { | |
| 1003 Type* type = *it; | |
| 1004 CHECK(T.None->NowIs(type)); | |
| 1005 } | |
| 1006 | |
| 1007 // Greatest Element (Top): T->NowIs(Any) | |
| 1008 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { | |
| 1009 Type* type = *it; | |
| 1010 CHECK(type->NowIs(T.Any)); | |
| 1011 } | |
| 1012 | |
| 1013 // Bottom Uniqueness: T->NowIs(None) implies T = None | |
| 1014 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { | |
| 1015 Type* type = *it; | |
| 1016 if (type->NowIs(T.None)) CheckEqual(type, T.None); | |
| 1017 } | |
| 1018 | |
| 1019 // Top Uniqueness: Any->NowIs(T) implies T = Any | |
| 1020 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { | |
| 1021 Type* type = *it; | |
| 1022 if (T.Any->NowIs(type)) CheckEqual(type, T.Any); | |
| 1023 } | |
| 1024 | |
| 1025 // Reflexivity: T->NowIs(T) | |
| 1026 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { | |
| 1027 Type* type = *it; | |
| 1028 CHECK(type->NowIs(type)); | |
| 1029 } | |
| 1030 | |
| 1031 // Transitivity: T1->NowIs(T2) and T2->NowIs(T3) implies T1->NowIs(T3) | |
| 1032 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { | |
| 1033 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { | |
| 1034 for (TypeIterator it3 = T.types.begin(); it3 != T.types.end(); ++it3) { | |
| 1035 Type* type1 = *it1; | |
| 1036 Type* type2 = *it2; | |
| 1037 Type* type3 = *it3; | |
| 1038 CHECK(!(type1->NowIs(type2) && type2->NowIs(type3)) || | |
| 1039 type1->NowIs(type3)); | |
| 1040 } | |
| 1041 } | |
| 1042 } | |
| 1043 | |
| 1044 // Antisymmetry: T1->NowIs(T2) and T2->NowIs(T1) iff T1 = T2 | |
| 1045 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { | |
| 1046 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { | |
| 1047 Type* type1 = *it1; | |
| 1048 Type* type2 = *it2; | |
| 1049 CHECK((type1->NowIs(type2) && type2->NowIs(type1)) == | |
| 1050 Equal(type1, type2)); | |
| 1051 } | |
| 1052 } | |
| 1053 | |
| 1054 // T1->Is(T2) implies T1->NowIs(T2) | |
| 1055 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { | |
| 1056 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { | |
| 1057 Type* type1 = *it1; | |
| 1058 Type* type2 = *it2; | |
| 1059 CHECK(!type1->Is(type2) || type1->NowIs(type2)); | |
| 1060 } | |
| 1061 } | |
| 1062 | |
| 1063 // Constant(V1)->NowIs(Constant(V2)) iff V1 = V2 | |
| 1064 for (ValueIterator vt1 = T.values.begin(); vt1 != T.values.end(); ++vt1) { | |
| 1065 for (ValueIterator vt2 = T.values.begin(); vt2 != T.values.end(); ++vt2) { | |
| 1066 Handle<i::Object> value1 = *vt1; | |
| 1067 Handle<i::Object> value2 = *vt2; | |
| 1068 Type* const_type1 = T.Constant(value1); | |
| 1069 Type* const_type2 = T.Constant(value2); | |
| 1070 CHECK(const_type1->NowIs(const_type2) == (*value1 == *value2)); | |
| 1071 } | |
| 1072 } | |
| 1073 | |
| 1074 // Class(M1)->NowIs(Class(M2)) iff M1 = M2 | |
| 1075 for (MapIterator mt1 = T.maps.begin(); mt1 != T.maps.end(); ++mt1) { | |
| 1076 for (MapIterator mt2 = T.maps.begin(); mt2 != T.maps.end(); ++mt2) { | |
| 1077 Handle<i::Map> map1 = *mt1; | |
| 1078 Handle<i::Map> map2 = *mt2; | |
| 1079 Type* class_type1 = T.Class(map1); | |
| 1080 Type* class_type2 = T.Class(map2); | |
| 1081 CHECK(class_type1->NowIs(class_type2) == (*map1 == *map2)); | |
| 1082 } | |
| 1083 } | |
| 1084 | |
| 1085 // Constant(V)->NowIs(Class(M)) iff V has map M | |
| 1086 for (MapIterator mt = T.maps.begin(); mt != T.maps.end(); ++mt) { | |
| 1087 for (ValueIterator vt = T.values.begin(); vt != T.values.end(); ++vt) { | |
| 1088 Handle<i::Map> map = *mt; | |
| 1089 Handle<i::Object> value = *vt; | |
| 1090 Type* const_type = T.Constant(value); | |
| 1091 Type* class_type = T.Class(map); | |
| 1092 CHECK((value->IsHeapObject() && | |
| 1093 i::HeapObject::cast(*value)->map() == *map) | |
| 1094 == const_type->NowIs(class_type)); | |
| 1095 } | |
| 1096 } | |
| 1097 | |
| 1098 // Class(M)->NowIs(Constant(V)) never | |
| 1099 for (MapIterator mt = T.maps.begin(); mt != T.maps.end(); ++mt) { | |
| 1100 for (ValueIterator vt = T.values.begin(); vt != T.values.end(); ++vt) { | |
| 1101 Handle<i::Map> map = *mt; | |
| 1102 Handle<i::Object> value = *vt; | |
| 1103 Type* const_type = T.Constant(value); | |
| 1104 Type* class_type = T.Class(map); | |
| 1105 CHECK(!class_type->NowIs(const_type)); | |
| 1106 } | |
| 1107 } | |
| 1108 } | |
| 1109 | |
| 1110 void Contains() { | 891 void Contains() { |
| 1111 // T->Contains(V) iff Constant(V)->Is(T) | 892 // T->Contains(V) iff Constant(V)->Is(T) |
| 1112 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { | 893 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { |
| 1113 for (ValueIterator vt = T.values.begin(); vt != T.values.end(); ++vt) { | 894 for (ValueIterator vt = T.values.begin(); vt != T.values.end(); ++vt) { |
| 1114 Type* type = *it; | 895 Type* type = *it; |
| 1115 Handle<i::Object> value = *vt; | 896 Handle<i::Object> value = *vt; |
| 1116 Type* const_type = T.Constant(value); | 897 Type* const_type = T.Constant(value); |
| 1117 CHECK(type->Contains(value) == const_type->Is(type)); | 898 CHECK(type->Contains(value) == const_type->Is(type)); |
| 1118 } | 899 } |
| 1119 } | 900 } |
| 1120 } | 901 } |
| 1121 | 902 |
| 1122 void NowContains() { | |
| 1123 // T->NowContains(V) iff Constant(V)->NowIs(T) | |
| 1124 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { | |
| 1125 for (ValueIterator vt = T.values.begin(); vt != T.values.end(); ++vt) { | |
| 1126 Type* type = *it; | |
| 1127 Handle<i::Object> value = *vt; | |
| 1128 Type* const_type = T.Constant(value); | |
| 1129 CHECK(type->NowContains(value) == const_type->NowIs(type)); | |
| 1130 } | |
| 1131 } | |
| 1132 | |
| 1133 // T->Contains(V) implies T->NowContains(V) | |
| 1134 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { | |
| 1135 for (ValueIterator vt = T.values.begin(); vt != T.values.end(); ++vt) { | |
| 1136 Type* type = *it; | |
| 1137 Handle<i::Object> value = *vt; | |
| 1138 CHECK(!type->Contains(value) || type->NowContains(value)); | |
| 1139 } | |
| 1140 } | |
| 1141 | |
| 1142 // NowOf(V)->Is(T) implies T->NowContains(V) | |
| 1143 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { | |
| 1144 for (ValueIterator vt = T.values.begin(); vt != T.values.end(); ++vt) { | |
| 1145 Type* type = *it; | |
| 1146 Handle<i::Object> value = *vt; | |
| 1147 Type* nowof_type = T.Of(value); | |
| 1148 CHECK(!nowof_type->NowIs(type) || type->NowContains(value)); | |
| 1149 } | |
| 1150 } | |
| 1151 } | |
| 1152 | |
| 1153 void Maybe() { | 903 void Maybe() { |
| 1154 // T->Maybe(Any) iff T inhabited | 904 // T->Maybe(Any) iff T inhabited |
| 1155 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { | 905 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { |
| 1156 Type* type = *it; | 906 Type* type = *it; |
| 1157 CHECK(type->Maybe(T.Any) == type->IsInhabited()); | 907 CHECK(type->Maybe(T.Any) == type->IsInhabited()); |
| 1158 } | 908 } |
| 1159 | 909 |
| 1160 // T->Maybe(None) never | 910 // T->Maybe(None) never |
| 1161 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { | 911 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { |
| 1162 Type* type = *it; | 912 Type* type = *it; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1212 for (ValueIterator vt1 = T.values.begin(); vt1 != T.values.end(); ++vt1) { | 962 for (ValueIterator vt1 = T.values.begin(); vt1 != T.values.end(); ++vt1) { |
| 1213 for (ValueIterator vt2 = T.values.begin(); vt2 != T.values.end(); ++vt2) { | 963 for (ValueIterator vt2 = T.values.begin(); vt2 != T.values.end(); ++vt2) { |
| 1214 Handle<i::Object> value1 = *vt1; | 964 Handle<i::Object> value1 = *vt1; |
| 1215 Handle<i::Object> value2 = *vt2; | 965 Handle<i::Object> value2 = *vt2; |
| 1216 Type* const_type1 = T.Constant(value1); | 966 Type* const_type1 = T.Constant(value1); |
| 1217 Type* const_type2 = T.Constant(value2); | 967 Type* const_type2 = T.Constant(value2); |
| 1218 CHECK(const_type1->Maybe(const_type2) == (*value1 == *value2)); | 968 CHECK(const_type1->Maybe(const_type2) == (*value1 == *value2)); |
| 1219 } | 969 } |
| 1220 } | 970 } |
| 1221 | 971 |
| 1222 // Class(M1)->Maybe(Class(M2)) iff M1 = M2 | |
| 1223 for (MapIterator mt1 = T.maps.begin(); mt1 != T.maps.end(); ++mt1) { | |
| 1224 for (MapIterator mt2 = T.maps.begin(); mt2 != T.maps.end(); ++mt2) { | |
| 1225 Handle<i::Map> map1 = *mt1; | |
| 1226 Handle<i::Map> map2 = *mt2; | |
| 1227 Type* class_type1 = T.Class(map1); | |
| 1228 Type* class_type2 = T.Class(map2); | |
| 1229 CHECK(class_type1->Maybe(class_type2) == (*map1 == *map2)); | |
| 1230 } | |
| 1231 } | |
| 1232 | |
| 1233 // Constant(V)->Maybe(Class(M)) never | |
| 1234 // This does NOT hold! | |
| 1235 /* | |
| 1236 for (MapIterator mt = T.maps.begin(); mt != T.maps.end(); ++mt) { | |
| 1237 for (ValueIterator vt = T.values.begin(); vt != T.values.end(); ++vt) { | |
| 1238 Handle<i::Map> map = *mt; | |
| 1239 Handle<i::Object> value = *vt; | |
| 1240 Type* const_type = T.Constant(value); | |
| 1241 Type* class_type = T.Class(map); | |
| 1242 CHECK(!const_type->Maybe(class_type)); | |
| 1243 } | |
| 1244 } | |
| 1245 */ | |
| 1246 | |
| 1247 // Class(M)->Maybe(Constant(V)) never | |
| 1248 // This does NOT hold! | |
| 1249 /* | |
| 1250 for (MapIterator mt = T.maps.begin(); mt != T.maps.end(); ++mt) { | |
| 1251 for (ValueIterator vt = T.values.begin(); vt != T.values.end(); ++vt) { | |
| 1252 Handle<i::Map> map = *mt; | |
| 1253 Handle<i::Object> value = *vt; | |
| 1254 Type* const_type = T.Constant(value); | |
| 1255 Type* class_type = T.Class(map); | |
| 1256 CHECK(!class_type->Maybe(const_type)); | |
| 1257 } | |
| 1258 } | |
| 1259 */ | |
| 1260 | |
| 1261 // Basic types | 972 // Basic types |
| 1262 CheckDisjoint(T.Boolean, T.Null); | 973 CheckDisjoint(T.Boolean, T.Null); |
| 1263 CheckDisjoint(T.Undefined, T.Null); | 974 CheckDisjoint(T.Undefined, T.Null); |
| 1264 CheckDisjoint(T.Boolean, T.Undefined); | 975 CheckDisjoint(T.Boolean, T.Undefined); |
| 1265 CheckOverlap(T.SignedSmall, T.Number); | 976 CheckOverlap(T.SignedSmall, T.Number); |
| 1266 CheckOverlap(T.NaN, T.Number); | 977 CheckOverlap(T.NaN, T.Number); |
| 1267 CheckDisjoint(T.Signed32, T.NaN); | 978 CheckDisjoint(T.Signed32, T.NaN); |
| 1268 CheckOverlap(T.UniqueName, T.Name); | 979 CheckOverlap(T.UniqueName, T.Name); |
| 1269 CheckOverlap(T.String, T.Name); | 980 CheckOverlap(T.String, T.Name); |
| 1270 CheckOverlap(T.InternalizedString, T.String); | 981 CheckOverlap(T.InternalizedString, T.String); |
| 1271 CheckOverlap(T.InternalizedString, T.UniqueName); | 982 CheckOverlap(T.InternalizedString, T.UniqueName); |
| 1272 CheckOverlap(T.InternalizedString, T.Name); | 983 CheckOverlap(T.InternalizedString, T.Name); |
| 1273 CheckOverlap(T.Symbol, T.UniqueName); | 984 CheckOverlap(T.Symbol, T.UniqueName); |
| 1274 CheckOverlap(T.Symbol, T.Name); | 985 CheckOverlap(T.Symbol, T.Name); |
| 1275 CheckOverlap(T.String, T.UniqueName); | 986 CheckOverlap(T.String, T.UniqueName); |
| 1276 CheckDisjoint(T.String, T.Symbol); | 987 CheckDisjoint(T.String, T.Symbol); |
| 1277 CheckDisjoint(T.InternalizedString, T.Symbol); | 988 CheckDisjoint(T.InternalizedString, T.Symbol); |
| 1278 CheckOverlap(T.Object, T.Receiver); | 989 CheckOverlap(T.Object, T.Receiver); |
| 1279 CheckOverlap(T.OtherObject, T.Object); | 990 CheckOverlap(T.OtherObject, T.Object); |
| 1280 CheckOverlap(T.Proxy, T.Receiver); | 991 CheckOverlap(T.Proxy, T.Receiver); |
| 1281 CheckDisjoint(T.Object, T.Proxy); | 992 CheckDisjoint(T.Object, T.Proxy); |
| 1282 | 993 |
| 1283 // Structural types | 994 // Structural types |
| 1284 CheckOverlap(T.ObjectClass, T.Object); | |
| 1285 CheckOverlap(T.ArrayClass, T.Object); | |
| 1286 CheckOverlap(T.ObjectClass, T.ObjectClass); | |
| 1287 CheckOverlap(T.ArrayClass, T.ArrayClass); | |
| 1288 CheckDisjoint(T.ObjectClass, T.ArrayClass); | |
| 1289 CheckOverlap(T.SmiConstant, T.SignedSmall); | 995 CheckOverlap(T.SmiConstant, T.SignedSmall); |
| 1290 CheckOverlap(T.SmiConstant, T.Signed32); | 996 CheckOverlap(T.SmiConstant, T.Signed32); |
| 1291 CheckOverlap(T.SmiConstant, T.Number); | 997 CheckOverlap(T.SmiConstant, T.Number); |
| 1292 CheckOverlap(T.ObjectConstant1, T.Object); | 998 CheckOverlap(T.ObjectConstant1, T.Object); |
| 1293 CheckOverlap(T.ObjectConstant2, T.Object); | 999 CheckOverlap(T.ObjectConstant2, T.Object); |
| 1294 CheckOverlap(T.ArrayConstant, T.Object); | 1000 CheckOverlap(T.ArrayConstant, T.Object); |
| 1295 CheckOverlap(T.ArrayConstant, T.Receiver); | 1001 CheckOverlap(T.ArrayConstant, T.Receiver); |
| 1296 CheckOverlap(T.ObjectConstant1, T.ObjectConstant1); | 1002 CheckOverlap(T.ObjectConstant1, T.ObjectConstant1); |
| 1297 CheckDisjoint(T.ObjectConstant1, T.ObjectConstant2); | 1003 CheckDisjoint(T.ObjectConstant1, T.ObjectConstant2); |
| 1298 CheckDisjoint(T.ObjectConstant1, T.ArrayConstant); | 1004 CheckDisjoint(T.ObjectConstant1, T.ArrayConstant); |
| 1299 CheckOverlap(T.ObjectConstant1, T.ArrayClass); | |
| 1300 CheckOverlap(T.ObjectConstant2, T.ArrayClass); | |
| 1301 CheckOverlap(T.ArrayConstant, T.ObjectClass); | |
| 1302 CheckOverlap(T.NumberArray, T.Receiver); | 1005 CheckOverlap(T.NumberArray, T.Receiver); |
| 1303 CheckDisjoint(T.NumberArray, T.AnyArray); | 1006 CheckDisjoint(T.NumberArray, T.AnyArray); |
| 1304 CheckDisjoint(T.NumberArray, T.StringArray); | 1007 CheckDisjoint(T.NumberArray, T.StringArray); |
| 1305 CheckOverlap(T.MethodFunction, T.Object); | 1008 CheckOverlap(T.MethodFunction, T.Object); |
| 1306 CheckDisjoint(T.SignedFunction1, T.NumberFunction1); | 1009 CheckDisjoint(T.SignedFunction1, T.NumberFunction1); |
| 1307 CheckDisjoint(T.SignedFunction1, T.NumberFunction2); | 1010 CheckDisjoint(T.SignedFunction1, T.NumberFunction2); |
| 1308 CheckDisjoint(T.NumberFunction1, T.NumberFunction2); | 1011 CheckDisjoint(T.NumberFunction1, T.NumberFunction2); |
| 1309 CheckDisjoint(T.SignedFunction1, T.MethodFunction); | 1012 CheckDisjoint(T.SignedFunction1, T.MethodFunction); |
| 1310 CheckOverlap(T.ObjectConstant1, T.ObjectClass); // !!! | |
| 1311 CheckOverlap(T.ObjectConstant2, T.ObjectClass); // !!! | |
| 1312 CheckOverlap(T.NumberClass, T.Intersect(T.Number, T.Tagged)); // !!! | |
| 1313 } | 1013 } |
| 1314 | 1014 |
| 1315 void Union1() { | 1015 void Union1() { |
| 1316 // Identity: Union(T, None) = T | 1016 // Identity: Union(T, None) = T |
| 1317 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { | 1017 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { |
| 1318 Type* type = *it; | 1018 Type* type = *it; |
| 1319 Type* union_type = T.Union(type, T.None); | 1019 Type* union_type = T.Union(type, T.None); |
| 1320 CheckEqual(union_type, type); | 1020 CheckEqual(union_type, type); |
| 1321 } | 1021 } |
| 1322 | 1022 |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1438 Type* type2 = *it2; | 1138 Type* type2 = *it2; |
| 1439 Type* type3 = *it3; | 1139 Type* type3 = *it3; |
| 1440 Type* union23 = T.Union(type2, type3); | 1140 Type* union23 = T.Union(type2, type3); |
| 1441 CHECK(!(type1->Is(type2) || type1->Is(type3)) || type1->Is(union23)); | 1141 CHECK(!(type1->Is(type2) || type1->Is(type3)) || type1->Is(union23)); |
| 1442 } | 1142 } |
| 1443 } | 1143 } |
| 1444 } | 1144 } |
| 1445 } | 1145 } |
| 1446 | 1146 |
| 1447 void Union4() { | 1147 void Union4() { |
| 1448 // Class-class | |
| 1449 CheckSub(T.Union(T.ObjectClass, T.ArrayClass), T.Object); | |
| 1450 CheckOverlap(T.Union(T.ObjectClass, T.ArrayClass), T.OtherObject); | |
| 1451 CheckOverlap(T.Union(T.ObjectClass, T.ArrayClass), T.Receiver); | |
| 1452 CheckDisjoint(T.Union(T.ObjectClass, T.ArrayClass), T.Number); | |
| 1453 | |
| 1454 // Constant-constant | 1148 // Constant-constant |
| 1455 CheckSub(T.Union(T.ObjectConstant1, T.ObjectConstant2), T.Object); | 1149 CheckSub(T.Union(T.ObjectConstant1, T.ObjectConstant2), T.Object); |
| 1456 CheckOverlap(T.Union(T.ObjectConstant1, T.ArrayConstant), T.OtherObject); | 1150 CheckOverlap(T.Union(T.ObjectConstant1, T.ArrayConstant), T.OtherObject); |
| 1457 CheckUnordered( | |
| 1458 T.Union(T.ObjectConstant1, T.ObjectConstant2), T.ObjectClass); | |
| 1459 CheckOverlap(T.Union(T.ObjectConstant1, T.ArrayConstant), T.OtherObject); | 1151 CheckOverlap(T.Union(T.ObjectConstant1, T.ArrayConstant), T.OtherObject); |
| 1460 CheckDisjoint( | 1152 CheckDisjoint( |
| 1461 T.Union(T.ObjectConstant1, T.ArrayConstant), T.Number); | 1153 T.Union(T.ObjectConstant1, T.ArrayConstant), T.Number); |
| 1462 CheckOverlap( | |
| 1463 T.Union(T.ObjectConstant1, T.ArrayConstant), T.ObjectClass); // !!! | |
| 1464 | 1154 |
| 1465 // Bitset-array | 1155 // Bitset-array |
| 1466 CHECK(this->IsBitset(T.Union(T.AnyArray, T.Receiver))); | 1156 CHECK(this->IsBitset(T.Union(T.AnyArray, T.Receiver))); |
| 1467 CHECK(this->IsUnion(T.Union(T.NumberArray, T.Number))); | 1157 CHECK(this->IsUnion(T.Union(T.NumberArray, T.Number))); |
| 1468 | 1158 |
| 1469 CheckEqual(T.Union(T.AnyArray, T.Receiver), T.Receiver); | 1159 CheckEqual(T.Union(T.AnyArray, T.Receiver), T.Receiver); |
| 1470 CheckEqual(T.Union(T.AnyArray, T.OtherObject), T.OtherObject); | 1160 CheckEqual(T.Union(T.AnyArray, T.OtherObject), T.OtherObject); |
| 1471 CheckUnordered(T.Union(T.AnyArray, T.String), T.Receiver); | 1161 CheckUnordered(T.Union(T.AnyArray, T.String), T.Receiver); |
| 1472 CheckOverlap(T.Union(T.NumberArray, T.String), T.Object); | 1162 CheckOverlap(T.Union(T.NumberArray, T.String), T.Object); |
| 1473 CheckDisjoint(T.Union(T.NumberArray, T.String), T.Number); | 1163 CheckDisjoint(T.Union(T.NumberArray, T.String), T.Number); |
| 1474 | 1164 |
| 1475 // Bitset-function | 1165 // Bitset-function |
| 1476 CHECK(this->IsBitset(T.Union(T.MethodFunction, T.Object))); | 1166 CHECK(this->IsBitset(T.Union(T.MethodFunction, T.Object))); |
| 1477 CHECK(this->IsUnion(T.Union(T.NumberFunction1, T.Number))); | 1167 CHECK(this->IsUnion(T.Union(T.NumberFunction1, T.Number))); |
| 1478 | 1168 |
| 1479 CheckEqual(T.Union(T.MethodFunction, T.Object), T.Object); | 1169 CheckEqual(T.Union(T.MethodFunction, T.Object), T.Object); |
| 1480 CheckUnordered(T.Union(T.NumberFunction1, T.String), T.Object); | 1170 CheckUnordered(T.Union(T.NumberFunction1, T.String), T.Object); |
| 1481 CheckOverlap(T.Union(T.NumberFunction2, T.String), T.Object); | 1171 CheckOverlap(T.Union(T.NumberFunction2, T.String), T.Object); |
| 1482 CheckDisjoint(T.Union(T.NumberFunction1, T.String), T.Number); | 1172 CheckDisjoint(T.Union(T.NumberFunction1, T.String), T.Number); |
| 1483 | 1173 |
| 1484 // Bitset-class | |
| 1485 CheckSub(T.Union(T.ObjectClass, T.SignedSmall), | |
| 1486 T.Union(T.Object, T.Number)); | |
| 1487 CheckSub(T.Union(T.ObjectClass, T.OtherObject), T.Object); | |
| 1488 CheckUnordered(T.Union(T.ObjectClass, T.String), T.OtherObject); | |
| 1489 CheckOverlap(T.Union(T.ObjectClass, T.String), T.Object); | |
| 1490 CheckDisjoint(T.Union(T.ObjectClass, T.String), T.Number); | |
| 1491 | |
| 1492 // Bitset-constant | 1174 // Bitset-constant |
| 1493 CheckSub( | 1175 CheckSub( |
| 1494 T.Union(T.ObjectConstant1, T.Signed32), T.Union(T.Object, T.Number)); | 1176 T.Union(T.ObjectConstant1, T.Signed32), T.Union(T.Object, T.Number)); |
| 1495 CheckSub(T.Union(T.ObjectConstant1, T.OtherObject), T.Object); | 1177 CheckSub(T.Union(T.ObjectConstant1, T.OtherObject), T.Object); |
| 1496 CheckUnordered(T.Union(T.ObjectConstant1, T.String), T.OtherObject); | 1178 CheckUnordered(T.Union(T.ObjectConstant1, T.String), T.OtherObject); |
| 1497 CheckOverlap(T.Union(T.ObjectConstant1, T.String), T.Object); | 1179 CheckOverlap(T.Union(T.ObjectConstant1, T.String), T.Object); |
| 1498 CheckDisjoint(T.Union(T.ObjectConstant1, T.String), T.Number); | 1180 CheckDisjoint(T.Union(T.ObjectConstant1, T.String), T.Number); |
| 1499 | 1181 |
| 1500 // Class-constant | |
| 1501 CheckSub(T.Union(T.ObjectConstant1, T.ArrayClass), T.Object); | |
| 1502 CheckUnordered(T.ObjectClass, T.Union(T.ObjectConstant1, T.ArrayClass)); | |
| 1503 CheckSub(T.Union(T.ObjectConstant1, T.ArrayClass), | |
| 1504 T.Union(T.Receiver, T.Object)); | |
| 1505 CheckUnordered(T.Union(T.ObjectConstant1, T.ArrayClass), T.ArrayConstant); | |
| 1506 CheckOverlap(T.Union(T.ObjectConstant1, T.ArrayClass), T.ObjectConstant2); | |
| 1507 CheckOverlap( | |
| 1508 T.Union(T.ObjectConstant1, T.ArrayClass), T.ObjectClass); // !!! | |
| 1509 | |
| 1510 // Bitset-union | |
| 1511 CheckSub( | |
| 1512 T.NaN, | |
| 1513 T.Union(T.Union(T.ArrayClass, T.ObjectConstant1), T.Number)); | |
| 1514 CheckSub( | |
| 1515 T.Union(T.Union(T.ArrayClass, T.ObjectConstant1), T.Signed32), | |
| 1516 T.Union(T.ObjectConstant1, T.Union(T.Number, T.ArrayClass))); | |
| 1517 | |
| 1518 // Class-union | |
| 1519 CheckSub( | |
| 1520 T.Union(T.ObjectClass, T.Union(T.ObjectConstant1, T.ObjectClass)), | |
| 1521 T.Object); | |
| 1522 CheckEqual( | |
| 1523 T.Union(T.Union(T.ArrayClass, T.ObjectConstant2), T.ArrayClass), | |
| 1524 T.Union(T.ArrayClass, T.ObjectConstant2)); | |
| 1525 | |
| 1526 // Constant-union | 1182 // Constant-union |
| 1527 CheckEqual( | 1183 CheckEqual( |
| 1528 T.Union( | 1184 T.Union( |
| 1529 T.ObjectConstant1, T.Union(T.ObjectConstant1, T.ObjectConstant2)), | 1185 T.ObjectConstant1, T.Union(T.ObjectConstant1, T.ObjectConstant2)), |
| 1530 T.Union(T.ObjectConstant2, T.ObjectConstant1)); | 1186 T.Union(T.ObjectConstant2, T.ObjectConstant1)); |
| 1531 CheckEqual( | 1187 CheckEqual( |
| 1532 T.Union( | 1188 T.Union( |
| 1533 T.Union(T.ArrayConstant, T.ObjectConstant2), T.ObjectConstant1), | 1189 T.Union(T.ArrayConstant, T.ObjectConstant2), T.ObjectConstant1), |
| 1534 T.Union( | 1190 T.Union( |
| 1535 T.ObjectConstant2, T.Union(T.ArrayConstant, T.ObjectConstant1))); | 1191 T.ObjectConstant2, T.Union(T.ArrayConstant, T.ObjectConstant1))); |
| 1536 | 1192 |
| 1537 // Array-union | 1193 // Array-union |
| 1538 CheckEqual( | 1194 CheckEqual( |
| 1539 T.Union(T.AnyArray, T.Union(T.NumberArray, T.AnyArray)), | 1195 T.Union(T.AnyArray, T.Union(T.NumberArray, T.AnyArray)), |
| 1540 T.Union(T.AnyArray, T.NumberArray)); | 1196 T.Union(T.AnyArray, T.NumberArray)); |
| 1541 CheckSub(T.Union(T.AnyArray, T.NumberArray), T.OtherObject); | 1197 CheckSub(T.Union(T.AnyArray, T.NumberArray), T.OtherObject); |
| 1542 | 1198 |
| 1543 // Function-union | 1199 // Function-union |
| 1544 CheckEqual( | 1200 CheckEqual( |
| 1545 T.Union(T.NumberFunction1, T.NumberFunction2), | 1201 T.Union(T.NumberFunction1, T.NumberFunction2), |
| 1546 T.Union(T.NumberFunction2, T.NumberFunction1)); | 1202 T.Union(T.NumberFunction2, T.NumberFunction1)); |
| 1547 CheckSub(T.Union(T.SignedFunction1, T.MethodFunction), T.Object); | 1203 CheckSub(T.Union(T.SignedFunction1, T.MethodFunction), T.Object); |
| 1548 | 1204 |
| 1549 // Union-union | 1205 // Union-union |
| 1550 CheckEqual( | 1206 CheckEqual( |
| 1551 T.Union( | 1207 T.Union( |
| 1552 T.Union(T.ObjectConstant2, T.ObjectConstant1), | 1208 T.Union(T.ObjectConstant2, T.ObjectConstant1), |
| 1553 T.Union(T.ObjectConstant1, T.ObjectConstant2)), | 1209 T.Union(T.ObjectConstant1, T.ObjectConstant2)), |
| 1554 T.Union(T.ObjectConstant2, T.ObjectConstant1)); | 1210 T.Union(T.ObjectConstant2, T.ObjectConstant1)); |
| 1555 CheckEqual(T.Union(T.Union(T.Number, T.ArrayClass), | |
| 1556 T.Union(T.SignedSmall, T.Receiver)), | |
| 1557 T.Union(T.Number, T.Receiver)); | |
| 1558 } | 1211 } |
| 1559 | 1212 |
| 1560 void Intersect() { | 1213 void Intersect() { |
| 1561 // Identity: Intersect(T, Any) = T | 1214 // Identity: Intersect(T, Any) = T |
| 1562 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { | 1215 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { |
| 1563 Type* type = *it; | 1216 Type* type = *it; |
| 1564 Type* intersect_type = T.Intersect(type, T.Any); | 1217 Type* intersect_type = T.Intersect(type, T.Any); |
| 1565 CheckEqual(intersect_type, type); | 1218 CheckEqual(intersect_type, type); |
| 1566 } | 1219 } |
| 1567 | 1220 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1583 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { | 1236 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { |
| 1584 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { | 1237 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { |
| 1585 Type* type1 = *it1; | 1238 Type* type1 = *it1; |
| 1586 Type* type2 = *it2; | 1239 Type* type2 = *it2; |
| 1587 Type* intersect12 = T.Intersect(type1, type2); | 1240 Type* intersect12 = T.Intersect(type1, type2); |
| 1588 Type* intersect21 = T.Intersect(type2, type1); | 1241 Type* intersect21 = T.Intersect(type2, type1); |
| 1589 CheckEqual(intersect12, intersect21); | 1242 CheckEqual(intersect12, intersect21); |
| 1590 } | 1243 } |
| 1591 } | 1244 } |
| 1592 | 1245 |
| 1593 // Associativity: | |
| 1594 // Intersect(T1, Intersect(T2, T3)) = Intersect(Intersect(T1, T2), T3) | |
| 1595 // This does NOT hold. For example: | |
| 1596 // (Class(..stringy1..) /\ Class(..stringy2..)) /\ Constant(..string..) = | |
| 1597 // None | |
| 1598 // Class(..stringy1..) /\ (Class(..stringy2..) /\ Constant(..string..)) = | |
| 1599 // Constant(..string..) | |
| 1600 /* | |
| 1601 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { | |
| 1602 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { | |
| 1603 for (TypeIterator it3 = T.types.begin(); it3 != T.types.end(); ++it3) { | |
| 1604 Type* type1 = *it1; | |
| 1605 Type* type2 = *it2; | |
| 1606 Type* type3 = *it3; | |
| 1607 Type* intersect12 = T.Intersect(type1, type2); | |
| 1608 Type* intersect23 = T.Intersect(type2, type3); | |
| 1609 Type* intersect1_23 = T.Intersect(type1, intersect23); | |
| 1610 Type* intersect12_3 = T.Intersect(intersect12, type3); | |
| 1611 CheckEqual(intersect1_23, intersect12_3); | |
| 1612 } | |
| 1613 } | |
| 1614 } | |
| 1615 */ | |
| 1616 | |
| 1617 // Join: Intersect(T1, T2)->Is(T1) and Intersect(T1, T2)->Is(T2) | |
| 1618 // This does NOT hold. For example: | |
| 1619 // Class(..stringy..) /\ Constant(..string..) = Constant(..string..) | |
| 1620 // Currently, not even the disjunction holds: | |
| 1621 // Class(Internal/TaggedPtr) /\ (Any/Untagged \/ Context(..)) = | |
| 1622 // Class(Internal/TaggedPtr) \/ Context(..) | |
| 1623 /* | |
| 1624 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { | |
| 1625 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { | |
| 1626 Type* type1 = *it1; | |
| 1627 Type* type2 = *it2; | |
| 1628 Type* intersect12 = T.Intersect(type1, type2); | |
| 1629 CHECK(intersect12->Is(type1)); | |
| 1630 CHECK(intersect12->Is(type2)); | |
| 1631 } | |
| 1632 } | |
| 1633 */ | |
| 1634 | |
| 1635 // Lower Boundedness: T1->Is(T2) implies Intersect(T1, T2) = T1 | 1246 // Lower Boundedness: T1->Is(T2) implies Intersect(T1, T2) = T1 |
| 1636 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { | 1247 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { |
| 1637 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { | 1248 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { |
| 1638 Type* type1 = *it1; | 1249 Type* type1 = *it1; |
| 1639 Type* type2 = *it2; | 1250 Type* type2 = *it2; |
| 1640 Type* intersect12 = T.Intersect(type1, type2); | 1251 Type* intersect12 = T.Intersect(type1, type2); |
| 1641 if (type1->Is(type2)) CheckEqual(intersect12, type1); | 1252 if (type1->Is(type2)) CheckEqual(intersect12, type1); |
| 1642 } | 1253 } |
| 1643 } | 1254 } |
| 1644 | 1255 |
| 1645 // Monotonicity: T1->Is(T2) implies Intersect(T1, T3)->Is(Intersect(T2, T3)) | |
| 1646 // This does NOT hold. For example: | |
| 1647 // Class(OtherObject/TaggedPtr) <= Any/TaggedPtr | |
| 1648 // Class(OtherObject/TaggedPtr) /\ Any/UntaggedInt1 = Class(..) | |
| 1649 // Any/TaggedPtr /\ Any/UntaggedInt1 = None | |
| 1650 /* | |
| 1651 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { | |
| 1652 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { | |
| 1653 for (TypeIterator it3 = T.types.begin(); it3 != T.types.end(); ++it3) { | |
| 1654 Type* type1 = *it1; | |
| 1655 Type* type2 = *it2; | |
| 1656 Type* type3 = *it3; | |
| 1657 Type* intersect13 = T.Intersect(type1, type3); | |
| 1658 Type* intersect23 = T.Intersect(type2, type3); | |
| 1659 CHECK(!type1->Is(type2) || intersect13->Is(intersect23)); | |
| 1660 } | |
| 1661 } | |
| 1662 } | |
| 1663 */ | |
| 1664 | |
| 1665 // Monotonicity: T1->Is(T3) or T2->Is(T3) implies Intersect(T1, T2)->Is(T3) | |
| 1666 // This does NOT hold. For example: | |
| 1667 // Class(..stringy..) <= Class(..stringy..) | |
| 1668 // Class(..stringy..) /\ Constant(..string..) = Constant(..string..) | |
| 1669 // Constant(..string..) </= Class(..stringy..) | |
| 1670 /* | |
| 1671 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { | |
| 1672 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { | |
| 1673 for (TypeIterator it3 = T.types.begin(); it3 != T.types.end(); ++it3) { | |
| 1674 Type* type1 = *it1; | |
| 1675 Type* type2 = *it2; | |
| 1676 Type* type3 = *it3; | |
| 1677 Type* intersect12 = T.Intersect(type1, type2); | |
| 1678 CHECK(!(type1->Is(type3) || type2->Is(type3)) || | |
| 1679 intersect12->Is(type3)); | |
| 1680 } | |
| 1681 } | |
| 1682 } | |
| 1683 */ | |
| 1684 | |
| 1685 // Monotonicity: T1->Is(T2) and T1->Is(T3) implies T1->Is(Intersect(T2, T3)) | 1256 // Monotonicity: T1->Is(T2) and T1->Is(T3) implies T1->Is(Intersect(T2, T3)) |
| 1686 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { | 1257 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { |
| 1687 HandleScope scope(isolate); | 1258 HandleScope scope(isolate); |
| 1688 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { | 1259 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { |
| 1689 for (TypeIterator it3 = T.types.begin(); it3 != T.types.end(); ++it3) { | 1260 for (TypeIterator it3 = T.types.begin(); it3 != T.types.end(); ++it3) { |
| 1690 Type* type1 = *it1; | 1261 Type* type1 = *it1; |
| 1691 Type* type2 = *it2; | 1262 Type* type2 = *it2; |
| 1692 Type* type3 = *it3; | 1263 Type* type3 = *it3; |
| 1693 Type* intersect23 = T.Intersect(type2, type3); | 1264 Type* intersect23 = T.Intersect(type2, type3); |
| 1694 CHECK(!(type1->Is(type2) && type1->Is(type3)) || | 1265 CHECK(!(type1->Is(type2) && type1->Is(type3)) || |
| 1695 type1->Is(intersect23)); | 1266 type1->Is(intersect23)); |
| 1696 } | 1267 } |
| 1697 } | 1268 } |
| 1698 } | 1269 } |
| 1699 | 1270 |
| 1700 // Bitset-class | |
| 1701 CheckEqual(T.Intersect(T.ObjectClass, T.Object), T.ObjectClass); | |
| 1702 CheckEqual(T.Semantic(T.Intersect(T.ObjectClass, T.Number)), T.None); | |
| 1703 | |
| 1704 // Bitset-array | 1271 // Bitset-array |
| 1705 CheckEqual(T.Intersect(T.NumberArray, T.Object), T.NumberArray); | 1272 CheckEqual(T.Intersect(T.NumberArray, T.Object), T.NumberArray); |
| 1706 CheckEqual(T.Semantic(T.Intersect(T.AnyArray, T.Proxy)), T.None); | 1273 CheckEqual(T.Semantic(T.Intersect(T.AnyArray, T.Proxy)), T.None); |
| 1707 | 1274 |
| 1708 // Bitset-function | 1275 // Bitset-function |
| 1709 CheckEqual(T.Intersect(T.MethodFunction, T.Object), T.MethodFunction); | 1276 CheckEqual(T.Intersect(T.MethodFunction, T.Object), T.MethodFunction); |
| 1710 CheckEqual(T.Semantic(T.Intersect(T.NumberFunction1, T.Proxy)), T.None); | 1277 CheckEqual(T.Semantic(T.Intersect(T.NumberFunction1, T.Proxy)), T.None); |
| 1711 | 1278 |
| 1712 // Bitset-union | |
| 1713 CheckEqual( | |
| 1714 T.Intersect(T.Object, T.Union(T.ObjectConstant1, T.ObjectClass)), | |
| 1715 T.Union(T.ObjectConstant1, T.ObjectClass)); | |
| 1716 CheckEqual(T.Semantic(T.Intersect(T.Union(T.ArrayClass, T.ObjectConstant1), | |
| 1717 T.Number)), | |
| 1718 T.None); | |
| 1719 | |
| 1720 // Class-constant | |
| 1721 CHECK(T.Intersect(T.ObjectConstant1, T.ObjectClass)->IsInhabited()); // !!! | |
| 1722 CHECK(T.Intersect(T.ArrayClass, T.ObjectConstant2)->IsInhabited()); | |
| 1723 | |
| 1724 // Array-union | 1279 // Array-union |
| 1725 CheckEqual( | 1280 CheckEqual( |
| 1726 T.Intersect(T.NumberArray, T.Union(T.NumberArray, T.ArrayClass)), | |
| 1727 T.NumberArray); | |
| 1728 CheckEqual( | |
| 1729 T.Intersect(T.AnyArray, T.Union(T.Object, T.SmiConstant)), | 1281 T.Intersect(T.AnyArray, T.Union(T.Object, T.SmiConstant)), |
| 1730 T.AnyArray); | 1282 T.AnyArray); |
| 1731 CHECK( | 1283 CHECK( |
| 1732 !T.Intersect(T.Union(T.AnyArray, T.ArrayConstant), T.NumberArray) | 1284 !T.Intersect(T.Union(T.AnyArray, T.ArrayConstant), T.NumberArray) |
| 1733 ->IsInhabited()); | 1285 ->IsInhabited()); |
| 1734 | 1286 |
| 1735 // Function-union | 1287 // Function-union |
| 1736 CheckEqual( | 1288 CheckEqual( |
| 1737 T.Intersect(T.MethodFunction, T.Union(T.String, T.MethodFunction)), | 1289 T.Intersect(T.MethodFunction, T.Union(T.String, T.MethodFunction)), |
| 1738 T.MethodFunction); | 1290 T.MethodFunction); |
| 1739 CheckEqual( | 1291 CheckEqual( |
| 1740 T.Intersect(T.NumberFunction1, T.Union(T.Object, T.SmiConstant)), | 1292 T.Intersect(T.NumberFunction1, T.Union(T.Object, T.SmiConstant)), |
| 1741 T.NumberFunction1); | 1293 T.NumberFunction1); |
| 1742 CHECK( | 1294 CHECK( |
| 1743 !T.Intersect(T.Union(T.MethodFunction, T.Name), T.NumberFunction2) | 1295 !T.Intersect(T.Union(T.MethodFunction, T.Name), T.NumberFunction2) |
| 1744 ->IsInhabited()); | 1296 ->IsInhabited()); |
| 1745 | 1297 |
| 1746 // Class-union | |
| 1747 CheckEqual( | |
| 1748 T.Intersect(T.ArrayClass, T.Union(T.ObjectConstant2, T.ArrayClass)), | |
| 1749 T.ArrayClass); | |
| 1750 CheckEqual( | |
| 1751 T.Intersect(T.ArrayClass, T.Union(T.Object, T.SmiConstant)), | |
| 1752 T.ArrayClass); | |
| 1753 CHECK( | |
| 1754 T.Intersect(T.Union(T.ObjectClass, T.ArrayConstant), T.ArrayClass) | |
| 1755 ->IsInhabited()); // !!! | |
| 1756 | |
| 1757 // Constant-union | 1298 // Constant-union |
| 1758 CheckEqual( | 1299 CheckEqual( |
| 1759 T.Intersect( | 1300 T.Intersect( |
| 1760 T.ObjectConstant1, T.Union(T.ObjectConstant1, T.ObjectConstant2)), | 1301 T.ObjectConstant1, T.Union(T.ObjectConstant1, T.ObjectConstant2)), |
| 1761 T.ObjectConstant1); | 1302 T.ObjectConstant1); |
| 1762 CheckEqual( | 1303 CheckEqual( |
| 1763 T.Intersect(T.SmiConstant, T.Union(T.Number, T.ObjectConstant2)), | 1304 T.Intersect(T.SmiConstant, T.Union(T.Number, T.ObjectConstant2)), |
| 1764 T.SmiConstant); | 1305 T.SmiConstant); |
| 1765 CHECK( | |
| 1766 T.Intersect( | |
| 1767 T.Union(T.ArrayConstant, T.ObjectClass), T.ObjectConstant1) | |
| 1768 ->IsInhabited()); // !!! | |
| 1769 | 1306 |
| 1770 // Union-union | 1307 // Union-union |
| 1771 CheckEqual(T.Intersect(T.Union(T.Number, T.ArrayClass), | |
| 1772 T.Union(T.SignedSmall, T.Receiver)), | |
| 1773 T.Union(T.SignedSmall, T.ArrayClass)); | |
| 1774 CheckEqual(T.Intersect(T.Union(T.Number, T.ObjectClass), | |
| 1775 T.Union(T.Signed32, T.OtherObject)), | |
| 1776 T.Union(T.Signed32, T.ObjectClass)); | |
| 1777 CheckEqual( | 1308 CheckEqual( |
| 1778 T.Intersect( | 1309 T.Intersect( |
| 1779 T.Union(T.ObjectConstant2, T.ObjectConstant1), | 1310 T.Union(T.ObjectConstant2, T.ObjectConstant1), |
| 1780 T.Union(T.ObjectConstant1, T.ObjectConstant2)), | 1311 T.Union(T.ObjectConstant1, T.ObjectConstant2)), |
| 1781 T.Union(T.ObjectConstant2, T.ObjectConstant1)); | 1312 T.Union(T.ObjectConstant2, T.ObjectConstant1)); |
| 1782 CheckEqual( | |
| 1783 T.Intersect( | |
| 1784 T.Union( | |
| 1785 T.ArrayClass, | |
| 1786 T.Union(T.ObjectConstant2, T.ObjectConstant1)), | |
| 1787 T.Union( | |
| 1788 T.ObjectConstant1, | |
| 1789 T.Union(T.ArrayConstant, T.ObjectConstant2))), | |
| 1790 T.Union( | |
| 1791 T.ArrayConstant, | |
| 1792 T.Union(T.ObjectConstant2, T.ObjectConstant1))); // !!! | |
| 1793 } | 1313 } |
| 1794 | 1314 |
| 1795 void Distributivity() { | 1315 void Distributivity() { |
| 1796 // Union(T1, Intersect(T2, T3)) = Intersect(Union(T1, T2), Union(T1, T3)) | 1316 // Union(T1, Intersect(T2, T3)) = Intersect(Union(T1, T2), Union(T1, T3)) |
| 1797 // This does NOT hold. For example: | 1317 // This does NOT hold. For example: |
| 1798 // Untagged \/ (Untagged /\ Class(../Tagged)) = Untagged \/ Class(../Tagged) | 1318 // Untagged \/ (Untagged /\ Class(../Tagged)) = Untagged \/ Class(../Tagged) |
| 1799 // (Untagged \/ Untagged) /\ (Untagged \/ Class(../Tagged)) = | 1319 // (Untagged \/ Untagged) /\ (Untagged \/ Class(../Tagged)) = |
| 1800 // Untagged /\ (Untagged \/ Class(../Tagged)) = Untagged | 1320 // Untagged /\ (Untagged \/ Class(../Tagged)) = Untagged |
| 1801 // because Untagged <= Untagged \/ Class(../Tagged) | 1321 // because Untagged <= Untagged \/ Class(../Tagged) |
| 1802 /* | 1322 /* |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1861 Type* u = T.Union(type1, type2); | 1381 Type* u = T.Union(type1, type2); |
| 1862 | 1382 |
| 1863 CHECK(type2->Min() == u->GetRange()->Min()); | 1383 CHECK(type2->Min() == u->GetRange()->Min()); |
| 1864 CHECK(type2->Max() == u->GetRange()->Max()); | 1384 CHECK(type2->Max() == u->GetRange()->Max()); |
| 1865 } | 1385 } |
| 1866 } | 1386 } |
| 1867 } | 1387 } |
| 1868 } | 1388 } |
| 1869 }; | 1389 }; |
| 1870 | 1390 |
| 1871 TEST(IsSomeType_zone) { Tests().IsSomeType(); } | 1391 } // namespace |
| 1872 | 1392 |
| 1873 TEST(PointwiseRepresentation_zone) { Tests().PointwiseRepresentation(); } | 1393 TEST(IsSomeType) { Tests().IsSomeType(); } |
| 1874 | 1394 |
| 1875 TEST(BitsetType_zone) { Tests().Bitset(); } | 1395 TEST(PointwiseRepresentation) { Tests().PointwiseRepresentation(); } |
| 1876 | 1396 |
| 1877 TEST(ClassType_zone) { Tests().Class(); } | 1397 TEST(BitsetType) { Tests().Bitset(); } |
| 1878 | 1398 |
| 1879 TEST(ConstantType_zone) { Tests().Constant(); } | 1399 TEST(ConstantType) { Tests().Constant(); } |
| 1880 | 1400 |
| 1881 TEST(RangeType_zone) { Tests().Range(); } | 1401 TEST(RangeType) { Tests().Range(); } |
| 1882 | 1402 |
| 1883 TEST(ArrayType_zone) { Tests().Array(); } | 1403 TEST(ArrayType) { Tests().Array(); } |
| 1884 | 1404 |
| 1885 TEST(FunctionType_zone) { Tests().Function(); } | 1405 TEST(FunctionType) { Tests().Function(); } |
| 1886 | 1406 |
| 1887 TEST(Of_zone) { Tests().Of(); } | 1407 TEST(Of) { Tests().Of(); } |
| 1888 | 1408 |
| 1889 TEST(NowOf_zone) { Tests().NowOf(); } | 1409 TEST(MinMax) { Tests().MinMax(); } |
| 1890 | 1410 |
| 1891 TEST(MinMax_zone) { Tests().MinMax(); } | 1411 TEST(BitsetGlb) { Tests().BitsetGlb(); } |
| 1892 | 1412 |
| 1893 TEST(BitsetGlb_zone) { Tests().BitsetGlb(); } | 1413 TEST(BitsetLub) { Tests().BitsetLub(); } |
| 1894 | 1414 |
| 1895 TEST(BitsetLub_zone) { Tests().BitsetLub(); } | 1415 TEST(Is1) { Tests().Is1(); } |
| 1896 | 1416 |
| 1897 TEST(Is1_zone) { Tests().Is1(); } | 1417 TEST(Is2) { Tests().Is2(); } |
| 1898 | 1418 |
| 1899 TEST(Is2_zone) { Tests().Is2(); } | 1419 TEST(Contains) { Tests().Contains(); } |
| 1900 | 1420 |
| 1901 TEST(NowIs_zone) { Tests().NowIs(); } | 1421 TEST(Maybe) { Tests().Maybe(); } |
| 1902 | 1422 |
| 1903 TEST(Contains_zone) { Tests().Contains(); } | 1423 TEST(Union1) { Tests().Union1(); } |
| 1904 | 1424 |
| 1905 TEST(NowContains_zone) { Tests().NowContains(); } | 1425 TEST(Union2) { Tests().Union2(); } |
| 1906 | 1426 |
| 1907 TEST(Maybe_zone) { Tests().Maybe(); } | 1427 TEST(Union3) { Tests().Union3(); } |
| 1908 | 1428 |
| 1909 TEST(Union1_zone) { Tests().Union1(); } | 1429 TEST(Union4) { Tests().Union4(); } |
| 1910 | 1430 |
| 1911 TEST(Union2_zone) { Tests().Union2(); } | 1431 TEST(Intersect) { Tests().Intersect(); } |
| 1912 | 1432 |
| 1913 TEST(Union3_zone) { Tests().Union3(); } | 1433 TEST(Distributivity) { Tests().Distributivity(); } |
| 1914 | 1434 |
| 1915 TEST(Union4_zone) { Tests().Union4(); } | 1435 TEST(GetRange) { Tests().GetRange(); } |
| 1916 | |
| 1917 TEST(Intersect_zone) { Tests().Intersect(); } | |
| 1918 | |
| 1919 TEST(Distributivity_zone) { Tests().Distributivity(); } | |
| 1920 | |
| 1921 TEST(GetRange_zone) { Tests().GetRange(); } | |
| OLD | NEW |