Chromium Code Reviews| 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/hydrogen-types.h" | 7 #include "src/hydrogen-types.h" |
| 8 #include "src/isolate-inl.h" | 8 #include "src/isolate-inl.h" |
| 9 #include "src/types.h" | 9 #include "src/types.h" |
| 10 #include "test/cctest/cctest.h" | 10 #include "test/cctest/cctest.h" |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 33 static int Length(Struct* structured) { | 33 static int Length(Struct* structured) { |
| 34 return static_cast<int>(reinterpret_cast<intptr_t>(structured[1])); | 34 return static_cast<int>(reinterpret_cast<intptr_t>(structured[1])); |
| 35 } | 35 } |
| 36 | 36 |
| 37 static Zone* ToRegion(Zone* zone, Isolate* isolate) { return zone; } | 37 static Zone* ToRegion(Zone* zone, Isolate* isolate) { return zone; } |
| 38 | 38 |
| 39 struct BitsetType : Type::BitsetType { | 39 struct BitsetType : Type::BitsetType { |
| 40 using Type::BitsetType::New; | 40 using Type::BitsetType::New; |
| 41 using Type::BitsetType::Glb; | 41 using Type::BitsetType::Glb; |
| 42 using Type::BitsetType::Lub; | 42 using Type::BitsetType::Lub; |
| 43 using Type::BitsetType::InherentLub; | 43 using Type::BitsetType::IsInhabited; |
| 44 }; | 44 }; |
| 45 }; | 45 }; |
| 46 | 46 |
| 47 | 47 |
| 48 struct HeapRep { | 48 struct HeapRep { |
| 49 typedef FixedArray Struct; | 49 typedef FixedArray Struct; |
| 50 | 50 |
| 51 static bool IsStruct(Handle<HeapType> t, int tag) { | 51 static bool IsStruct(Handle<HeapType> t, int tag) { |
| 52 return t->IsFixedArray() && Smi::cast(AsStruct(t)->get(0))->value() == tag; | 52 return t->IsFixedArray() && Smi::cast(AsStruct(t)->get(0))->value() == tag; |
| 53 } | 53 } |
| 54 static bool IsBitset(Handle<HeapType> t) { return t->IsSmi(); } | 54 static bool IsBitset(Handle<HeapType> t) { return t->IsSmi(); } |
| 55 static bool IsUnion(Handle<HeapType> t) { return IsStruct(t, 6); } | 55 static bool IsUnion(Handle<HeapType> t) { return IsStruct(t, 6); } |
| 56 | 56 |
| 57 static Struct* AsStruct(Handle<HeapType> t) { return FixedArray::cast(*t); } | 57 static Struct* AsStruct(Handle<HeapType> t) { return FixedArray::cast(*t); } |
| 58 static int AsBitset(Handle<HeapType> t) { return Smi::cast(*t)->value(); } | 58 static int AsBitset(Handle<HeapType> t) { return Smi::cast(*t)->value(); } |
| 59 static Struct* AsUnion(Handle<HeapType> t) { return AsStruct(t); } | 59 static Struct* AsUnion(Handle<HeapType> t) { return AsStruct(t); } |
| 60 static int Length(Struct* structured) { return structured->length() - 1; } | 60 static int Length(Struct* structured) { return structured->length() - 1; } |
| 61 | 61 |
| 62 static Isolate* ToRegion(Zone* zone, Isolate* isolate) { return isolate; } | 62 static Isolate* ToRegion(Zone* zone, Isolate* isolate) { return isolate; } |
| 63 | 63 |
| 64 struct BitsetType : HeapType::BitsetType { | 64 struct BitsetType : HeapType::BitsetType { |
| 65 using HeapType::BitsetType::New; | 65 using HeapType::BitsetType::New; |
| 66 using HeapType::BitsetType::Glb; | 66 using HeapType::BitsetType::Glb; |
| 67 using HeapType::BitsetType::Lub; | 67 using HeapType::BitsetType::Lub; |
| 68 using HeapType::BitsetType::InherentLub; | 68 using HeapType::BitsetType::IsInhabited; |
| 69 static int Glb(Handle<HeapType> type) { return Glb(*type); } | 69 static int Glb(Handle<HeapType> type) { return Glb(*type); } |
| 70 static int Lub(Handle<HeapType> type) { return Lub(*type); } | 70 static int Lub(Handle<HeapType> type) { return Lub(*type); } |
| 71 static int InherentLub(Handle<HeapType> type) { return InherentLub(*type); } | |
| 72 }; | 71 }; |
| 73 }; | 72 }; |
| 74 | 73 |
| 75 | 74 |
| 76 template<class Type, class TypeHandle, class Region> | 75 template<class Type, class TypeHandle, class Region> |
| 77 class Types { | 76 class Types { |
| 78 public: | 77 public: |
| 79 Types(Region* region, Isolate* isolate) | 78 Types(Region* region, Isolate* isolate) |
| 80 : region_(region), rng_(isolate->random_number_generator()) { | 79 : region_(region), rng_(isolate->random_number_generator()) { |
| 81 #define DECLARE_TYPE(name, value) \ | 80 #define DECLARE_TYPE(name, value) \ |
| 82 name = Type::name(region); \ | 81 name = Type::name(region); \ |
| 83 types.push_back(name); | 82 types.push_back(name); |
| 84 BITSET_TYPE_LIST(DECLARE_TYPE) | 83 PROPER_BITSET_TYPE_LIST(DECLARE_TYPE) |
| 85 #undef DECLARE_TYPE | 84 #undef DECLARE_TYPE |
| 86 | 85 |
| 87 object_map = isolate->factory()->NewMap(JS_OBJECT_TYPE, 3 * kPointerSize); | 86 object_map = isolate->factory()->NewMap( |
| 88 array_map = isolate->factory()->NewMap(JS_ARRAY_TYPE, 4 * kPointerSize); | 87 JS_OBJECT_TYPE, JSObject::kHeaderSize); |
| 88 array_map = isolate->factory()->NewMap( | |
| 89 JS_ARRAY_TYPE, JSArray::kSize); | |
| 90 number_map = isolate->factory()->NewMap( | |
| 91 HEAP_NUMBER_TYPE, HeapNumber::kSize); | |
| 89 uninitialized_map = isolate->factory()->uninitialized_map(); | 92 uninitialized_map = isolate->factory()->uninitialized_map(); |
| 90 ObjectClass = Type::Class(object_map, region); | 93 ObjectClass = Type::Class(object_map, region); |
| 91 ArrayClass = Type::Class(array_map, region); | 94 ArrayClass = Type::Class(array_map, region); |
| 95 NumberClass = Type::Class(number_map, region); | |
| 92 UninitializedClass = Type::Class(uninitialized_map, region); | 96 UninitializedClass = Type::Class(uninitialized_map, region); |
| 93 | 97 |
| 94 maps.push_back(object_map); | 98 maps.push_back(object_map); |
| 95 maps.push_back(array_map); | 99 maps.push_back(array_map); |
| 96 maps.push_back(uninitialized_map); | 100 maps.push_back(uninitialized_map); |
| 97 for (MapVector::iterator it = maps.begin(); it != maps.end(); ++it) { | 101 for (MapVector::iterator it = maps.begin(); it != maps.end(); ++it) { |
| 98 types.push_back(Type::Class(*it, region)); | 102 types.push_back(Type::Class(*it, region)); |
| 99 } | 103 } |
| 100 | 104 |
| 101 smi = handle(Smi::FromInt(666), isolate); | 105 smi = handle(Smi::FromInt(666), isolate); |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 114 values.push_back(smi); | 118 values.push_back(smi); |
| 115 values.push_back(signed32); | 119 values.push_back(signed32); |
| 116 values.push_back(object1); | 120 values.push_back(object1); |
| 117 values.push_back(object2); | 121 values.push_back(object2); |
| 118 values.push_back(array); | 122 values.push_back(array); |
| 119 values.push_back(uninitialized); | 123 values.push_back(uninitialized); |
| 120 for (ValueVector::iterator it = values.begin(); it != values.end(); ++it) { | 124 for (ValueVector::iterator it = values.begin(); it != values.end(); ++it) { |
| 121 types.push_back(Type::Constant(*it, region)); | 125 types.push_back(Type::Constant(*it, region)); |
| 122 } | 126 } |
| 123 | 127 |
| 124 doubles.push_back(-0.0); | 128 integers.push_back(isolate->factory()->NewNumber(-V8_INFINITY)); |
| 125 doubles.push_back(+0.0); | 129 integers.push_back(isolate->factory()->NewNumber(+V8_INFINITY)); |
| 126 doubles.push_back(-std::numeric_limits<double>::infinity()); | 130 integers.push_back(isolate->factory()->NewNumber(-rng_->NextInt(10))); |
| 127 doubles.push_back(+std::numeric_limits<double>::infinity()); | 131 integers.push_back(isolate->factory()->NewNumber(+rng_->NextInt(10))); |
| 128 for (int i = 0; i < 10; ++i) { | 132 for (int i = 0; i < 10; ++i) { |
| 129 doubles.push_back(rng_->NextInt()); | 133 double x = rng_->NextInt(); |
| 130 doubles.push_back(rng_->NextDouble() * rng_->NextInt()); | 134 integers.push_back(isolate->factory()->NewNumber(x)); |
| 135 x *= rng_->NextInt(); | |
| 136 if (!IsMinusZero(x)) integers.push_back(isolate->factory()->NewNumber(x)); | |
| 131 } | 137 } |
| 132 | 138 |
| 133 NumberArray = Type::Array(Number, region); | 139 NumberArray = Type::Array(Number, region); |
| 134 StringArray = Type::Array(String, region); | 140 StringArray = Type::Array(String, region); |
| 135 AnyArray = Type::Array(Any, region); | 141 AnyArray = Type::Array(Any, region); |
| 136 | 142 |
| 137 SignedFunction1 = Type::Function(SignedSmall, SignedSmall, region); | 143 SignedFunction1 = Type::Function(SignedSmall, SignedSmall, region); |
| 138 NumberFunction1 = Type::Function(Number, Number, region); | 144 NumberFunction1 = Type::Function(Number, Number, region); |
| 139 NumberFunction2 = Type::Function(Number, Number, Number, region); | 145 NumberFunction2 = Type::Function(Number, Number, Number, region); |
| 140 MethodFunction = Type::Function(String, Object, 0, region); | 146 MethodFunction = Type::Function(String, Object, 0, region); |
| 141 | 147 |
| 142 for (int i = 0; i < 30; ++i) { | 148 for (int i = 0; i < 30; ++i) { |
| 143 types.push_back(Fuzz()); | 149 types.push_back(Fuzz()); |
| 144 } | 150 } |
| 145 } | 151 } |
| 146 | 152 |
| 147 Handle<i::Map> object_map; | 153 Handle<i::Map> object_map; |
| 148 Handle<i::Map> array_map; | 154 Handle<i::Map> array_map; |
| 155 Handle<i::Map> number_map; | |
| 149 Handle<i::Map> uninitialized_map; | 156 Handle<i::Map> uninitialized_map; |
| 150 | 157 |
| 151 Handle<i::Smi> smi; | 158 Handle<i::Smi> smi; |
| 152 Handle<i::HeapNumber> signed32; | 159 Handle<i::HeapNumber> signed32; |
| 153 Handle<i::JSObject> object1; | 160 Handle<i::JSObject> object1; |
| 154 Handle<i::JSObject> object2; | 161 Handle<i::JSObject> object2; |
| 155 Handle<i::JSArray> array; | 162 Handle<i::JSArray> array; |
| 156 Handle<i::Oddball> uninitialized; | 163 Handle<i::Oddball> uninitialized; |
| 157 | 164 |
| 158 #define DECLARE_TYPE(name, value) TypeHandle name; | 165 #define DECLARE_TYPE(name, value) TypeHandle name; |
| 159 BITSET_TYPE_LIST(DECLARE_TYPE) | 166 BITSET_TYPE_LIST(DECLARE_TYPE) |
| 160 #undef DECLARE_TYPE | 167 #undef DECLARE_TYPE |
| 161 | 168 |
| 162 TypeHandle ObjectClass; | 169 TypeHandle ObjectClass; |
| 163 TypeHandle ArrayClass; | 170 TypeHandle ArrayClass; |
| 171 TypeHandle NumberClass; | |
| 164 TypeHandle UninitializedClass; | 172 TypeHandle UninitializedClass; |
| 165 | 173 |
| 166 TypeHandle SmiConstant; | 174 TypeHandle SmiConstant; |
| 167 TypeHandle Signed32Constant; | 175 TypeHandle Signed32Constant; |
| 168 TypeHandle ObjectConstant1; | 176 TypeHandle ObjectConstant1; |
| 169 TypeHandle ObjectConstant2; | 177 TypeHandle ObjectConstant2; |
| 170 TypeHandle ArrayConstant; | 178 TypeHandle ArrayConstant; |
| 171 TypeHandle UninitializedConstant; | 179 TypeHandle UninitializedConstant; |
| 172 | 180 |
| 173 TypeHandle NumberArray; | 181 TypeHandle NumberArray; |
| 174 TypeHandle StringArray; | 182 TypeHandle StringArray; |
| 175 TypeHandle AnyArray; | 183 TypeHandle AnyArray; |
| 176 | 184 |
| 177 TypeHandle SignedFunction1; | 185 TypeHandle SignedFunction1; |
| 178 TypeHandle NumberFunction1; | 186 TypeHandle NumberFunction1; |
| 179 TypeHandle NumberFunction2; | 187 TypeHandle NumberFunction2; |
| 180 TypeHandle MethodFunction; | 188 TypeHandle MethodFunction; |
| 181 | 189 |
| 182 typedef std::vector<TypeHandle> TypeVector; | 190 typedef std::vector<TypeHandle> TypeVector; |
| 183 typedef std::vector<Handle<i::Map> > MapVector; | 191 typedef std::vector<Handle<i::Map> > MapVector; |
| 184 typedef std::vector<Handle<i::Object> > ValueVector; | 192 typedef std::vector<Handle<i::Object> > ValueVector; |
| 185 typedef std::vector<double> DoubleVector; | |
| 186 | 193 |
| 187 TypeVector types; | 194 TypeVector types; |
| 188 MapVector maps; | 195 MapVector maps; |
| 189 ValueVector values; | 196 ValueVector values; |
| 190 DoubleVector doubles; // Some floating-point values, excluding NaN. | 197 ValueVector integers; // "Integer" values used for range limits. |
| 191 | |
| 192 // Range type helper functions, partially copied from types.cc. | |
| 193 // Note: dle(dmin(x,y), dmax(x,y)) holds iff neither x nor y is NaN. | |
| 194 bool dle(double x, double y) { | |
| 195 return x <= y && (x != 0 || IsMinusZero(x) || !IsMinusZero(y)); | |
| 196 } | |
| 197 bool deq(double x, double y) { | |
| 198 return dle(x, y) && dle(y, x); | |
| 199 } | |
| 200 double dmin(double x, double y) { | |
| 201 return dle(x, y) ? x : y; | |
| 202 } | |
| 203 double dmax(double x, double y) { | |
| 204 return dle(x, y) ? y : x; | |
| 205 } | |
| 206 | 198 |
| 207 TypeHandle Of(Handle<i::Object> value) { | 199 TypeHandle Of(Handle<i::Object> value) { |
| 208 return Type::Of(value, region_); | 200 return Type::Of(value, region_); |
| 209 } | 201 } |
| 210 | 202 |
| 211 TypeHandle NowOf(Handle<i::Object> value) { | 203 TypeHandle NowOf(Handle<i::Object> value) { |
| 212 return Type::NowOf(value, region_); | 204 return Type::NowOf(value, region_); |
| 213 } | 205 } |
| 214 | 206 |
| 207 TypeHandle Class(Handle<i::Map> map) { | |
| 208 return Type::Class(map, region_); | |
| 209 } | |
| 210 | |
| 215 TypeHandle Constant(Handle<i::Object> value) { | 211 TypeHandle Constant(Handle<i::Object> value) { |
| 216 return Type::Constant(value, region_); | 212 return Type::Constant(value, region_); |
| 217 } | 213 } |
| 218 | 214 |
| 219 TypeHandle Range(double min, double max) { | 215 TypeHandle Range(Handle<i::Object> min, Handle<i::Object> max) { |
| 220 return Type::Range(min, max, region_); | 216 return Type::Range(min, max, region_); |
| 221 } | 217 } |
| 222 | 218 |
| 223 TypeHandle Class(Handle<i::Map> map) { | 219 TypeHandle Context(TypeHandle outer) { |
| 224 return Type::Class(map, region_); | 220 return Type::Context(outer, region_); |
| 225 } | 221 } |
| 226 | 222 |
| 227 TypeHandle Array1(TypeHandle element) { | 223 TypeHandle Array1(TypeHandle element) { |
| 228 return Type::Array(element, region_); | 224 return Type::Array(element, region_); |
| 229 } | 225 } |
| 230 | 226 |
| 231 TypeHandle Function0(TypeHandle result, TypeHandle receiver) { | 227 TypeHandle Function0(TypeHandle result, TypeHandle receiver) { |
| 232 return Type::Function(result, receiver, 0, region_); | 228 return Type::Function(result, receiver, 0, region_); |
| 233 } | 229 } |
| 234 | 230 |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 251 | 247 |
| 252 template<class Type2, class TypeHandle2> | 248 template<class Type2, class TypeHandle2> |
| 253 TypeHandle Convert(TypeHandle2 t) { | 249 TypeHandle Convert(TypeHandle2 t) { |
| 254 return Type::template Convert<Type2>(t, region_); | 250 return Type::template Convert<Type2>(t, region_); |
| 255 } | 251 } |
| 256 | 252 |
| 257 TypeHandle Random() { | 253 TypeHandle Random() { |
| 258 return types[rng_->NextInt(static_cast<int>(types.size()))]; | 254 return types[rng_->NextInt(static_cast<int>(types.size()))]; |
| 259 } | 255 } |
| 260 | 256 |
| 261 TypeHandle Fuzz(int depth = 5) { | 257 TypeHandle Fuzz(int depth = 4) { |
| 262 switch (rng_->NextInt(depth == 0 ? 3 : 20)) { | 258 switch (rng_->NextInt(depth == 0 ? 3 : 20)) { |
| 263 case 0: { // bitset | 259 case 0: { // bitset |
| 264 int n = 0 | 260 int n = 0 |
| 265 #define COUNT_BITSET_TYPES(type, value) + 1 | 261 #define COUNT_BITSET_TYPES(type, value) + 1 |
| 266 BITSET_TYPE_LIST(COUNT_BITSET_TYPES) | 262 PROPER_BITSET_TYPE_LIST(COUNT_BITSET_TYPES) |
| 267 #undef COUNT_BITSET_TYPES | 263 #undef COUNT_BITSET_TYPES |
| 268 ; | 264 ; |
| 269 int i = rng_->NextInt(n); | 265 int i = rng_->NextInt(n); |
| 270 #define PICK_BITSET_TYPE(type, value) \ | 266 #define PICK_BITSET_TYPE(type, value) \ |
| 271 if (i-- == 0) return Type::type(region_); | 267 if (i-- == 0) return Type::type(region_); |
| 272 BITSET_TYPE_LIST(PICK_BITSET_TYPE) | 268 PROPER_BITSET_TYPE_LIST(PICK_BITSET_TYPE) |
| 273 #undef PICK_BITSET_TYPE | 269 #undef PICK_BITSET_TYPE |
| 274 UNREACHABLE(); | 270 UNREACHABLE(); |
| 275 } | 271 } |
| 276 case 1: { // class | 272 case 1: { // class |
| 277 int i = rng_->NextInt(static_cast<int>(maps.size())); | 273 int i = rng_->NextInt(static_cast<int>(maps.size())); |
| 278 return Type::Class(maps[i], region_); | 274 return Type::Class(maps[i], region_); |
| 279 } | 275 } |
| 280 case 2: { // constant | 276 case 2: { // constant |
| 281 int i = rng_->NextInt(static_cast<int>(values.size())); | 277 int i = rng_->NextInt(static_cast<int>(values.size())); |
| 282 return Type::Constant(values[i], region_); | 278 return Type::Constant(values[i], region_); |
| 283 } | 279 } |
| 284 case 3: { // context | 280 case 3: { // range |
| 281 int i = rng_->NextInt(static_cast<int>(integers.size())); | |
| 282 int j = rng_->NextInt(static_cast<int>(integers.size())); | |
| 283 i::Handle<i::Object> min = integers[i]; | |
| 284 i::Handle<i::Object> max = integers[j]; | |
| 285 if (min->Number() > max->Number()) std::swap(min, max); | |
| 286 return Type::Range(min, max, region_); | |
| 287 } | |
| 288 case 4: { // context | |
| 285 int depth = rng_->NextInt(3); | 289 int depth = rng_->NextInt(3); |
| 286 TypeHandle type = Type::Internal(region_); | 290 TypeHandle type = Type::Internal(region_); |
| 287 for (int i = 0; i < depth; ++i) type = Type::Context(type, region_); | 291 for (int i = 0; i < depth; ++i) type = Type::Context(type, region_); |
| 288 return type; | 292 return type; |
| 289 } | 293 } |
| 290 case 4: { // array | 294 case 5: { // array |
| 291 TypeHandle element = Fuzz(depth / 2); | 295 TypeHandle element = Fuzz(depth / 2); |
| 292 return Type::Array(element, region_); | 296 return Type::Array(element, region_); |
| 293 } | 297 } |
| 294 case 5: | 298 case 6: |
| 295 case 6: { // function | 299 case 7: { // function |
| 296 TypeHandle result = Fuzz(depth / 2); | 300 TypeHandle result = Fuzz(depth / 2); |
| 297 TypeHandle receiver = Fuzz(depth / 2); | 301 TypeHandle receiver = Fuzz(depth / 2); |
| 298 int arity = rng_->NextInt(3); | 302 int arity = rng_->NextInt(3); |
| 299 TypeHandle type = Type::Function(result, receiver, arity, region_); | 303 TypeHandle type = Type::Function(result, receiver, arity, region_); |
| 300 for (int i = 0; i < type->AsFunction()->Arity(); ++i) { | 304 for (int i = 0; i < type->AsFunction()->Arity(); ++i) { |
| 301 TypeHandle parameter = Fuzz(depth / 2); | 305 TypeHandle parameter = Fuzz(depth / 2); |
| 302 type->AsFunction()->InitParameter(i, parameter); | 306 type->AsFunction()->InitParameter(i, parameter); |
| 303 } | 307 } |
| 304 return type; | 308 return type; |
| 305 } | 309 } |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 323 v8::base::RandomNumberGenerator* rng_; | 327 v8::base::RandomNumberGenerator* rng_; |
| 324 }; | 328 }; |
| 325 | 329 |
| 326 | 330 |
| 327 template<class Type, class TypeHandle, class Region, class Rep> | 331 template<class Type, class TypeHandle, class Region, class Rep> |
| 328 struct Tests : Rep { | 332 struct Tests : Rep { |
| 329 typedef Types<Type, TypeHandle, Region> TypesInstance; | 333 typedef Types<Type, TypeHandle, Region> TypesInstance; |
| 330 typedef typename TypesInstance::TypeVector::iterator TypeIterator; | 334 typedef typename TypesInstance::TypeVector::iterator TypeIterator; |
| 331 typedef typename TypesInstance::MapVector::iterator MapIterator; | 335 typedef typename TypesInstance::MapVector::iterator MapIterator; |
| 332 typedef typename TypesInstance::ValueVector::iterator ValueIterator; | 336 typedef typename TypesInstance::ValueVector::iterator ValueIterator; |
| 333 typedef typename TypesInstance::DoubleVector::iterator DoubleIterator; | |
| 334 | 337 |
| 335 Isolate* isolate; | 338 Isolate* isolate; |
| 336 HandleScope scope; | 339 HandleScope scope; |
| 337 Zone zone; | 340 Zone zone; |
| 338 TypesInstance T; | 341 TypesInstance T; |
| 339 | 342 |
| 340 Tests() : | 343 Tests() : |
| 341 isolate(CcTest::i_isolate()), | 344 isolate(CcTest::i_isolate()), |
| 342 scope(isolate), | 345 scope(isolate), |
| 343 zone(isolate), | 346 zone(isolate), |
| 344 T(Rep::ToRegion(&zone, isolate), isolate) { | 347 T(Rep::ToRegion(&zone, isolate), isolate) { |
| 345 } | 348 } |
| 346 | 349 |
| 347 bool Equal(TypeHandle type1, TypeHandle type2) { | 350 bool Equal(TypeHandle type1, TypeHandle type2) { |
| 348 return | 351 return |
| 349 type1->Equals(type2) && | 352 type1->Equals(type2) && |
| 350 Rep::IsBitset(type1) == Rep::IsBitset(type2) && | 353 this->IsBitset(type1) == this->IsBitset(type2) && |
| 351 Rep::IsUnion(type1) == Rep::IsUnion(type2) && | 354 this->IsUnion(type1) == this->IsUnion(type2) && |
| 352 type1->NumClasses() == type2->NumClasses() && | 355 type1->NumClasses() == type2->NumClasses() && |
| 353 type1->NumConstants() == type2->NumConstants() && | 356 type1->NumConstants() == type2->NumConstants() && |
| 354 (!Rep::IsBitset(type1) || | 357 (!this->IsBitset(type1) || |
| 355 Rep::AsBitset(type1) == Rep::AsBitset(type2)) && | 358 this->AsBitset(type1) == this->AsBitset(type2)) && |
| 356 (!Rep::IsUnion(type1) || | 359 (!this->IsUnion(type1) || |
| 357 Rep::Length(Rep::AsUnion(type1)) == Rep::Length(Rep::AsUnion(type2))); | 360 this->Length(this->AsUnion(type1)) == |
| 361 this->Length(this->AsUnion(type2))); | |
| 358 } | 362 } |
| 359 | 363 |
| 360 void CheckEqual(TypeHandle type1, TypeHandle type2) { | 364 void CheckEqual(TypeHandle type1, TypeHandle type2) { |
| 361 CHECK(Equal(type1, type2)); | 365 CHECK(Equal(type1, type2)); |
| 362 } | 366 } |
| 363 | 367 |
| 364 void CheckSub(TypeHandle type1, TypeHandle type2) { | 368 void CheckSub(TypeHandle type1, TypeHandle type2) { |
| 365 CHECK(type1->Is(type2)); | 369 CHECK(type1->Is(type2)); |
| 366 CHECK(!type2->Is(type1)); | 370 CHECK(!type2->Is(type1)); |
| 367 if (Rep::IsBitset(type1) && Rep::IsBitset(type2)) { | 371 if (this->IsBitset(type1) && this->IsBitset(type2)) { |
| 368 CHECK_NE(Rep::AsBitset(type1), Rep::AsBitset(type2)); | 372 CHECK_NE(this->AsBitset(type1), this->AsBitset(type2)); |
| 369 } | 373 } |
| 370 } | 374 } |
| 371 | 375 |
| 372 void CheckUnordered(TypeHandle type1, TypeHandle type2) { | 376 void CheckUnordered(TypeHandle type1, TypeHandle type2) { |
| 373 CHECK(!type1->Is(type2)); | 377 CHECK(!type1->Is(type2)); |
| 374 CHECK(!type2->Is(type1)); | 378 CHECK(!type2->Is(type1)); |
| 375 if (Rep::IsBitset(type1) && Rep::IsBitset(type2)) { | 379 if (this->IsBitset(type1) && this->IsBitset(type2)) { |
| 376 CHECK_NE(Rep::AsBitset(type1), Rep::AsBitset(type2)); | 380 CHECK_NE(this->AsBitset(type1), this->AsBitset(type2)); |
| 377 } | 381 } |
| 378 } | 382 } |
| 379 | 383 |
| 380 void CheckOverlap(TypeHandle type1, TypeHandle type2, TypeHandle mask) { | 384 void CheckOverlap(TypeHandle type1, TypeHandle type2) { |
| 381 CHECK(type1->Maybe(type2)); | 385 CHECK(type1->Maybe(type2)); |
| 382 CHECK(type2->Maybe(type1)); | 386 CHECK(type2->Maybe(type1)); |
| 383 if (Rep::IsBitset(type1) && Rep::IsBitset(type2)) { | |
| 384 CHECK_NE(0, | |
| 385 Rep::AsBitset(type1) & Rep::AsBitset(type2) & Rep::AsBitset(mask)); | |
| 386 } | |
| 387 } | 387 } |
| 388 | 388 |
| 389 void CheckDisjoint(TypeHandle type1, TypeHandle type2, TypeHandle mask) { | 389 void CheckDisjoint(TypeHandle type1, TypeHandle type2) { |
| 390 CHECK(!type1->Is(type2)); | 390 CHECK(!type1->Is(type2)); |
| 391 CHECK(!type2->Is(type1)); | 391 CHECK(!type2->Is(type1)); |
| 392 CHECK(!type1->Maybe(type2)); | 392 CHECK(!type1->Maybe(type2)); |
| 393 CHECK(!type2->Maybe(type1)); | 393 CHECK(!type2->Maybe(type1)); |
| 394 if (Rep::IsBitset(type1) && Rep::IsBitset(type2)) { | 394 } |
| 395 CHECK_EQ(0, | 395 |
| 396 Rep::AsBitset(type1) & Rep::AsBitset(type2) & Rep::AsBitset(mask)); | 396 void IsSomeType() { |
| 397 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { | |
| 398 TypeHandle t = *it; | |
| 399 CHECK(1 == | |
| 400 this->IsBitset(t) + t->IsClass() + t->IsConstant() + t->IsRange() + | |
| 401 this->IsUnion(t) + t->IsArray() + t->IsFunction() + t->IsContext()); | |
| 397 } | 402 } |
| 398 } | 403 } |
| 399 | 404 |
| 400 void Bitset() { | 405 void Bitset() { |
| 401 // None and Any are bitsets. | 406 // None and Any are bitsets. |
| 402 CHECK(this->IsBitset(T.None)); | 407 CHECK(this->IsBitset(T.None)); |
| 403 CHECK(this->IsBitset(T.Any)); | 408 CHECK(this->IsBitset(T.Any)); |
| 404 | 409 |
| 405 CHECK_EQ(0, this->AsBitset(T.None)); | 410 CHECK_EQ(0, this->AsBitset(T.None)); |
| 406 CHECK_EQ(-1, this->AsBitset(T.Any)); | 411 CHECK_EQ(-1, this->AsBitset(T.Any)); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 445 TypeHandle type2 = *it2; | 450 TypeHandle type2 = *it2; |
| 446 TypeHandle union12 = T.Union(type1, type2); | 451 TypeHandle union12 = T.Union(type1, type2); |
| 447 if (this->IsBitset(type1) && this->IsBitset(type2)) { | 452 if (this->IsBitset(type1) && this->IsBitset(type2)) { |
| 448 CHECK_EQ( | 453 CHECK_EQ( |
| 449 this->AsBitset(type1) | this->AsBitset(type2), | 454 this->AsBitset(type1) | this->AsBitset(type2), |
| 450 this->AsBitset(union12)); | 455 this->AsBitset(union12)); |
| 451 } | 456 } |
| 452 } | 457 } |
| 453 } | 458 } |
| 454 | 459 |
| 455 // Intersect(T1, T2) is bitwise conjunction for bitsets T1,T2 | 460 // Intersect(T1, T2) is bitwise conjunction for bitsets T1,T2 (modulo None) |
|
rossberg
2014/09/15 15:58:30
Hm, None doesn't really sound right...
neis1
2014/09/16 10:04:00
Why not? If Intersect(T1, T2) is None, then it ma
| |
| 456 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { | 461 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { |
| 457 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { | 462 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { |
| 458 TypeHandle type1 = *it1; | 463 TypeHandle type1 = *it1; |
| 459 TypeHandle type2 = *it2; | 464 TypeHandle type2 = *it2; |
| 460 TypeHandle intersect12 = T.Intersect(type1, type2); | 465 TypeHandle intersect12 = T.Intersect(type1, type2); |
| 461 if (this->IsBitset(type1) && this->IsBitset(type2)) { | 466 if (this->IsBitset(type1) && this->IsBitset(type2)) { |
| 467 int bitset = this->AsBitset(type1) & this->AsBitset(type2); | |
| 462 CHECK_EQ( | 468 CHECK_EQ( |
| 463 this->AsBitset(type1) & this->AsBitset(type2), | 469 Rep::BitsetType::IsInhabited(bitset) ? bitset : 0, |
| 464 this->AsBitset(intersect12)); | 470 this->AsBitset(intersect12)); |
| 465 } | 471 } |
| 466 } | 472 } |
| 467 } | 473 } |
| 468 } | 474 } |
| 469 | 475 |
| 470 void Class() { | 476 void Class() { |
| 471 // Constructor | 477 // Constructor |
| 472 for (MapIterator mt = T.maps.begin(); mt != T.maps.end(); ++mt) { | 478 for (MapIterator mt = T.maps.begin(); mt != T.maps.end(); ++mt) { |
| 473 Handle<i::Map> map = *mt; | 479 Handle<i::Map> map = *mt; |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 555 CHECK(T.Constant(fac->NewNumber(-10.1))->Is(T.OtherNumber)); | 561 CHECK(T.Constant(fac->NewNumber(-10.1))->Is(T.OtherNumber)); |
| 556 CHECK(T.Constant(fac->NewNumber(10e60))->Is(T.OtherNumber)); | 562 CHECK(T.Constant(fac->NewNumber(10e60))->Is(T.OtherNumber)); |
| 557 CHECK(T.Constant(fac->NewNumber(-1.0*0.0))->Is(T.MinusZero)); | 563 CHECK(T.Constant(fac->NewNumber(-1.0*0.0))->Is(T.MinusZero)); |
| 558 CHECK(T.Constant(fac->NewNumber(v8::base::OS::nan_value()))->Is(T.NaN)); | 564 CHECK(T.Constant(fac->NewNumber(v8::base::OS::nan_value()))->Is(T.NaN)); |
| 559 CHECK(T.Constant(fac->NewNumber(V8_INFINITY))->Is(T.OtherNumber)); | 565 CHECK(T.Constant(fac->NewNumber(V8_INFINITY))->Is(T.OtherNumber)); |
| 560 CHECK(T.Constant(fac->NewNumber(-V8_INFINITY))->Is(T.OtherNumber)); | 566 CHECK(T.Constant(fac->NewNumber(-V8_INFINITY))->Is(T.OtherNumber)); |
| 561 } | 567 } |
| 562 | 568 |
| 563 void Range() { | 569 void Range() { |
| 564 // Constructor | 570 // Constructor |
| 565 for (DoubleIterator i = T.doubles.begin(); i != T.doubles.end(); ++i) { | 571 for (ValueIterator i = T.integers.begin(); i != T.integers.end(); ++i) { |
| 566 for (DoubleIterator j = T.doubles.begin(); j != T.doubles.end(); ++j) { | 572 for (ValueIterator j = T.integers.begin(); j != T.integers.end(); ++j) { |
| 567 double min = T.dmin(*i, *j); | 573 i::Handle<i::Object> min = *i; |
| 568 double max = T.dmax(*i, *j); | 574 i::Handle<i::Object> max = *j; |
| 575 if (min->Number() > max->Number()) std::swap(min, max); | |
| 569 TypeHandle type = T.Range(min, max); | 576 TypeHandle type = T.Range(min, max); |
| 570 CHECK(type->IsRange()); | 577 CHECK(type->IsRange()); |
| 571 } | 578 } |
| 572 } | 579 } |
| 573 | 580 |
| 574 // Range attributes | 581 // Range attributes |
| 575 for (DoubleIterator i = T.doubles.begin(); i != T.doubles.end(); ++i) { | 582 for (ValueIterator i = T.integers.begin(); i != T.integers.end(); ++i) { |
| 576 for (DoubleIterator j = T.doubles.begin(); j != T.doubles.end(); ++j) { | 583 for (ValueIterator j = T.integers.begin(); j != T.integers.end(); ++j) { |
| 577 double min = T.dmin(*i, *j); | 584 i::Handle<i::Object> min = *i; |
| 578 double max = T.dmax(*i, *j); | 585 i::Handle<i::Object> max = *j; |
| 579 printf("RangeType: min, max = %f, %f\n", min, max); | 586 if (min->Number() > max->Number()) std::swap(min, max); |
| 580 TypeHandle type = T.Range(min, max); | 587 TypeHandle type = T.Range(min, max); |
| 581 printf("RangeType: Min, Max = %f, %f\n", | 588 CHECK(*min == *type->AsRange()->MinV()); |
| 582 type->AsRange()->Min(), type->AsRange()->Max()); | 589 CHECK(*max == *type->AsRange()->MaxV()); |
| 583 CHECK(min == type->AsRange()->Min()); | |
| 584 CHECK(max == type->AsRange()->Max()); | |
| 585 } | 590 } |
| 586 } | 591 } |
| 587 | 592 |
| 588 // TODO(neis): enable once subtyping is updated. | 593 // Functionality & Injectivity: Range(min1, max1) = Range(min2, max2) <=> |
| 589 // // Functionality & Injectivity: Range(min1, max1) = Range(min2, max2) <=> | 594 // min1 = min2 /\ max1 = max2 |
| 590 // // min1 = min2 /\ max1 = max2 | 595 for (ValueIterator i1 = T.integers.begin(); |
| 591 // for (DoubleIterator i1 = T.doubles.begin(); i1 != T.doubles.end(); ++i1) { | 596 i1 != T.integers.end(); ++i1) { |
| 592 // for (DoubleIterator j1 = T.doubles.begin(); j1 != T.doubles.end(); ++j1) { | 597 for (ValueIterator j1 = T.integers.begin(); |
| 593 // for (DoubleIterator i2 = T.doubles.begin(); | 598 j1 != T.integers.end(); ++j1) { |
| 594 // i2 != T.doubles.end(); ++i2) { | 599 for (ValueIterator i2 = T.integers.begin(); |
| 595 // for (DoubleIterator j2 = T.doubles.begin(); | 600 i2 != T.integers.end(); ++i2) { |
| 596 // j2 != T.doubles.end(); ++j2) { | 601 for (ValueIterator j2 = T.integers.begin(); |
| 597 // double min1 = T.dmin(*i1, *j1); | 602 j2 != T.integers.end(); ++j2) { |
| 598 // double max1 = T.dmax(*i1, *j1); | 603 i::Handle<i::Object> min1 = *i1; |
| 599 // double min2 = T.dmin(*i2, *j2); | 604 i::Handle<i::Object> max1 = *j1; |
| 600 // double max2 = T.dmax(*i2, *j2); | 605 i::Handle<i::Object> min2 = *i2; |
| 601 // TypeHandle type1 = T.Range(min1, max1); | 606 i::Handle<i::Object> max2 = *j2; |
| 602 // TypeHandle type2 = T.Range(min2, max2); | 607 if (min1->Number() > max1->Number()) std::swap(min1, max1); |
| 603 // CHECK(Equal(type1, type2) == | 608 if (min2->Number() > max2->Number()) std::swap(min2, max2); |
| 604 // (T.deq(min1, min2) && T.deq(max1, max2))); | 609 TypeHandle type1 = T.Range(min1, max1); |
| 605 // } | 610 TypeHandle type2 = T.Range(min2, max2); |
| 606 // } | 611 CHECK(Equal(type1, type2) == (*min1 == *min2 && *max1 == *max2)); |
| 607 // } | 612 } |
| 608 // } | 613 } |
| 614 } | |
| 615 } | |
| 609 } | 616 } |
| 610 | 617 |
| 611 void Array() { | 618 void Array() { |
| 612 // Constructor | 619 // Constructor |
| 613 for (int i = 0; i < 20; ++i) { | 620 for (int i = 0; i < 20; ++i) { |
| 614 TypeHandle type = T.Random(); | 621 TypeHandle type = T.Random(); |
| 615 TypeHandle array = T.Array1(type); | 622 TypeHandle array = T.Array1(type); |
| 616 CHECK(array->IsArray()); | 623 CHECK(array->IsArray()); |
| 617 } | 624 } |
| 618 | 625 |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 706 | 713 |
| 707 void Of() { | 714 void Of() { |
| 708 // Constant(V)->Is(Of(V)) | 715 // Constant(V)->Is(Of(V)) |
| 709 for (ValueIterator vt = T.values.begin(); vt != T.values.end(); ++vt) { | 716 for (ValueIterator vt = T.values.begin(); vt != T.values.end(); ++vt) { |
| 710 Handle<i::Object> value = *vt; | 717 Handle<i::Object> value = *vt; |
| 711 TypeHandle const_type = T.Constant(value); | 718 TypeHandle const_type = T.Constant(value); |
| 712 TypeHandle of_type = T.Of(value); | 719 TypeHandle of_type = T.Of(value); |
| 713 CHECK(const_type->Is(of_type)); | 720 CHECK(const_type->Is(of_type)); |
| 714 } | 721 } |
| 715 | 722 |
| 716 // Constant(V)->Is(T) iff Of(V)->Is(T) or T->Maybe(Constant(V)) | 723 // If Of(V)->Is(T), then Constant(V)->Is(T) |
| 717 for (ValueIterator vt = T.values.begin(); vt != T.values.end(); ++vt) { | 724 for (ValueIterator vt = T.values.begin(); vt != T.values.end(); ++vt) { |
| 718 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { | 725 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { |
| 719 Handle<i::Object> value = *vt; | 726 Handle<i::Object> value = *vt; |
| 720 TypeHandle type = *it; | 727 TypeHandle type = *it; |
| 721 TypeHandle const_type = T.Constant(value); | 728 TypeHandle const_type = T.Constant(value); |
| 722 TypeHandle of_type = T.Of(value); | 729 TypeHandle of_type = T.Of(value); |
| 723 CHECK(const_type->Is(type) == | 730 CHECK(!of_type->Is(type) || const_type->Is(type)); |
| 724 (of_type->Is(type) || type->Maybe(const_type))); | 731 } |
| 732 } | |
| 733 | |
| 734 // If Constant(V)->Is(T), then Of(V)->Is(T) or T->Maybe(Constant(V)) | |
| 735 for (ValueIterator vt = T.values.begin(); vt != T.values.end(); ++vt) { | |
| 736 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { | |
| 737 Handle<i::Object> value = *vt; | |
| 738 TypeHandle type = *it; | |
| 739 TypeHandle const_type = T.Constant(value); | |
| 740 TypeHandle of_type = T.Of(value); | |
| 741 CHECK(!const_type->Is(type) || | |
| 742 of_type->Is(type) || type->Maybe(const_type)); | |
| 725 } | 743 } |
| 726 } | 744 } |
| 727 } | 745 } |
| 728 | 746 |
| 729 void NowOf() { | 747 void NowOf() { |
| 730 // Constant(V)->NowIs(NowOf(V)) | 748 // Constant(V)->NowIs(NowOf(V)) |
| 731 for (ValueIterator vt = T.values.begin(); vt != T.values.end(); ++vt) { | 749 for (ValueIterator vt = T.values.begin(); vt != T.values.end(); ++vt) { |
| 732 Handle<i::Object> value = *vt; | 750 Handle<i::Object> value = *vt; |
| 733 TypeHandle const_type = T.Constant(value); | 751 TypeHandle const_type = T.Constant(value); |
| 734 TypeHandle nowof_type = T.NowOf(value); | 752 TypeHandle nowof_type = T.NowOf(value); |
| 735 CHECK(const_type->NowIs(nowof_type)); | 753 CHECK(const_type->NowIs(nowof_type)); |
| 736 } | 754 } |
| 737 | 755 |
| 738 // NowOf(V)->Is(Of(V)) | 756 // NowOf(V)->Is(Of(V)) |
| 739 for (ValueIterator vt = T.values.begin(); vt != T.values.end(); ++vt) { | 757 for (ValueIterator vt = T.values.begin(); vt != T.values.end(); ++vt) { |
| 740 Handle<i::Object> value = *vt; | 758 Handle<i::Object> value = *vt; |
| 741 TypeHandle nowof_type = T.NowOf(value); | 759 TypeHandle nowof_type = T.NowOf(value); |
| 742 TypeHandle of_type = T.Of(value); | 760 TypeHandle of_type = T.Of(value); |
| 743 CHECK(nowof_type->Is(of_type)); | 761 CHECK(nowof_type->Is(of_type)); |
| 744 } | 762 } |
| 745 | 763 |
| 746 // Constant(V)->NowIs(T) iff NowOf(V)->NowIs(T) or T->Maybe(Constant(V)) | 764 // If NowOf(V)->NowIs(T), then Constant(V)->NowIs(T) |
| 747 for (ValueIterator vt = T.values.begin(); vt != T.values.end(); ++vt) { | 765 for (ValueIterator vt = T.values.begin(); vt != T.values.end(); ++vt) { |
| 748 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { | 766 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { |
| 749 Handle<i::Object> value = *vt; | 767 Handle<i::Object> value = *vt; |
| 750 TypeHandle type = *it; | 768 TypeHandle type = *it; |
| 751 TypeHandle const_type = T.Constant(value); | 769 TypeHandle const_type = T.Constant(value); |
| 752 TypeHandle nowof_type = T.NowOf(value); | 770 TypeHandle nowof_type = T.NowOf(value); |
| 753 CHECK(const_type->NowIs(type) == | 771 CHECK(!nowof_type->NowIs(type) || const_type->NowIs(type)); |
| 754 (nowof_type->NowIs(type) || type->Maybe(const_type))); | |
| 755 } | 772 } |
| 756 } | 773 } |
| 757 | 774 |
| 758 // Constant(V)->Is(T) implies NowOf(V)->Is(T) or T->Maybe(Constant(V)) | 775 // If Constant(V)->NowIs(T), |
| 776 // then NowOf(V)->NowIs(T) or T->Maybe(Constant(V)) | |
| 759 for (ValueIterator vt = T.values.begin(); vt != T.values.end(); ++vt) { | 777 for (ValueIterator vt = T.values.begin(); vt != T.values.end(); ++vt) { |
| 760 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { | 778 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { |
| 761 Handle<i::Object> value = *vt; | 779 Handle<i::Object> value = *vt; |
| 780 TypeHandle type = *it; | |
| 781 TypeHandle const_type = T.Constant(value); | |
| 782 TypeHandle nowof_type = T.NowOf(value); | |
| 783 CHECK(!const_type->NowIs(type) || | |
| 784 nowof_type->NowIs(type) || type->Maybe(const_type)); | |
| 785 } | |
| 786 } | |
| 787 | |
| 788 // If Constant(V)->Is(T), | |
| 789 // then NowOf(V)->Is(T) or T->Maybe(Constant(V)) | |
| 790 for (ValueIterator vt = T.values.begin(); vt != T.values.end(); ++vt) { | |
| 791 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { | |
| 792 Handle<i::Object> value = *vt; | |
| 762 TypeHandle type = *it; | 793 TypeHandle type = *it; |
| 763 TypeHandle const_type = T.Constant(value); | 794 TypeHandle const_type = T.Constant(value); |
| 764 TypeHandle nowof_type = T.NowOf(value); | 795 TypeHandle nowof_type = T.NowOf(value); |
| 765 CHECK(!const_type->Is(type) || | 796 CHECK(!const_type->Is(type) || |
| 766 (nowof_type->Is(type) || type->Maybe(const_type))); | 797 nowof_type->Is(type) || type->Maybe(const_type)); |
| 767 } | 798 } |
| 768 } | 799 } |
| 769 } | 800 } |
| 770 | 801 |
| 771 void Bounds() { | 802 void BitsetGlb() { |
| 772 // Ordering: (T->BitsetGlb())->Is(T->BitsetLub()) | 803 // Lower: (T->BitsetGlb())->Is(T) |
| 773 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { | |
| 774 TypeHandle type = *it; | |
| 775 TypeHandle glb = | |
| 776 Rep::BitsetType::New(Rep::BitsetType::Glb(type), T.region()); | |
| 777 TypeHandle lub = | |
| 778 Rep::BitsetType::New(Rep::BitsetType::Lub(type), T.region()); | |
| 779 CHECK(glb->Is(lub)); | |
| 780 } | |
| 781 | |
| 782 // Lower bound: (T->BitsetGlb())->Is(T) | |
| 783 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { | 804 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { |
| 784 TypeHandle type = *it; | 805 TypeHandle type = *it; |
| 785 TypeHandle glb = | 806 TypeHandle glb = |
| 786 Rep::BitsetType::New(Rep::BitsetType::Glb(type), T.region()); | 807 Rep::BitsetType::New(Rep::BitsetType::Glb(type), T.region()); |
| 787 CHECK(glb->Is(type)); | 808 CHECK(glb->Is(type)); |
| 788 } | 809 } |
| 789 | 810 |
| 790 // Upper bound: T->Is(T->BitsetLub()) | 811 // Greatest: If T1->IsBitset() and T1->Is(T2), then T1->Is(T2->BitsetGlb()) |
| 812 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { | |
| 813 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { | |
| 814 TypeHandle type1 = *it1; | |
| 815 TypeHandle type2 = *it2; | |
| 816 TypeHandle glb2 = | |
| 817 Rep::BitsetType::New(Rep::BitsetType::Glb(type2), T.region()); | |
| 818 CHECK(!this->IsBitset(type1) || !type1->Is(type2) || type1->Is(glb2)); | |
| 819 } | |
| 820 } | |
| 821 | |
| 822 // Monotonicity: T1->Is(T2) implies (T1->BitsetGlb())->Is(T2->BitsetGlb()) | |
| 823 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { | |
| 824 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { | |
| 825 TypeHandle type1 = *it1; | |
| 826 TypeHandle type2 = *it2; | |
| 827 TypeHandle glb1 = | |
| 828 Rep::BitsetType::New(Rep::BitsetType::Glb(type1), T.region()); | |
| 829 TypeHandle glb2 = | |
| 830 Rep::BitsetType::New(Rep::BitsetType::Glb(type2), T.region()); | |
| 831 CHECK(!type1->Is(type2) || glb1->Is(glb2)); | |
| 832 } | |
| 833 } | |
| 834 } | |
| 835 | |
| 836 void BitsetLub() { | |
| 837 // Upper: T->Is(T->BitsetLub()) | |
| 791 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { | 838 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { |
| 792 TypeHandle type = *it; | 839 TypeHandle type = *it; |
| 793 TypeHandle lub = | 840 TypeHandle lub = |
| 794 Rep::BitsetType::New(Rep::BitsetType::Lub(type), T.region()); | 841 Rep::BitsetType::New(Rep::BitsetType::Lub(type), T.region()); |
| 795 CHECK(type->Is(lub)); | 842 CHECK(type->Is(lub)); |
| 796 } | 843 } |
| 797 | 844 |
| 798 // Inherent bound: (T->BitsetLub())->Is(T->InherentBitsetLub()) | 845 // Least: If T2->IsBitset() and T1->Is(T2), then (T1->BitsetLub())->Is(T2) |
| 799 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { | 846 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { |
| 800 TypeHandle type = *it; | 847 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { |
| 801 TypeHandle lub = | 848 TypeHandle type1 = *it1; |
| 802 Rep::BitsetType::New(Rep::BitsetType::Lub(type), T.region()); | 849 TypeHandle type2 = *it2; |
| 803 TypeHandle inherent = | 850 TypeHandle lub1 = |
| 804 Rep::BitsetType::New(Rep::BitsetType::InherentLub(type), T.region()); | 851 Rep::BitsetType::New(Rep::BitsetType::Lub(type1), T.region()); |
| 805 CHECK(lub->Is(inherent)); | 852 CHECK(!this->IsBitset(type2) || !type1->Is(type2) || lub1->Is(type2)); |
| 853 } | |
| 854 } | |
| 855 | |
| 856 // Monotonicity: T1->Is(T2) implies (T1->BitsetLub())->Is(T2->BitsetLub()) | |
| 857 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { | |
| 858 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { | |
| 859 TypeHandle type1 = *it1; | |
| 860 TypeHandle type2 = *it2; | |
| 861 TypeHandle lub1 = | |
| 862 Rep::BitsetType::New(Rep::BitsetType::Lub(type1), T.region()); | |
| 863 TypeHandle lub2 = | |
| 864 Rep::BitsetType::New(Rep::BitsetType::Lub(type2), T.region()); | |
| 865 CHECK(!type1->Is(type2) || lub1->Is(lub2)); | |
| 866 } | |
| 806 } | 867 } |
| 807 } | 868 } |
| 808 | 869 |
| 809 void Is() { | 870 void Is() { |
| 810 // Least Element (Bottom): None->Is(T) | 871 // Least Element (Bottom): None->Is(T) |
| 811 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { | 872 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { |
| 812 TypeHandle type = *it; | 873 TypeHandle type = *it; |
| 813 CHECK(T.None->Is(type)); | 874 CHECK(T.None->Is(type)); |
| 814 } | 875 } |
| 815 | 876 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 851 | 912 |
| 852 // Antisymmetry: T1->Is(T2) and T2->Is(T1) iff T1 = T2 | 913 // Antisymmetry: T1->Is(T2) and T2->Is(T1) iff T1 = T2 |
| 853 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { | 914 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { |
| 854 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { | 915 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { |
| 855 TypeHandle type1 = *it1; | 916 TypeHandle type1 = *it1; |
| 856 TypeHandle type2 = *it2; | 917 TypeHandle type2 = *it2; |
| 857 CHECK((type1->Is(type2) && type2->Is(type1)) == Equal(type1, type2)); | 918 CHECK((type1->Is(type2) && type2->Is(type1)) == Equal(type1, type2)); |
| 858 } | 919 } |
| 859 } | 920 } |
| 860 | 921 |
| 922 // Class(M1)->Is(Class(M2)) iff M1 = M2 | |
| 923 for (MapIterator mt1 = T.maps.begin(); mt1 != T.maps.end(); ++mt1) { | |
| 924 for (MapIterator mt2 = T.maps.begin(); mt2 != T.maps.end(); ++mt2) { | |
| 925 Handle<i::Map> map1 = *mt1; | |
| 926 Handle<i::Map> map2 = *mt2; | |
| 927 TypeHandle class_type1 = T.Class(map1); | |
| 928 TypeHandle class_type2 = T.Class(map2); | |
| 929 CHECK(class_type1->Is(class_type2) == (*map1 == *map2)); | |
| 930 } | |
| 931 } | |
| 932 | |
| 861 // Constant(V1)->Is(Constant(V2)) iff V1 = V2 | 933 // Constant(V1)->Is(Constant(V2)) iff V1 = V2 |
| 862 for (ValueIterator vt1 = T.values.begin(); vt1 != T.values.end(); ++vt1) { | 934 for (ValueIterator vt1 = T.values.begin(); vt1 != T.values.end(); ++vt1) { |
| 863 for (ValueIterator vt2 = T.values.begin(); vt2 != T.values.end(); ++vt2) { | 935 for (ValueIterator vt2 = T.values.begin(); vt2 != T.values.end(); ++vt2) { |
| 864 Handle<i::Object> value1 = *vt1; | 936 Handle<i::Object> value1 = *vt1; |
| 865 Handle<i::Object> value2 = *vt2; | 937 Handle<i::Object> value2 = *vt2; |
| 866 TypeHandle const_type1 = T.Constant(value1); | 938 TypeHandle const_type1 = T.Constant(value1); |
| 867 TypeHandle const_type2 = T.Constant(value2); | 939 TypeHandle const_type2 = T.Constant(value2); |
| 868 CHECK(const_type1->Is(const_type2) == (*value1 == *value2)); | 940 CHECK(const_type1->Is(const_type2) == (*value1 == *value2)); |
| 869 } | 941 } |
| 870 } | 942 } |
| 871 | 943 |
| 872 // Class(M1)->Is(Class(M2)) iff M1 = M2 | 944 // Range(min1, max1)->Is(Range(min2, max2)) iff |
| 873 for (MapIterator mt1 = T.maps.begin(); mt1 != T.maps.end(); ++mt1) { | 945 // min1 >= min2 /\ max1 <= max2 |
| 874 for (MapIterator mt2 = T.maps.begin(); mt2 != T.maps.end(); ++mt2) { | 946 for (ValueIterator i1 = T.integers.begin(); |
| 875 Handle<i::Map> map1 = *mt1; | 947 i1 != T.integers.end(); ++i1) { |
| 876 Handle<i::Map> map2 = *mt2; | 948 for (ValueIterator j1 = T.integers.begin(); |
| 877 TypeHandle class_type1 = T.Class(map1); | 949 j1 != T.integers.end(); ++j1) { |
| 878 TypeHandle class_type2 = T.Class(map2); | 950 for (ValueIterator i2 = T.integers.begin(); |
| 879 CHECK(class_type1->Is(class_type2) == (*map1 == *map2)); | 951 i2 != T.integers.end(); ++i2) { |
| 952 for (ValueIterator j2 = T.integers.begin(); | |
| 953 j2 != T.integers.end(); ++j2) { | |
| 954 i::Handle<i::Object> min1 = *i1; | |
| 955 i::Handle<i::Object> max1 = *j1; | |
| 956 i::Handle<i::Object> min2 = *i2; | |
| 957 i::Handle<i::Object> max2 = *j2; | |
| 958 if (min1->Number() > max1->Number()) std::swap(min1, max1); | |
| 959 if (min2->Number() > max2->Number()) std::swap(min2, max2); | |
| 960 TypeHandle type1 = T.Range(min1, max1); | |
| 961 TypeHandle type2 = T.Range(min2, max2); | |
| 962 CHECK(type1->Is(type2) == | |
| 963 (min2->Number() <= min1->Number() && | |
| 964 max1->Number() <= max2->Number())); | |
| 965 } | |
| 966 } | |
| 880 } | 967 } |
| 881 } | 968 } |
| 882 | 969 |
| 883 // Constant(V)->Is(Class(M)) never | 970 // Context(T1)->Is(Context(T2)) iff T1 = T2 |
| 884 for (MapIterator mt = T.maps.begin(); mt != T.maps.end(); ++mt) { | 971 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { |
| 885 for (ValueIterator vt = T.values.begin(); vt != T.values.end(); ++vt) { | 972 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { |
| 886 Handle<i::Map> map = *mt; | 973 TypeHandle outer1 = *it1; |
| 887 Handle<i::Object> value = *vt; | 974 TypeHandle outer2 = *it2; |
| 888 TypeHandle constant_type = T.Constant(value); | 975 TypeHandle type1 = T.Context(outer1); |
| 889 TypeHandle class_type = T.Class(map); | 976 TypeHandle type2 = T.Context(outer2); |
| 890 CHECK(!constant_type->Is(class_type)); | 977 CHECK(type1->Is(type2) == outer1->Equals(outer2)); |
| 891 } | 978 } |
| 892 } | 979 } |
| 893 | 980 |
| 894 // Class(M)->Is(Constant(V)) never | 981 // Array(T1)->Is(Array(T2)) iff T1 = T2 |
| 895 for (MapIterator mt = T.maps.begin(); mt != T.maps.end(); ++mt) { | 982 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { |
| 896 for (ValueIterator vt = T.values.begin(); vt != T.values.end(); ++vt) { | 983 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { |
| 897 Handle<i::Map> map = *mt; | 984 TypeHandle element1 = *it1; |
| 898 Handle<i::Object> value = *vt; | 985 TypeHandle element2 = *it2; |
| 899 TypeHandle constant_type = T.Constant(value); | 986 TypeHandle type1 = T.Array1(element1); |
| 900 TypeHandle class_type = T.Class(map); | 987 TypeHandle type2 = T.Array1(element2); |
| 901 CHECK(!class_type->Is(constant_type)); | 988 CHECK(type1->Is(type2) == element1->Equals(element2)); |
| 902 } | 989 } |
| 903 } | 990 } |
| 904 | 991 |
| 992 // Function0(S1, T1)->Is(Function0(S2, T2)) iff S1 = S2 and T1 = T2 | |
| 993 for (TypeIterator i = T.types.begin(); i != T.types.end(); ++i) { | |
| 994 for (TypeIterator j = T.types.begin(); j != T.types.end(); ++j) { | |
| 995 TypeHandle result1 = *i; | |
| 996 TypeHandle receiver1 = *j; | |
| 997 TypeHandle type1 = T.Function0(result1, receiver1); | |
| 998 TypeHandle result2 = T.Random(); | |
| 999 TypeHandle receiver2 = T.Random(); | |
| 1000 TypeHandle type2 = T.Function0(result2, receiver2); | |
| 1001 CHECK(type1->Is(type2) == | |
| 1002 (result1->Equals(result2) && receiver1->Equals(receiver2))); | |
| 1003 } | |
| 1004 } | |
| 1005 | |
| 1006 // (In-)Compatibilities. | |
| 1007 for (TypeIterator i = T.types.begin(); i != T.types.end(); ++i) { | |
| 1008 for (TypeIterator j = T.types.begin(); j != T.types.end(); ++j) { | |
| 1009 TypeHandle type1 = *i; | |
| 1010 TypeHandle type2 = *j; | |
| 1011 CHECK(!type1->Is(type2) || this->IsBitset(type2) || | |
| 1012 this->IsUnion(type2) || this->IsUnion(type1) || | |
| 1013 (type1->IsClass() && type2->IsClass()) || | |
| 1014 (type1->IsConstant() && type2->IsConstant()) || | |
| 1015 (type1->IsConstant() && type2->IsRange()) || | |
| 1016 (type1->IsRange() && type2->IsRange()) || | |
| 1017 (type1->IsContext() && type2->IsContext()) || | |
| 1018 (type1->IsArray() && type2->IsArray()) || | |
| 1019 (type1->IsFunction() && type2->IsFunction()) || | |
| 1020 type1->Equals(T.None)); | |
| 1021 } | |
| 1022 } | |
| 1023 | |
| 905 // Basic types | 1024 // Basic types |
| 906 CheckUnordered(T.Boolean, T.Null); | 1025 CheckUnordered(T.Boolean, T.Null); |
| 907 CheckUnordered(T.Undefined, T.Null); | 1026 CheckUnordered(T.Undefined, T.Null); |
| 908 CheckUnordered(T.Boolean, T.Undefined); | 1027 CheckUnordered(T.Boolean, T.Undefined); |
| 909 | 1028 |
| 910 CheckSub(T.SignedSmall, T.Number); | 1029 CheckSub(T.SignedSmall, T.Number); |
| 911 CheckSub(T.Signed32, T.Number); | 1030 CheckSub(T.Signed32, T.Number); |
| 912 CheckSub(T.SignedSmall, T.Signed32); | 1031 CheckSub(T.SignedSmall, T.Signed32); |
| 913 CheckUnordered(T.SignedSmall, T.MinusZero); | 1032 CheckUnordered(T.SignedSmall, T.MinusZero); |
| 914 CheckUnordered(T.Signed32, T.Unsigned32); | 1033 CheckUnordered(T.Signed32, T.Unsigned32); |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1082 void Contains() { | 1201 void Contains() { |
| 1083 // T->Contains(V) iff Constant(V)->Is(T) | 1202 // T->Contains(V) iff Constant(V)->Is(T) |
| 1084 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { | 1203 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { |
| 1085 for (ValueIterator vt = T.values.begin(); vt != T.values.end(); ++vt) { | 1204 for (ValueIterator vt = T.values.begin(); vt != T.values.end(); ++vt) { |
| 1086 TypeHandle type = *it; | 1205 TypeHandle type = *it; |
| 1087 Handle<i::Object> value = *vt; | 1206 Handle<i::Object> value = *vt; |
| 1088 TypeHandle const_type = T.Constant(value); | 1207 TypeHandle const_type = T.Constant(value); |
| 1089 CHECK(type->Contains(value) == const_type->Is(type)); | 1208 CHECK(type->Contains(value) == const_type->Is(type)); |
| 1090 } | 1209 } |
| 1091 } | 1210 } |
| 1092 | |
| 1093 // Of(V)->Is(T) implies T->Contains(V) | |
| 1094 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { | |
| 1095 for (ValueIterator vt = T.values.begin(); vt != T.values.end(); ++vt) { | |
| 1096 TypeHandle type = *it; | |
| 1097 Handle<i::Object> value = *vt; | |
| 1098 TypeHandle of_type = T.Of(value); | |
| 1099 CHECK(!of_type->Is(type) || type->Contains(value)); | |
| 1100 } | |
| 1101 } | |
| 1102 } | 1211 } |
| 1103 | 1212 |
| 1104 void NowContains() { | 1213 void NowContains() { |
| 1105 // T->NowContains(V) iff Constant(V)->NowIs(T) | 1214 // T->NowContains(V) iff Constant(V)->NowIs(T) |
| 1106 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { | 1215 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { |
| 1107 for (ValueIterator vt = T.values.begin(); vt != T.values.end(); ++vt) { | 1216 for (ValueIterator vt = T.values.begin(); vt != T.values.end(); ++vt) { |
| 1108 TypeHandle type = *it; | 1217 TypeHandle type = *it; |
| 1109 Handle<i::Object> value = *vt; | 1218 Handle<i::Object> value = *vt; |
| 1110 TypeHandle const_type = T.Constant(value); | 1219 TypeHandle const_type = T.Constant(value); |
| 1111 CHECK(type->NowContains(value) == const_type->NowIs(type)); | 1220 CHECK(type->NowContains(value) == const_type->NowIs(type)); |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 1123 | 1232 |
| 1124 // NowOf(V)->Is(T) implies T->NowContains(V) | 1233 // NowOf(V)->Is(T) implies T->NowContains(V) |
| 1125 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { | 1234 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { |
| 1126 for (ValueIterator vt = T.values.begin(); vt != T.values.end(); ++vt) { | 1235 for (ValueIterator vt = T.values.begin(); vt != T.values.end(); ++vt) { |
| 1127 TypeHandle type = *it; | 1236 TypeHandle type = *it; |
| 1128 Handle<i::Object> value = *vt; | 1237 Handle<i::Object> value = *vt; |
| 1129 TypeHandle nowof_type = T.Of(value); | 1238 TypeHandle nowof_type = T.Of(value); |
| 1130 CHECK(!nowof_type->NowIs(type) || type->NowContains(value)); | 1239 CHECK(!nowof_type->NowIs(type) || type->NowContains(value)); |
| 1131 } | 1240 } |
| 1132 } | 1241 } |
| 1133 | |
| 1134 // NowOf(V)->NowIs(T) implies T->NowContains(V) | |
| 1135 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { | |
| 1136 for (ValueIterator vt = T.values.begin(); vt != T.values.end(); ++vt) { | |
| 1137 TypeHandle type = *it; | |
| 1138 Handle<i::Object> value = *vt; | |
| 1139 TypeHandle nowof_type = T.Of(value); | |
| 1140 CHECK(!nowof_type->NowIs(type) || type->NowContains(value)); | |
| 1141 } | |
| 1142 } | |
| 1143 } | 1242 } |
| 1144 | 1243 |
| 1145 void Maybe() { | 1244 void Maybe() { |
| 1146 // T->Maybe(Any) iff T inhabited | 1245 // T->Maybe(Any) iff T inhabited |
| 1147 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { | 1246 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { |
| 1148 TypeHandle type = *it; | 1247 TypeHandle type = *it; |
| 1149 CHECK(type->Maybe(T.Any) == type->IsInhabited()); | 1248 CHECK(type->Maybe(T.Any) == type->IsInhabited()); |
| 1150 } | 1249 } |
| 1151 | 1250 |
| 1152 // T->Maybe(None) never | 1251 // T->Maybe(None) never |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1215 for (MapIterator mt1 = T.maps.begin(); mt1 != T.maps.end(); ++mt1) { | 1314 for (MapIterator mt1 = T.maps.begin(); mt1 != T.maps.end(); ++mt1) { |
| 1216 for (MapIterator mt2 = T.maps.begin(); mt2 != T.maps.end(); ++mt2) { | 1315 for (MapIterator mt2 = T.maps.begin(); mt2 != T.maps.end(); ++mt2) { |
| 1217 Handle<i::Map> map1 = *mt1; | 1316 Handle<i::Map> map1 = *mt1; |
| 1218 Handle<i::Map> map2 = *mt2; | 1317 Handle<i::Map> map2 = *mt2; |
| 1219 TypeHandle class_type1 = T.Class(map1); | 1318 TypeHandle class_type1 = T.Class(map1); |
| 1220 TypeHandle class_type2 = T.Class(map2); | 1319 TypeHandle class_type2 = T.Class(map2); |
| 1221 CHECK(class_type1->Maybe(class_type2) == (*map1 == *map2)); | 1320 CHECK(class_type1->Maybe(class_type2) == (*map1 == *map2)); |
| 1222 } | 1321 } |
| 1223 } | 1322 } |
| 1224 | 1323 |
| 1225 // Constant(V)->Maybe(Class(M)) never | |
| 1226 for (MapIterator mt = T.maps.begin(); mt != T.maps.end(); ++mt) { | |
| 1227 for (ValueIterator vt = T.values.begin(); vt != T.values.end(); ++vt) { | |
| 1228 Handle<i::Map> map = *mt; | |
| 1229 Handle<i::Object> value = *vt; | |
| 1230 TypeHandle const_type = T.Constant(value); | |
| 1231 TypeHandle class_type = T.Class(map); | |
| 1232 CHECK(!const_type->Maybe(class_type)); | |
| 1233 } | |
| 1234 } | |
| 1235 | |
| 1236 // Class(M)->Maybe(Constant(V)) never | |
| 1237 for (MapIterator mt = T.maps.begin(); mt != T.maps.end(); ++mt) { | |
| 1238 for (ValueIterator vt = T.values.begin(); vt != T.values.end(); ++vt) { | |
| 1239 Handle<i::Map> map = *mt; | |
| 1240 Handle<i::Object> value = *vt; | |
| 1241 TypeHandle const_type = T.Constant(value); | |
| 1242 TypeHandle class_type = T.Class(map); | |
| 1243 CHECK(!class_type->Maybe(const_type)); | |
| 1244 } | |
| 1245 } | |
| 1246 | |
| 1247 // Basic types | 1324 // Basic types |
| 1248 CheckDisjoint(T.Boolean, T.Null, T.Semantic); | 1325 CheckDisjoint(T.Boolean, T.Null); |
| 1249 CheckDisjoint(T.Undefined, T.Null, T.Semantic); | 1326 CheckDisjoint(T.Undefined, T.Null); |
| 1250 CheckDisjoint(T.Boolean, T.Undefined, T.Semantic); | 1327 CheckDisjoint(T.Boolean, T.Undefined); |
| 1251 | 1328 CheckOverlap(T.SignedSmall, T.Number); |
| 1252 CheckOverlap(T.SignedSmall, T.Number, T.Semantic); | 1329 CheckOverlap(T.NaN, T.Number); |
| 1253 CheckOverlap(T.NaN, T.Number, T.Semantic); | 1330 CheckDisjoint(T.Signed32, T.NaN); |
| 1254 CheckDisjoint(T.Signed32, T.NaN, T.Semantic); | 1331 CheckOverlap(T.UniqueName, T.Name); |
| 1255 | 1332 CheckOverlap(T.String, T.Name); |
| 1256 CheckOverlap(T.UniqueName, T.Name, T.Semantic); | 1333 CheckOverlap(T.InternalizedString, T.String); |
| 1257 CheckOverlap(T.String, T.Name, T.Semantic); | 1334 CheckOverlap(T.InternalizedString, T.UniqueName); |
| 1258 CheckOverlap(T.InternalizedString, T.String, T.Semantic); | 1335 CheckOverlap(T.InternalizedString, T.Name); |
| 1259 CheckOverlap(T.InternalizedString, T.UniqueName, T.Semantic); | 1336 CheckOverlap(T.Symbol, T.UniqueName); |
| 1260 CheckOverlap(T.InternalizedString, T.Name, T.Semantic); | 1337 CheckOverlap(T.Symbol, T.Name); |
| 1261 CheckOverlap(T.Symbol, T.UniqueName, T.Semantic); | 1338 CheckOverlap(T.String, T.UniqueName); |
| 1262 CheckOverlap(T.Symbol, T.Name, T.Semantic); | 1339 CheckDisjoint(T.String, T.Symbol); |
| 1263 CheckOverlap(T.String, T.UniqueName, T.Semantic); | 1340 CheckDisjoint(T.InternalizedString, T.Symbol); |
| 1264 CheckDisjoint(T.String, T.Symbol, T.Semantic); | 1341 CheckOverlap(T.Object, T.Receiver); |
| 1265 CheckDisjoint(T.InternalizedString, T.Symbol, T.Semantic); | 1342 CheckOverlap(T.Array, T.Object); |
| 1266 | 1343 CheckOverlap(T.Function, T.Object); |
| 1267 CheckOverlap(T.Object, T.Receiver, T.Semantic); | 1344 CheckOverlap(T.Proxy, T.Receiver); |
| 1268 CheckOverlap(T.Array, T.Object, T.Semantic); | 1345 CheckDisjoint(T.Object, T.Proxy); |
| 1269 CheckOverlap(T.Function, T.Object, T.Semantic); | 1346 CheckDisjoint(T.Array, T.Function); |
| 1270 CheckOverlap(T.Proxy, T.Receiver, T.Semantic); | |
| 1271 CheckDisjoint(T.Object, T.Proxy, T.Semantic); | |
| 1272 CheckDisjoint(T.Array, T.Function, T.Semantic); | |
| 1273 | 1347 |
| 1274 // Structural types | 1348 // Structural types |
| 1275 CheckOverlap(T.ObjectClass, T.Object, T.Semantic); | 1349 CheckOverlap(T.ObjectClass, T.Object); |
| 1276 CheckOverlap(T.ArrayClass, T.Object, T.Semantic); | 1350 CheckOverlap(T.ArrayClass, T.Object); |
| 1277 CheckOverlap(T.ObjectClass, T.ObjectClass, T.Semantic); | 1351 CheckOverlap(T.ObjectClass, T.ObjectClass); |
| 1278 CheckOverlap(T.ArrayClass, T.ArrayClass, T.Semantic); | 1352 CheckOverlap(T.ArrayClass, T.ArrayClass); |
| 1279 CheckDisjoint(T.ObjectClass, T.ArrayClass, T.Semantic); | 1353 CheckDisjoint(T.ObjectClass, T.ArrayClass); |
| 1280 | 1354 CheckOverlap(T.SmiConstant, T.SignedSmall); |
| 1281 CheckOverlap(T.SmiConstant, T.SignedSmall, T.Semantic); | 1355 CheckOverlap(T.SmiConstant, T.Signed32); |
| 1282 CheckOverlap(T.SmiConstant, T.Signed32, T.Semantic); | 1356 CheckOverlap(T.SmiConstant, T.Number); |
| 1283 CheckOverlap(T.SmiConstant, T.Number, T.Semantic); | 1357 CheckOverlap(T.ObjectConstant1, T.Object); |
| 1284 CheckOverlap(T.ObjectConstant1, T.Object, T.Semantic); | 1358 CheckOverlap(T.ObjectConstant2, T.Object); |
| 1285 CheckOverlap(T.ObjectConstant2, T.Object, T.Semantic); | 1359 CheckOverlap(T.ArrayConstant, T.Object); |
| 1286 CheckOverlap(T.ArrayConstant, T.Object, T.Semantic); | 1360 CheckOverlap(T.ArrayConstant, T.Array); |
| 1287 CheckOverlap(T.ArrayConstant, T.Array, T.Semantic); | 1361 CheckOverlap(T.ObjectConstant1, T.ObjectConstant1); |
| 1288 CheckOverlap(T.ObjectConstant1, T.ObjectConstant1, T.Semantic); | 1362 CheckDisjoint(T.ObjectConstant1, T.ObjectConstant2); |
| 1289 CheckDisjoint(T.ObjectConstant1, T.ObjectConstant2, T.Semantic); | 1363 CheckDisjoint(T.ObjectConstant1, T.ArrayConstant); |
| 1290 CheckDisjoint(T.ObjectConstant1, T.ArrayConstant, T.Semantic); | 1364 CheckDisjoint(T.ObjectConstant1, T.ArrayClass); |
| 1291 | 1365 CheckDisjoint(T.ObjectConstant2, T.ArrayClass); |
| 1292 CheckDisjoint(T.ObjectConstant1, T.ObjectClass, T.Semantic); | 1366 CheckDisjoint(T.ArrayConstant, T.ObjectClass); |
| 1293 CheckDisjoint(T.ObjectConstant2, T.ObjectClass, T.Semantic); | 1367 CheckOverlap(T.NumberArray, T.Array); |
| 1294 CheckDisjoint(T.ObjectConstant1, T.ArrayClass, T.Semantic); | 1368 CheckDisjoint(T.NumberArray, T.AnyArray); |
| 1295 CheckDisjoint(T.ObjectConstant2, T.ArrayClass, T.Semantic); | 1369 CheckDisjoint(T.NumberArray, T.StringArray); |
| 1296 CheckDisjoint(T.ArrayConstant, T.ObjectClass, T.Semantic); | 1370 CheckOverlap(T.MethodFunction, T.Function); |
| 1297 | 1371 CheckDisjoint(T.SignedFunction1, T.NumberFunction1); |
| 1298 CheckOverlap(T.NumberArray, T.Array, T.Semantic); | 1372 CheckDisjoint(T.SignedFunction1, T.NumberFunction2); |
| 1299 CheckDisjoint(T.NumberArray, T.AnyArray, T.Semantic); | 1373 CheckDisjoint(T.NumberFunction1, T.NumberFunction2); |
| 1300 CheckDisjoint(T.NumberArray, T.StringArray, T.Semantic); | 1374 CheckDisjoint(T.SignedFunction1, T.MethodFunction); |
| 1301 | 1375 CheckOverlap(T.ObjectConstant1, T.ObjectClass); // !!! |
| 1302 CheckOverlap(T.MethodFunction, T.Function, T.Semantic); | 1376 CheckOverlap(T.ObjectConstant2, T.ObjectClass); // !!! |
| 1303 CheckDisjoint(T.SignedFunction1, T.NumberFunction1, T.Semantic); | 1377 CheckOverlap(T.NumberClass, T.Intersect(T.Number, T.Untagged)); // !!! |
| 1304 CheckDisjoint(T.SignedFunction1, T.NumberFunction2, T.Semantic); | |
| 1305 CheckDisjoint(T.NumberFunction1, T.NumberFunction2, T.Semantic); | |
| 1306 CheckDisjoint(T.SignedFunction1, T.MethodFunction, T.Semantic); | |
| 1307 } | 1378 } |
| 1308 | 1379 |
| 1309 void Union1() { | 1380 void Union1() { |
| 1310 // Identity: Union(T, None) = T | 1381 // Identity: Union(T, None) = T |
| 1311 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { | 1382 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { |
| 1312 TypeHandle type = *it; | 1383 TypeHandle type = *it; |
| 1313 TypeHandle union_type = T.Union(type, T.None); | 1384 TypeHandle union_type = T.Union(type, T.None); |
| 1314 CheckEqual(union_type, type); | 1385 CheckEqual(union_type, type); |
| 1315 } | 1386 } |
| 1316 | 1387 |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 1333 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { | 1404 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { |
| 1334 TypeHandle type1 = *it1; | 1405 TypeHandle type1 = *it1; |
| 1335 TypeHandle type2 = *it2; | 1406 TypeHandle type2 = *it2; |
| 1336 TypeHandle union12 = T.Union(type1, type2); | 1407 TypeHandle union12 = T.Union(type1, type2); |
| 1337 TypeHandle union21 = T.Union(type2, type1); | 1408 TypeHandle union21 = T.Union(type2, type1); |
| 1338 CheckEqual(union12, union21); | 1409 CheckEqual(union12, union21); |
| 1339 } | 1410 } |
| 1340 } | 1411 } |
| 1341 | 1412 |
| 1342 // Associativity: Union(T1, Union(T2, T3)) = Union(Union(T1, T2), T3) | 1413 // Associativity: Union(T1, Union(T2, T3)) = Union(Union(T1, T2), T3) |
| 1414 // This does NOT hold! | |
| 1415 /* | |
| 1343 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { | 1416 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { |
| 1344 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { | 1417 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { |
| 1345 for (TypeIterator it3 = T.types.begin(); it3 != T.types.end(); ++it3) { | 1418 for (TypeIterator it3 = T.types.begin(); it3 != T.types.end(); ++it3) { |
| 1346 TypeHandle type1 = *it1; | 1419 TypeHandle type1 = *it1; |
| 1347 TypeHandle type2 = *it2; | 1420 TypeHandle type2 = *it2; |
| 1348 TypeHandle type3 = *it3; | 1421 TypeHandle type3 = *it3; |
| 1349 TypeHandle union12 = T.Union(type1, type2); | 1422 TypeHandle union12 = T.Union(type1, type2); |
| 1350 TypeHandle union23 = T.Union(type2, type3); | 1423 TypeHandle union23 = T.Union(type2, type3); |
| 1351 TypeHandle union1_23 = T.Union(type1, union23); | 1424 TypeHandle union1_23 = T.Union(type1, union23); |
| 1352 TypeHandle union12_3 = T.Union(union12, type3); | 1425 TypeHandle union12_3 = T.Union(union12, type3); |
| 1353 CheckEqual(union1_23, union12_3); | 1426 CheckEqual(union1_23, union12_3); |
| 1354 } | 1427 } |
| 1355 } | 1428 } |
| 1356 } | 1429 } |
| 1430 */ | |
| 1357 | 1431 |
| 1358 // Meet: T1->Is(Union(T1, T2)) and T2->Is(Union(T1, T2)) | 1432 // Meet: T1->Is(Union(T1, T2)) and T2->Is(Union(T1, T2)) |
| 1359 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { | 1433 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { |
| 1360 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { | 1434 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { |
| 1361 TypeHandle type1 = *it1; | 1435 TypeHandle type1 = *it1; |
| 1362 TypeHandle type2 = *it2; | 1436 TypeHandle type2 = *it2; |
| 1363 TypeHandle union12 = T.Union(type1, type2); | 1437 TypeHandle union12 = T.Union(type1, type2); |
| 1364 CHECK(type1->Is(union12)); | 1438 CHECK(type1->Is(union12)); |
| 1365 CHECK(type2->Is(union12)); | 1439 CHECK(type2->Is(union12)); |
| 1366 } | 1440 } |
| 1367 } | 1441 } |
| 1368 | 1442 |
| 1369 // Upper Boundedness: T1->Is(T2) implies Union(T1, T2) = T2 | 1443 // Upper Boundedness: T1->Is(T2) implies Union(T1, T2) = T2 |
| 1370 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { | 1444 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { |
| 1371 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { | 1445 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { |
| 1372 TypeHandle type1 = *it1; | 1446 TypeHandle type1 = *it1; |
| 1373 TypeHandle type2 = *it2; | 1447 TypeHandle type2 = *it2; |
| 1374 TypeHandle union12 = T.Union(type1, type2); | 1448 TypeHandle union12 = T.Union(type1, type2); |
| 1375 if (type1->Is(type2)) CheckEqual(union12, type2); | 1449 if (type1->Is(type2)) CheckEqual(union12, type2); |
| 1376 } | 1450 } |
| 1377 } | 1451 } |
| 1378 } | |
| 1379 | 1452 |
| 1380 void Union2() { | |
| 1381 // Monotonicity: T1->Is(T2) implies Union(T1, T3)->Is(Union(T2, T3)) | 1453 // Monotonicity: T1->Is(T2) implies Union(T1, T3)->Is(Union(T2, T3)) |
| 1454 // This does NOT hold. | |
| 1455 /* | |
| 1382 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { | 1456 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { |
| 1383 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { | 1457 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { |
| 1384 for (TypeIterator it3 = T.types.begin(); it3 != T.types.end(); ++it3) { | 1458 for (TypeIterator it3 = T.types.begin(); it3 != T.types.end(); ++it3) { |
| 1385 TypeHandle type1 = *it1; | 1459 TypeHandle type1 = *it1; |
| 1386 TypeHandle type2 = *it2; | 1460 TypeHandle type2 = *it2; |
| 1387 TypeHandle type3 = *it3; | 1461 TypeHandle type3 = *it3; |
| 1388 TypeHandle union13 = T.Union(type1, type3); | 1462 TypeHandle union13 = T.Union(type1, type3); |
| 1389 TypeHandle union23 = T.Union(type2, type3); | 1463 TypeHandle union23 = T.Union(type2, type3); |
| 1390 CHECK(!type1->Is(type2) || union13->Is(union23)); | 1464 CHECK(!type1->Is(type2) || union13->Is(union23)); |
| 1391 } | 1465 } |
| 1392 } | 1466 } |
| 1393 } | 1467 } |
| 1468 */ | |
| 1469 } | |
| 1394 | 1470 |
| 1471 void Union2() { | |
| 1395 // Monotonicity: T1->Is(T3) and T2->Is(T3) implies Union(T1, T2)->Is(T3) | 1472 // Monotonicity: T1->Is(T3) and T2->Is(T3) implies Union(T1, T2)->Is(T3) |
| 1473 // This does NOT hold. TODO(neis): Could fix this by splitting | |
| 1474 // OtherNumber into a negative and a positive part. | |
| 1475 /* | |
| 1396 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { | 1476 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { |
| 1397 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { | 1477 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { |
| 1398 for (TypeIterator it3 = T.types.begin(); it3 != T.types.end(); ++it3) { | 1478 for (TypeIterator it3 = T.types.begin(); it3 != T.types.end(); ++it3) { |
| 1399 TypeHandle type1 = *it1; | 1479 TypeHandle type1 = *it1; |
| 1400 TypeHandle type2 = *it2; | 1480 TypeHandle type2 = *it2; |
| 1401 TypeHandle type3 = *it3; | 1481 TypeHandle type3 = *it3; |
| 1402 TypeHandle union12 = T.Union(type1, type2); | 1482 TypeHandle union12 = T.Union(type1, type2); |
| 1403 CHECK(!(type1->Is(type3) && type2->Is(type3)) || union12->Is(type3)); | 1483 CHECK(!(type1->Is(type3) && type2->Is(type3)) || union12->Is(type3)); |
| 1404 } | 1484 } |
| 1405 } | 1485 } |
| 1406 } | 1486 } |
| 1487 */ | |
| 1488 } | |
| 1407 | 1489 |
| 1490 void Union3() { | |
| 1408 // Monotonicity: T1->Is(T2) or T1->Is(T3) implies T1->Is(Union(T2, T3)) | 1491 // Monotonicity: T1->Is(T2) or T1->Is(T3) implies T1->Is(Union(T2, T3)) |
| 1409 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { | 1492 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { |
| 1410 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { | 1493 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { |
| 1411 for (TypeIterator it3 = T.types.begin(); it3 != T.types.end(); ++it3) { | 1494 for (TypeIterator it3 = T.types.begin(); it3 != T.types.end(); ++it3) { |
| 1412 TypeHandle type1 = *it1; | 1495 TypeHandle type1 = *it1; |
| 1413 TypeHandle type2 = *it2; | 1496 TypeHandle type2 = *it2; |
| 1414 TypeHandle type3 = *it3; | 1497 TypeHandle type3 = *it3; |
| 1415 TypeHandle union23 = T.Union(type2, type3); | 1498 TypeHandle union23 = T.Union(type2, type3); |
| 1416 CHECK(!(type1->Is(type2) || type1->Is(type3)) || type1->Is(union23)); | 1499 CHECK(!(type1->Is(type2) || type1->Is(type3)) || type1->Is(union23)); |
| 1417 } | 1500 } |
| 1418 } | 1501 } |
| 1419 } | 1502 } |
| 1503 } | |
| 1420 | 1504 |
| 1505 void Union4() { | |
| 1421 // Class-class | 1506 // Class-class |
| 1422 CheckSub(T.Union(T.ObjectClass, T.ArrayClass), T.Object); | 1507 CheckSub(T.Union(T.ObjectClass, T.ArrayClass), T.Object); |
| 1423 CheckUnordered(T.Union(T.ObjectClass, T.ArrayClass), T.Array); | 1508 CheckUnordered(T.Union(T.ObjectClass, T.ArrayClass), T.Array); |
| 1424 CheckOverlap(T.Union(T.ObjectClass, T.ArrayClass), T.Array, T.Semantic); | 1509 CheckOverlap(T.Union(T.ObjectClass, T.ArrayClass), T.Array); |
| 1425 CheckDisjoint(T.Union(T.ObjectClass, T.ArrayClass), T.Number, T.Semantic); | 1510 CheckDisjoint(T.Union(T.ObjectClass, T.ArrayClass), T.Number); |
| 1426 | 1511 |
| 1427 // Constant-constant | 1512 // Constant-constant |
| 1428 CheckSub(T.Union(T.ObjectConstant1, T.ObjectConstant2), T.Object); | 1513 CheckSub(T.Union(T.ObjectConstant1, T.ObjectConstant2), T.Object); |
| 1429 CheckUnordered(T.Union(T.ObjectConstant1, T.ArrayConstant), T.Array); | 1514 CheckUnordered(T.Union(T.ObjectConstant1, T.ArrayConstant), T.Array); |
| 1430 CheckUnordered( | 1515 CheckUnordered( |
| 1431 T.Union(T.ObjectConstant1, T.ObjectConstant2), T.ObjectClass); | 1516 T.Union(T.ObjectConstant1, T.ObjectConstant2), T.ObjectClass); |
| 1432 CheckOverlap( | 1517 CheckOverlap( |
| 1433 T.Union(T.ObjectConstant1, T.ArrayConstant), T.Array, T.Semantic); | 1518 T.Union(T.ObjectConstant1, T.ArrayConstant), T.Array); |
| 1434 CheckDisjoint( | 1519 CheckDisjoint( |
| 1435 T.Union(T.ObjectConstant1, T.ArrayConstant), T.Number, T.Semantic); | 1520 T.Union(T.ObjectConstant1, T.ArrayConstant), T.Number); |
| 1436 CheckDisjoint( | 1521 CheckOverlap( |
| 1437 T.Union(T.ObjectConstant1, T.ArrayConstant), T.ObjectClass, T.Semantic); | 1522 T.Union(T.ObjectConstant1, T.ArrayConstant), T.ObjectClass); // !!! |
| 1438 | 1523 |
| 1439 // Bitset-array | 1524 // Bitset-array |
| 1440 CHECK(this->IsBitset(T.Union(T.AnyArray, T.Array))); | 1525 CHECK(this->IsBitset(T.Union(T.AnyArray, T.Array))); |
| 1441 CHECK(this->IsUnion(T.Union(T.NumberArray, T.Number))); | 1526 CHECK(this->IsUnion(T.Union(T.NumberArray, T.Number))); |
| 1442 | 1527 |
| 1443 CheckEqual(T.Union(T.AnyArray, T.Array), T.Array); | 1528 CheckEqual(T.Union(T.AnyArray, T.Array), T.Array); |
| 1444 CheckUnordered(T.Union(T.AnyArray, T.String), T.Array); | 1529 CheckUnordered(T.Union(T.AnyArray, T.String), T.Array); |
| 1445 CheckOverlap(T.Union(T.NumberArray, T.String), T.Object, T.Semantic); | 1530 CheckOverlap(T.Union(T.NumberArray, T.String), T.Object); |
| 1446 CheckDisjoint(T.Union(T.NumberArray, T.String), T.Number, T.Semantic); | 1531 CheckDisjoint(T.Union(T.NumberArray, T.String), T.Number); |
| 1447 | 1532 |
| 1448 // Bitset-function | 1533 // Bitset-function |
| 1449 CHECK(this->IsBitset(T.Union(T.MethodFunction, T.Function))); | 1534 CHECK(this->IsBitset(T.Union(T.MethodFunction, T.Function))); |
| 1450 CHECK(this->IsUnion(T.Union(T.NumberFunction1, T.Number))); | 1535 CHECK(this->IsUnion(T.Union(T.NumberFunction1, T.Number))); |
| 1451 | 1536 |
| 1452 CheckEqual(T.Union(T.MethodFunction, T.Function), T.Function); | 1537 CheckEqual(T.Union(T.MethodFunction, T.Function), T.Function); |
| 1453 CheckUnordered(T.Union(T.NumberFunction1, T.String), T.Function); | 1538 CheckUnordered(T.Union(T.NumberFunction1, T.String), T.Function); |
| 1454 CheckOverlap(T.Union(T.NumberFunction2, T.String), T.Object, T.Semantic); | 1539 CheckOverlap(T.Union(T.NumberFunction2, T.String), T.Object); |
| 1455 CheckDisjoint(T.Union(T.NumberFunction1, T.String), T.Number, T.Semantic); | 1540 CheckDisjoint(T.Union(T.NumberFunction1, T.String), T.Number); |
| 1456 | 1541 |
| 1457 // Bitset-class | 1542 // Bitset-class |
| 1458 CheckSub( | 1543 CheckSub( |
| 1459 T.Union(T.ObjectClass, T.SignedSmall), T.Union(T.Object, T.Number)); | 1544 T.Union(T.ObjectClass, T.SignedSmall), T.Union(T.Object, T.Number)); |
| 1460 CheckSub(T.Union(T.ObjectClass, T.Array), T.Object); | 1545 CheckSub(T.Union(T.ObjectClass, T.Array), T.Object); |
| 1461 CheckUnordered(T.Union(T.ObjectClass, T.String), T.Array); | 1546 CheckUnordered(T.Union(T.ObjectClass, T.String), T.Array); |
| 1462 CheckOverlap(T.Union(T.ObjectClass, T.String), T.Object, T.Semantic); | 1547 CheckOverlap(T.Union(T.ObjectClass, T.String), T.Object); |
| 1463 CheckDisjoint(T.Union(T.ObjectClass, T.String), T.Number, T.Semantic); | 1548 CheckDisjoint(T.Union(T.ObjectClass, T.String), T.Number); |
| 1464 | 1549 |
| 1465 // Bitset-constant | 1550 // Bitset-constant |
| 1466 CheckSub( | 1551 CheckSub( |
| 1467 T.Union(T.ObjectConstant1, T.Signed32), T.Union(T.Object, T.Number)); | 1552 T.Union(T.ObjectConstant1, T.Signed32), T.Union(T.Object, T.Number)); |
| 1468 CheckSub(T.Union(T.ObjectConstant1, T.Array), T.Object); | 1553 CheckSub(T.Union(T.ObjectConstant1, T.Array), T.Object); |
| 1469 CheckUnordered(T.Union(T.ObjectConstant1, T.String), T.Array); | 1554 CheckUnordered(T.Union(T.ObjectConstant1, T.String), T.Array); |
| 1470 CheckOverlap(T.Union(T.ObjectConstant1, T.String), T.Object, T.Semantic); | 1555 CheckOverlap(T.Union(T.ObjectConstant1, T.String), T.Object); |
| 1471 CheckDisjoint(T.Union(T.ObjectConstant1, T.String), T.Number, T.Semantic); | 1556 CheckDisjoint(T.Union(T.ObjectConstant1, T.String), T.Number); |
| 1472 | 1557 |
| 1473 // Class-constant | 1558 // Class-constant |
| 1474 CheckSub(T.Union(T.ObjectConstant1, T.ArrayClass), T.Object); | 1559 CheckSub(T.Union(T.ObjectConstant1, T.ArrayClass), T.Object); |
| 1475 CheckUnordered(T.ObjectClass, T.Union(T.ObjectConstant1, T.ArrayClass)); | 1560 CheckUnordered(T.ObjectClass, T.Union(T.ObjectConstant1, T.ArrayClass)); |
| 1476 CheckSub( | 1561 CheckSub( |
| 1477 T.Union(T.ObjectConstant1, T.ArrayClass), T.Union(T.Array, T.Object)); | 1562 T.Union(T.ObjectConstant1, T.ArrayClass), T.Union(T.Array, T.Object)); |
| 1478 CheckUnordered(T.Union(T.ObjectConstant1, T.ArrayClass), T.ArrayConstant); | 1563 CheckUnordered(T.Union(T.ObjectConstant1, T.ArrayClass), T.ArrayConstant); |
| 1479 CheckDisjoint( | 1564 CheckDisjoint( |
| 1480 T.Union(T.ObjectConstant1, T.ArrayClass), T.ObjectConstant2, | 1565 T.Union(T.ObjectConstant1, T.ArrayClass), T.ObjectConstant2); |
| 1481 T.Semantic); | 1566 CheckOverlap( |
| 1482 CheckDisjoint( | 1567 T.Union(T.ObjectConstant1, T.ArrayClass), T.ObjectClass); // !!! |
| 1483 T.Union(T.ObjectConstant1, T.ArrayClass), T.ObjectClass, T.Semantic); | |
| 1484 | 1568 |
| 1485 // Bitset-union | 1569 // Bitset-union |
| 1486 CheckSub( | 1570 CheckSub( |
| 1487 T.NaN, | 1571 T.NaN, |
| 1488 T.Union(T.Union(T.ArrayClass, T.ObjectConstant1), T.Number)); | 1572 T.Union(T.Union(T.ArrayClass, T.ObjectConstant1), T.Number)); |
| 1489 CheckSub( | 1573 CheckSub( |
| 1490 T.Union(T.Union(T.ArrayClass, T.ObjectConstant1), T.Signed32), | 1574 T.Union(T.Union(T.ArrayClass, T.ObjectConstant1), T.Signed32), |
| 1491 T.Union(T.ObjectConstant1, T.Union(T.Number, T.ArrayClass))); | 1575 T.Union(T.ObjectConstant1, T.Union(T.Number, T.ArrayClass))); |
| 1492 | 1576 |
| 1493 // Class-union | 1577 // Class-union |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1527 T.Union(T.ObjectConstant2, T.ObjectConstant1), | 1611 T.Union(T.ObjectConstant2, T.ObjectConstant1), |
| 1528 T.Union(T.ObjectConstant1, T.ObjectConstant2)), | 1612 T.Union(T.ObjectConstant1, T.ObjectConstant2)), |
| 1529 T.Union(T.ObjectConstant2, T.ObjectConstant1)); | 1613 T.Union(T.ObjectConstant2, T.ObjectConstant1)); |
| 1530 CheckEqual( | 1614 CheckEqual( |
| 1531 T.Union( | 1615 T.Union( |
| 1532 T.Union(T.Number, T.ArrayClass), | 1616 T.Union(T.Number, T.ArrayClass), |
| 1533 T.Union(T.SignedSmall, T.Array)), | 1617 T.Union(T.SignedSmall, T.Array)), |
| 1534 T.Union(T.Number, T.Array)); | 1618 T.Union(T.Number, T.Array)); |
| 1535 } | 1619 } |
| 1536 | 1620 |
| 1537 void Intersect1() { | 1621 void Intersect() { |
| 1538 // Identity: Intersect(T, Any) = T | 1622 // Identity: Intersect(T, Any) = T |
| 1539 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { | 1623 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { |
| 1540 TypeHandle type = *it; | 1624 TypeHandle type = *it; |
| 1541 TypeHandle intersect_type = T.Intersect(type, T.Any); | 1625 TypeHandle intersect_type = T.Intersect(type, T.Any); |
| 1542 CheckEqual(intersect_type, type); | 1626 CheckEqual(intersect_type, type); |
| 1543 } | 1627 } |
| 1544 | 1628 |
| 1545 // Domination: Intersect(T, None) = None | 1629 // Domination: Intersect(T, None) = None |
| 1546 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { | 1630 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { |
| 1547 TypeHandle type = *it; | 1631 TypeHandle type = *it; |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 1562 TypeHandle type1 = *it1; | 1646 TypeHandle type1 = *it1; |
| 1563 TypeHandle type2 = *it2; | 1647 TypeHandle type2 = *it2; |
| 1564 TypeHandle intersect12 = T.Intersect(type1, type2); | 1648 TypeHandle intersect12 = T.Intersect(type1, type2); |
| 1565 TypeHandle intersect21 = T.Intersect(type2, type1); | 1649 TypeHandle intersect21 = T.Intersect(type2, type1); |
| 1566 CheckEqual(intersect12, intersect21); | 1650 CheckEqual(intersect12, intersect21); |
| 1567 } | 1651 } |
| 1568 } | 1652 } |
| 1569 | 1653 |
| 1570 // Associativity: | 1654 // Associativity: |
| 1571 // Intersect(T1, Intersect(T2, T3)) = Intersect(Intersect(T1, T2), T3) | 1655 // Intersect(T1, Intersect(T2, T3)) = Intersect(Intersect(T1, T2), T3) |
| 1656 // This does NOT hold. | |
| 1657 /* | |
| 1572 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { | 1658 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { |
| 1573 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { | 1659 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { |
| 1574 for (TypeIterator it3 = T.types.begin(); it3 != T.types.end(); ++it3) { | 1660 for (TypeIterator it3 = T.types.begin(); it3 != T.types.end(); ++it3) { |
| 1575 TypeHandle type1 = *it1; | 1661 TypeHandle type1 = *it1; |
| 1576 TypeHandle type2 = *it2; | 1662 TypeHandle type2 = *it2; |
| 1577 TypeHandle type3 = *it3; | 1663 TypeHandle type3 = *it3; |
| 1578 TypeHandle intersect12 = T.Intersect(type1, type2); | 1664 TypeHandle intersect12 = T.Intersect(type1, type2); |
| 1579 TypeHandle intersect23 = T.Intersect(type2, type3); | 1665 TypeHandle intersect23 = T.Intersect(type2, type3); |
| 1580 TypeHandle intersect1_23 = T.Intersect(type1, intersect23); | 1666 TypeHandle intersect1_23 = T.Intersect(type1, intersect23); |
| 1581 TypeHandle intersect12_3 = T.Intersect(intersect12, type3); | 1667 TypeHandle intersect12_3 = T.Intersect(intersect12, type3); |
| 1582 CheckEqual(intersect1_23, intersect12_3); | 1668 CheckEqual(intersect1_23, intersect12_3); |
| 1583 } | 1669 } |
| 1584 } | 1670 } |
| 1585 } | 1671 } |
| 1672 */ | |
| 1586 | 1673 |
| 1587 // Join: Intersect(T1, T2)->Is(T1) and Intersect(T1, T2)->Is(T2) | 1674 // Join: Intersect(T1, T2)->Is(T1) and Intersect(T1, T2)->Is(T2) |
| 1675 // This does NOT hold. | |
| 1676 /* | |
| 1588 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { | 1677 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { |
| 1589 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { | 1678 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { |
| 1590 TypeHandle type1 = *it1; | 1679 TypeHandle type1 = *it1; |
| 1591 TypeHandle type2 = *it2; | 1680 TypeHandle type2 = *it2; |
| 1592 TypeHandle intersect12 = T.Intersect(type1, type2); | 1681 TypeHandle intersect12 = T.Intersect(type1, type2); |
| 1593 CHECK(intersect12->Is(type1)); | 1682 CHECK(intersect12->Is(type1)); |
| 1594 CHECK(intersect12->Is(type2)); | 1683 CHECK(intersect12->Is(type2)); |
| 1595 } | 1684 } |
| 1596 } | 1685 } |
| 1686 */ | |
| 1597 | 1687 |
| 1598 // Lower Boundedness: T1->Is(T2) implies Intersect(T1, T2) = T1 | 1688 // Lower Boundedness: T1->Is(T2) implies Intersect(T1, T2) = T1 |
| 1599 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { | 1689 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { |
| 1600 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { | 1690 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { |
| 1601 TypeHandle type1 = *it1; | 1691 TypeHandle type1 = *it1; |
| 1602 TypeHandle type2 = *it2; | 1692 TypeHandle type2 = *it2; |
| 1603 TypeHandle intersect12 = T.Intersect(type1, type2); | 1693 TypeHandle intersect12 = T.Intersect(type1, type2); |
| 1604 if (type1->Is(type2)) CheckEqual(intersect12, type1); | 1694 if (type1->Is(type2)) CheckEqual(intersect12, type1); |
| 1605 } | 1695 } |
| 1606 } | 1696 } |
| 1607 } | |
| 1608 | 1697 |
| 1609 void Intersect2() { | |
| 1610 // Monotonicity: T1->Is(T2) implies Intersect(T1, T3)->Is(Intersect(T2, T3)) | 1698 // Monotonicity: T1->Is(T2) implies Intersect(T1, T3)->Is(Intersect(T2, T3)) |
| 1699 // This does NOT hold. | |
| 1700 /* | |
| 1611 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { | 1701 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { |
| 1612 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { | 1702 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { |
| 1613 for (TypeIterator it3 = T.types.begin(); it3 != T.types.end(); ++it3) { | 1703 for (TypeIterator it3 = T.types.begin(); it3 != T.types.end(); ++it3) { |
| 1614 TypeHandle type1 = *it1; | 1704 TypeHandle type1 = *it1; |
| 1615 TypeHandle type2 = *it2; | 1705 TypeHandle type2 = *it2; |
| 1616 TypeHandle type3 = *it3; | 1706 TypeHandle type3 = *it3; |
| 1617 TypeHandle intersect13 = T.Intersect(type1, type3); | 1707 TypeHandle intersect13 = T.Intersect(type1, type3); |
| 1618 TypeHandle intersect23 = T.Intersect(type2, type3); | 1708 TypeHandle intersect23 = T.Intersect(type2, type3); |
| 1619 CHECK(!type1->Is(type2) || intersect13->Is(intersect23)); | 1709 CHECK(!type1->Is(type2) || intersect13->Is(intersect23)); |
| 1620 } | 1710 } |
| 1621 } | 1711 } |
| 1622 } | 1712 } |
| 1713 */ | |
| 1623 | 1714 |
| 1624 // Monotonicity: T1->Is(T3) or T2->Is(T3) implies Intersect(T1, T2)->Is(T3) | 1715 // Monotonicity: T1->Is(T3) or T2->Is(T3) implies Intersect(T1, T2)->Is(T3) |
| 1716 // This does NOT hold. | |
| 1717 /* | |
| 1625 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { | 1718 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { |
| 1626 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { | 1719 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { |
| 1627 for (TypeIterator it3 = T.types.begin(); it3 != T.types.end(); ++it3) { | 1720 for (TypeIterator it3 = T.types.begin(); it3 != T.types.end(); ++it3) { |
| 1628 TypeHandle type1 = *it1; | 1721 TypeHandle type1 = *it1; |
| 1629 TypeHandle type2 = *it2; | 1722 TypeHandle type2 = *it2; |
| 1630 TypeHandle type3 = *it3; | 1723 TypeHandle type3 = *it3; |
| 1631 TypeHandle intersect12 = T.Intersect(type1, type2); | 1724 TypeHandle intersect12 = T.Intersect(type1, type2); |
| 1632 CHECK(!(type1->Is(type3) || type2->Is(type3)) || | 1725 CHECK(!(type1->Is(type3) || type2->Is(type3)) || |
| 1633 intersect12->Is(type3)); | 1726 intersect12->Is(type3)); |
| 1634 } | 1727 } |
| 1635 } | 1728 } |
| 1636 } | 1729 } |
| 1730 */ | |
| 1637 | 1731 |
| 1638 // Monotonicity: T1->Is(T2) and T1->Is(T3) implies T1->Is(Intersect(T2, T3)) | 1732 // Monotonicity: T1->Is(T2) and T1->Is(T3) implies T1->Is(Intersect(T2, T3)) |
| 1733 // This does NOT hold. | |
| 1734 /* | |
| 1639 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { | 1735 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { |
| 1640 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { | 1736 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { |
| 1641 for (TypeIterator it3 = T.types.begin(); it3 != T.types.end(); ++it3) { | 1737 for (TypeIterator it3 = T.types.begin(); it3 != T.types.end(); ++it3) { |
| 1642 TypeHandle type1 = *it1; | 1738 TypeHandle type1 = *it1; |
| 1643 TypeHandle type2 = *it2; | 1739 TypeHandle type2 = *it2; |
| 1644 TypeHandle type3 = *it3; | 1740 TypeHandle type3 = *it3; |
| 1645 TypeHandle intersect23 = T.Intersect(type2, type3); | 1741 TypeHandle intersect23 = T.Intersect(type2, type3); |
| 1646 CHECK(!(type1->Is(type2) && type1->Is(type3)) || | 1742 CHECK(!(type1->Is(type2) && type1->Is(type3)) || |
| 1647 type1->Is(intersect23)); | 1743 type1->Is(intersect23)); |
| 1648 } | 1744 } |
| 1649 } | 1745 } |
| 1650 } | 1746 } |
| 1747 */ | |
| 1651 | 1748 |
| 1652 // Bitset-class | 1749 // Bitset-class |
| 1653 CheckEqual(T.Intersect(T.ObjectClass, T.Object), T.ObjectClass); | 1750 CheckEqual(T.Intersect(T.ObjectClass, T.Object), T.ObjectClass); |
| 1654 CheckSub(T.Intersect(T.ObjectClass, T.Array), T.Representation); | 1751 CheckEqual(T.Intersect(T.ObjectClass, T.Array), T.None); |
| 1655 CheckSub(T.Intersect(T.ObjectClass, T.Number), T.Representation); | 1752 CheckEqual(T.Intersect(T.ObjectClass, T.Number), T.None); |
| 1656 | 1753 |
| 1657 // Bitset-array | 1754 // Bitset-array |
| 1658 CheckEqual(T.Intersect(T.NumberArray, T.Object), T.NumberArray); | 1755 CheckEqual(T.Intersect(T.NumberArray, T.Object), T.NumberArray); |
| 1659 CheckSub(T.Intersect(T.AnyArray, T.Function), T.Representation); | 1756 CheckEqual(T.Intersect(T.AnyArray, T.Function), T.None); |
| 1660 | 1757 |
| 1661 // Bitset-function | 1758 // Bitset-function |
| 1662 CheckEqual(T.Intersect(T.MethodFunction, T.Object), T.MethodFunction); | 1759 CheckEqual(T.Intersect(T.MethodFunction, T.Object), T.MethodFunction); |
| 1663 CheckSub(T.Intersect(T.NumberFunction1, T.Array), T.Representation); | 1760 CheckEqual(T.Intersect(T.NumberFunction1, T.Array), T.None); |
| 1664 | 1761 |
| 1665 // Bitset-union | 1762 // Bitset-union |
| 1666 CheckEqual( | 1763 CheckEqual( |
| 1667 T.Intersect(T.Object, T.Union(T.ObjectConstant1, T.ObjectClass)), | 1764 T.Intersect(T.Object, T.Union(T.ObjectConstant1, T.ObjectClass)), |
| 1668 T.Union(T.ObjectConstant1, T.ObjectClass)); | 1765 T.Union(T.ObjectConstant1, T.ObjectClass)); |
| 1669 CHECK( | 1766 CHECK( |
| 1670 !T.Intersect(T.Union(T.ArrayClass, T.ObjectConstant1), T.Number) | 1767 !T.Intersect(T.Union(T.ArrayClass, T.ObjectConstant1), T.Number) |
| 1671 ->IsInhabited()); | 1768 ->IsInhabited()); |
| 1672 | 1769 |
| 1673 // Class-constant | 1770 // Class-constant |
| 1674 CHECK(!T.Intersect(T.ObjectConstant1, T.ObjectClass)->IsInhabited()); | 1771 CHECK(T.Intersect(T.ObjectConstant1, T.ObjectClass)->IsInhabited()); // !!! |
| 1675 CHECK(!T.Intersect(T.ArrayClass, T.ObjectConstant2)->IsInhabited()); | 1772 CHECK(!T.Intersect(T.ArrayClass, T.ObjectConstant2)->IsInhabited()); |
| 1676 | 1773 |
| 1677 // Array-union | 1774 // Array-union |
| 1678 CheckEqual( | 1775 CheckEqual( |
| 1679 T.Intersect(T.NumberArray, T.Union(T.NumberArray, T.ArrayClass)), | 1776 T.Intersect(T.NumberArray, T.Union(T.NumberArray, T.ArrayClass)), |
| 1680 T.NumberArray); | 1777 T.NumberArray); |
| 1681 CheckEqual( | 1778 CheckEqual( |
| 1682 T.Intersect(T.AnyArray, T.Union(T.Object, T.SmiConstant)), | 1779 T.Intersect(T.AnyArray, T.Union(T.Object, T.SmiConstant)), |
| 1683 T.AnyArray); | 1780 T.AnyArray); |
| 1684 CHECK( | 1781 CHECK( |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 1697 ->IsInhabited()); | 1794 ->IsInhabited()); |
| 1698 | 1795 |
| 1699 // Class-union | 1796 // Class-union |
| 1700 CheckEqual( | 1797 CheckEqual( |
| 1701 T.Intersect(T.ArrayClass, T.Union(T.ObjectConstant2, T.ArrayClass)), | 1798 T.Intersect(T.ArrayClass, T.Union(T.ObjectConstant2, T.ArrayClass)), |
| 1702 T.ArrayClass); | 1799 T.ArrayClass); |
| 1703 CheckEqual( | 1800 CheckEqual( |
| 1704 T.Intersect(T.ArrayClass, T.Union(T.Object, T.SmiConstant)), | 1801 T.Intersect(T.ArrayClass, T.Union(T.Object, T.SmiConstant)), |
| 1705 T.ArrayClass); | 1802 T.ArrayClass); |
| 1706 CHECK( | 1803 CHECK( |
| 1707 !T.Intersect(T.Union(T.ObjectClass, T.ArrayConstant), T.ArrayClass) | 1804 T.Intersect(T.Union(T.ObjectClass, T.ArrayConstant), T.ArrayClass) |
| 1708 ->IsInhabited()); | 1805 ->IsInhabited()); // !!! |
| 1709 | 1806 |
| 1710 // Constant-union | 1807 // Constant-union |
| 1711 CheckEqual( | 1808 CheckEqual( |
| 1712 T.Intersect( | 1809 T.Intersect( |
| 1713 T.ObjectConstant1, T.Union(T.ObjectConstant1, T.ObjectConstant2)), | 1810 T.ObjectConstant1, T.Union(T.ObjectConstant1, T.ObjectConstant2)), |
| 1714 T.ObjectConstant1); | 1811 T.ObjectConstant1); |
| 1715 CheckEqual( | 1812 CheckEqual( |
| 1716 T.Intersect(T.SmiConstant, T.Union(T.Number, T.ObjectConstant2)), | 1813 T.Intersect(T.SmiConstant, T.Union(T.Number, T.ObjectConstant2)), |
| 1717 T.SmiConstant); | 1814 T.SmiConstant); |
| 1718 CHECK( | 1815 CHECK( |
| 1719 !T.Intersect( | 1816 T.Intersect( |
| 1720 T.Union(T.ArrayConstant, T.ObjectClass), T.ObjectConstant1) | 1817 T.Union(T.ArrayConstant, T.ObjectClass), T.ObjectConstant1) |
| 1721 ->IsInhabited()); | 1818 ->IsInhabited()); // !!! |
| 1722 | 1819 |
| 1723 // Union-union | 1820 // Union-union |
| 1724 CheckEqual( | 1821 CheckEqual( |
| 1725 T.Intersect( | 1822 T.Intersect( |
| 1726 T.Union(T.Number, T.ArrayClass), | 1823 T.Union(T.Number, T.ArrayClass), |
| 1727 T.Union(T.SignedSmall, T.Array)), | 1824 T.Union(T.SignedSmall, T.Array)), |
| 1728 T.Union(T.SignedSmall, T.ArrayClass)); | 1825 T.Union(T.SignedSmall, T.ArrayClass)); |
| 1729 CheckEqual( | 1826 CheckEqual( |
| 1730 T.Intersect( | 1827 T.Intersect( |
| 1731 T.Union(T.Number, T.ObjectClass), | 1828 T.Union(T.Number, T.ObjectClass), |
| 1732 T.Union(T.Signed32, T.Array)), | 1829 T.Union(T.Signed32, T.Array)), |
| 1733 T.Signed32); | 1830 T.Signed32); |
| 1734 CheckEqual( | 1831 CheckEqual( |
| 1735 T.Intersect( | 1832 T.Intersect( |
| 1736 T.Union(T.ObjectConstant2, T.ObjectConstant1), | 1833 T.Union(T.ObjectConstant2, T.ObjectConstant1), |
| 1737 T.Union(T.ObjectConstant1, T.ObjectConstant2)), | 1834 T.Union(T.ObjectConstant1, T.ObjectConstant2)), |
| 1738 T.Union(T.ObjectConstant2, T.ObjectConstant1)); | 1835 T.Union(T.ObjectConstant2, T.ObjectConstant1)); |
| 1739 CheckEqual( | 1836 CheckEqual( |
| 1740 T.Intersect( | 1837 T.Intersect( |
| 1741 T.Union( | 1838 T.Union( |
| 1742 T.Union(T.ObjectConstant2, T.ObjectConstant1), T.ArrayClass), | 1839 T.ArrayClass, |
| 1840 T.Union(T.ObjectConstant2, T.ObjectConstant1)), | |
| 1743 T.Union( | 1841 T.Union( |
| 1744 T.ObjectConstant1, | 1842 T.ObjectConstant1, |
| 1745 T.Union(T.ArrayConstant, T.ObjectConstant2))), | 1843 T.Union(T.ArrayConstant, T.ObjectConstant2))), |
| 1746 T.Union(T.ObjectConstant2, T.ObjectConstant1)); | 1844 T.Union( |
| 1845 T.ArrayConstant, | |
| 1846 T.Union(T.ObjectConstant2, T.ObjectConstant1))); // !!! | |
| 1747 } | 1847 } |
| 1748 | 1848 |
| 1749 void Distributivity1() { | 1849 void Distributivity() { |
| 1750 // Distributivity: | |
| 1751 // Union(T1, Intersect(T2, T3)) = Intersect(Union(T1, T2), Union(T1, T3)) | 1850 // Union(T1, Intersect(T2, T3)) = Intersect(Union(T1, T2), Union(T1, T3)) |
| 1851 // This does NOT hold. | |
| 1852 /* | |
| 1752 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { | 1853 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { |
| 1753 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { | 1854 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { |
| 1754 for (TypeIterator it3 = T.types.begin(); it3 != T.types.end(); ++it3) { | 1855 for (TypeIterator it3 = T.types.begin(); it3 != T.types.end(); ++it3) { |
| 1755 TypeHandle type1 = *it1; | 1856 TypeHandle type1 = *it1; |
| 1756 TypeHandle type2 = *it2; | 1857 TypeHandle type2 = *it2; |
| 1757 TypeHandle type3 = *it3; | 1858 TypeHandle type3 = *it3; |
| 1758 TypeHandle union12 = T.Union(type1, type2); | 1859 TypeHandle union12 = T.Union(type1, type2); |
| 1759 TypeHandle union13 = T.Union(type1, type3); | 1860 TypeHandle union13 = T.Union(type1, type3); |
| 1760 TypeHandle intersect23 = T.Intersect(type2, type3); | 1861 TypeHandle intersect23 = T.Intersect(type2, type3); |
| 1761 TypeHandle union1_23 = T.Union(type1, intersect23); | 1862 TypeHandle union1_23 = T.Union(type1, intersect23); |
| 1762 TypeHandle intersect12_13 = T.Intersect(union12, union13); | 1863 TypeHandle intersect12_13 = T.Intersect(union12, union13); |
| 1763 CHECK(Equal(union1_23, intersect12_13)); | 1864 CHECK(Equal(union1_23, intersect12_13)); |
| 1764 } | 1865 } |
| 1765 } | 1866 } |
| 1766 } | 1867 } |
| 1767 } | 1868 */ |
| 1768 | 1869 |
| 1769 void Distributivity2() { | |
| 1770 // Distributivity: | |
| 1771 // Intersect(T1, Union(T2, T3)) = Union(Intersect(T1, T2), Intersect(T1,T3)) | 1870 // Intersect(T1, Union(T2, T3)) = Union(Intersect(T1, T2), Intersect(T1,T3)) |
| 1871 // This does NOT hold. | |
| 1872 /* | |
| 1772 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { | 1873 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { |
| 1773 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { | 1874 for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { |
| 1774 for (TypeIterator it3 = T.types.begin(); it3 != T.types.end(); ++it3) { | 1875 for (TypeIterator it3 = T.types.begin(); it3 != T.types.end(); ++it3) { |
| 1775 TypeHandle type1 = *it1; | 1876 TypeHandle type1 = *it1; |
| 1776 TypeHandle type2 = *it2; | 1877 TypeHandle type2 = *it2; |
| 1777 TypeHandle type3 = *it3; | 1878 TypeHandle type3 = *it3; |
| 1778 TypeHandle intersect12 = T.Intersect(type1, type2); | 1879 TypeHandle intersect12 = T.Intersect(type1, type2); |
| 1779 TypeHandle intersect13 = T.Intersect(type1, type3); | 1880 TypeHandle intersect13 = T.Intersect(type1, type3); |
| 1780 TypeHandle union23 = T.Union(type2, type3); | 1881 TypeHandle union23 = T.Union(type2, type3); |
| 1781 TypeHandle intersect1_23 = T.Intersect(type1, union23); | 1882 TypeHandle intersect1_23 = T.Intersect(type1, union23); |
| 1782 TypeHandle union12_13 = T.Union(intersect12, intersect13); | 1883 TypeHandle union12_13 = T.Union(intersect12, intersect13); |
| 1783 CHECK(Equal(intersect1_23, union12_13)); | 1884 CHECK(Equal(intersect1_23, union12_13)); |
| 1784 } | 1885 } |
| 1785 } | 1886 } |
| 1786 } | 1887 } |
| 1888 */ | |
| 1787 } | 1889 } |
| 1788 | 1890 |
| 1789 template<class Type2, class TypeHandle2, class Region2, class Rep2> | 1891 template<class Type2, class TypeHandle2, class Region2, class Rep2> |
| 1790 void Convert() { | 1892 void Convert() { |
| 1791 Types<Type2, TypeHandle2, Region2> T2( | 1893 Types<Type2, TypeHandle2, Region2> T2( |
| 1792 Rep2::ToRegion(&zone, isolate), isolate); | 1894 Rep2::ToRegion(&zone, isolate), isolate); |
| 1793 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { | 1895 for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { |
| 1794 TypeHandle type1 = *it; | 1896 TypeHandle type1 = *it; |
| 1795 TypeHandle2 type2 = T2.template Convert<Type>(type1); | 1897 TypeHandle2 type2 = T2.template Convert<Type>(type1); |
| 1796 TypeHandle type3 = T.template Convert<Type2>(type2); | 1898 TypeHandle type3 = T.template Convert<Type2>(type2); |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 1808 CHECK(!type1->Is(type2) || htype1.IsSubtypeOf(htype2)); | 1910 CHECK(!type1->Is(type2) || htype1.IsSubtypeOf(htype2)); |
| 1809 } | 1911 } |
| 1810 } | 1912 } |
| 1811 } | 1913 } |
| 1812 }; | 1914 }; |
| 1813 | 1915 |
| 1814 typedef Tests<Type, Type*, Zone, ZoneRep> ZoneTests; | 1916 typedef Tests<Type, Type*, Zone, ZoneRep> ZoneTests; |
| 1815 typedef Tests<HeapType, Handle<HeapType>, Isolate, HeapRep> HeapTests; | 1917 typedef Tests<HeapType, Handle<HeapType>, Isolate, HeapRep> HeapTests; |
| 1816 | 1918 |
| 1817 | 1919 |
| 1920 TEST(IsSomeType) { | |
| 1921 CcTest::InitializeVM(); | |
| 1922 ZoneTests().IsSomeType(); | |
| 1923 HeapTests().IsSomeType(); | |
| 1924 } | |
| 1925 | |
| 1926 | |
| 1818 TEST(BitsetType) { | 1927 TEST(BitsetType) { |
| 1819 CcTest::InitializeVM(); | 1928 CcTest::InitializeVM(); |
| 1820 ZoneTests().Bitset(); | 1929 ZoneTests().Bitset(); |
| 1821 HeapTests().Bitset(); | 1930 HeapTests().Bitset(); |
| 1822 } | 1931 } |
| 1823 | 1932 |
| 1824 | 1933 |
| 1825 TEST(ClassType) { | 1934 TEST(ClassType) { |
| 1826 CcTest::InitializeVM(); | 1935 CcTest::InitializeVM(); |
| 1827 ZoneTests().Class(); | 1936 ZoneTests().Class(); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1864 } | 1973 } |
| 1865 | 1974 |
| 1866 | 1975 |
| 1867 TEST(NowOf) { | 1976 TEST(NowOf) { |
| 1868 CcTest::InitializeVM(); | 1977 CcTest::InitializeVM(); |
| 1869 ZoneTests().NowOf(); | 1978 ZoneTests().NowOf(); |
| 1870 HeapTests().NowOf(); | 1979 HeapTests().NowOf(); |
| 1871 } | 1980 } |
| 1872 | 1981 |
| 1873 | 1982 |
| 1874 TEST(Bounds) { | 1983 TEST(BitsetGlb) { |
| 1875 CcTest::InitializeVM(); | 1984 CcTest::InitializeVM(); |
| 1876 ZoneTests().Bounds(); | 1985 ZoneTests().BitsetGlb(); |
| 1877 HeapTests().Bounds(); | 1986 HeapTests().BitsetGlb(); |
| 1878 } | 1987 } |
| 1879 | 1988 |
| 1880 | 1989 |
| 1990 TEST(BitsetLub) { | |
| 1991 CcTest::InitializeVM(); | |
| 1992 ZoneTests().BitsetLub(); | |
| 1993 HeapTests().BitsetLub(); | |
| 1994 } | |
| 1995 | |
| 1996 | |
| 1881 TEST(Is) { | 1997 TEST(Is) { |
| 1882 CcTest::InitializeVM(); | 1998 CcTest::InitializeVM(); |
| 1883 ZoneTests().Is(); | 1999 ZoneTests().Is(); |
| 1884 HeapTests().Is(); | 2000 HeapTests().Is(); |
| 1885 } | 2001 } |
| 1886 | 2002 |
| 1887 | 2003 |
| 1888 TEST(NowIs) { | 2004 TEST(NowIs) { |
| 1889 CcTest::InitializeVM(); | 2005 CcTest::InitializeVM(); |
| 1890 ZoneTests().NowIs(); | 2006 ZoneTests().NowIs(); |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 1906 } | 2022 } |
| 1907 | 2023 |
| 1908 | 2024 |
| 1909 TEST(Maybe) { | 2025 TEST(Maybe) { |
| 1910 CcTest::InitializeVM(); | 2026 CcTest::InitializeVM(); |
| 1911 ZoneTests().Maybe(); | 2027 ZoneTests().Maybe(); |
| 1912 HeapTests().Maybe(); | 2028 HeapTests().Maybe(); |
| 1913 } | 2029 } |
| 1914 | 2030 |
| 1915 | 2031 |
| 1916 // TODO(rossberg): make me faster! | |
| 1917 #if 0 | |
| 1918 TEST(Union1) { | 2032 TEST(Union1) { |
| 1919 CcTest::InitializeVM(); | 2033 CcTest::InitializeVM(); |
| 1920 ZoneTests().Union1(); | 2034 ZoneTests().Union1(); |
| 1921 HeapTests().Union1(); | 2035 HeapTests().Union1(); |
| 1922 } | 2036 } |
| 1923 | 2037 |
| 1924 | 2038 |
| 2039 /* | |
| 1925 TEST(Union2) { | 2040 TEST(Union2) { |
| 1926 CcTest::InitializeVM(); | 2041 CcTest::InitializeVM(); |
| 1927 ZoneTests().Union2(); | 2042 ZoneTests().Union2(); |
| 1928 HeapTests().Union2(); | 2043 HeapTests().Union2(); |
| 1929 } | 2044 } |
| 2045 */ | |
| 1930 | 2046 |
| 1931 | 2047 |
| 1932 TEST(Intersect1) { | 2048 TEST(Union3) { |
| 1933 CcTest::InitializeVM(); | 2049 CcTest::InitializeVM(); |
| 1934 ZoneTests().Intersect1(); | 2050 ZoneTests().Union3(); |
| 1935 HeapTests().Intersect1(); | 2051 HeapTests().Union3(); |
| 1936 } | 2052 } |
| 1937 | 2053 |
| 1938 | 2054 |
| 1939 TEST(Intersect2) { | 2055 TEST(Union4) { |
| 1940 CcTest::InitializeVM(); | 2056 CcTest::InitializeVM(); |
| 1941 ZoneTests().Intersect2(); | 2057 ZoneTests().Union4(); |
| 1942 HeapTests().Intersect2(); | 2058 HeapTests().Union4(); |
| 1943 } | 2059 } |
| 1944 | 2060 |
| 1945 | 2061 |
| 1946 TEST(Distributivity1) { | 2062 TEST(Intersect) { |
| 1947 CcTest::InitializeVM(); | 2063 CcTest::InitializeVM(); |
| 1948 ZoneTests().Distributivity1(); | 2064 ZoneTests().Intersect(); |
| 1949 HeapTests().Distributivity1(); | 2065 HeapTests().Intersect(); |
| 1950 } | 2066 } |
| 1951 | 2067 |
| 1952 | 2068 |
| 1953 TEST(Distributivity2) { | 2069 /* |
| 2070 TEST(Distributivity) { | |
| 1954 CcTest::InitializeVM(); | 2071 CcTest::InitializeVM(); |
| 1955 ZoneTests().Distributivity2(); | 2072 ZoneTests().Distributivity(); |
| 1956 HeapTests().Distributivity2(); | 2073 HeapTests().Distributivity(); |
| 1957 } | 2074 } |
| 1958 #endif // TODO(rossberg): make me faster | 2075 */ |
| 2076 | |
| 1959 | 2077 |
| 1960 TEST(Convert) { | 2078 TEST(Convert) { |
| 1961 CcTest::InitializeVM(); | 2079 CcTest::InitializeVM(); |
| 1962 ZoneTests().Convert<HeapType, Handle<HeapType>, Isolate, HeapRep>(); | 2080 ZoneTests().Convert<HeapType, Handle<HeapType>, Isolate, HeapRep>(); |
| 1963 HeapTests().Convert<Type, Type*, Zone, ZoneRep>(); | 2081 HeapTests().Convert<Type, Type*, Zone, ZoneRep>(); |
| 1964 } | 2082 } |
| 1965 | 2083 |
| 1966 | 2084 |
| 1967 TEST(HTypeFromType) { | 2085 TEST(HTypeFromType) { |
| 1968 CcTest::InitializeVM(); | 2086 CcTest::InitializeVM(); |
| 1969 ZoneTests().HTypeFromType(); | 2087 ZoneTests().HTypeFromType(); |
| 1970 HeapTests().HTypeFromType(); | 2088 HeapTests().HTypeFromType(); |
| 1971 } | 2089 } |
| OLD | NEW |