| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 V(NonNumber, kAny - kNumber) \ | 130 V(NonNumber, kAny - kNumber) \ |
| 131 V(Detectable, kAllocated - kUndetectable) | 131 V(Detectable, kAllocated - kUndetectable) |
| 132 | 132 |
| 133 | 133 |
| 134 // struct Config { | 134 // struct Config { |
| 135 // typedef Base; | 135 // typedef Base; |
| 136 // typedef Unioned; | 136 // typedef Unioned; |
| 137 // typedef Region; | 137 // typedef Region; |
| 138 // template<class> struct Handle { typedef type; } // No template typedefs... | 138 // template<class> struct Handle { typedef type; } // No template typedefs... |
| 139 // static Handle<Type>::type handle(Type* type); // !is_bitset(type) | 139 // static Handle<Type>::type handle(Type* type); // !is_bitset(type) |
| 140 // static bool is_bitset(Type* type); | 140 // static bool is_bitset(Type*); |
| 141 // static bool is_class(Type* type); | 141 // static bool is_class(Type*); |
| 142 // static bool is_constant(Type* type); | 142 // static bool is_constant(Type*); |
| 143 // static bool is_union(Type* type); | 143 // static bool is_union(Type*); |
| 144 // static int as_bitset(Type* type); | 144 // static int as_bitset(Type*); |
| 145 // static i::Handle<i::Map> as_class(Type* type); | 145 // static i::Handle<i::Map> as_class(Type*); |
| 146 // static i::Handle<i::Object> as_constant(Type* type); | 146 // static i::Handle<i::Object> as_constant(Type*); |
| 147 // static Handle<Unioned>::type as_union(Type* type); | 147 // static Handle<Unioned>::type as_union(Type*); |
| 148 // static Type* from_bitset(int bitset); | 148 // static Type* from_bitset(int bitset); |
| 149 // static Handle<Type>::type from_bitset(int bitset, Region* region); | 149 // static Handle<Type>::type from_bitset(int bitset, Region*); |
| 150 // static Handle<Type>::type from_class(i::Handle<i::Map> map, Region* region) | 150 // static Handle<Type>::type from_class(i::Handle<i::Map>, Region*) |
| 151 // static Handle<Type>::type from_constant( | 151 // static Handle<Type>::type from_constant(i::Handle<i::Object>, Region*); |
| 152 // i::Handle<i::Object> value, Region* region); | 152 // static Handle<Type>::type from_union(Handle<Unioned>::type); |
| 153 // static Handle<Type>::type from_union(Handle<Unioned>::T unioned); | 153 // static Handle<Unioned>::type union_create(int size, Region*); |
| 154 // static Handle<Unioned>::type union_create(int size, Region* region); | 154 // static void union_shrink(Handle<Unioned>::type, int size); |
| 155 // static Handle<Type>::type union_get(Handle<Unioned>::T unioned, int i); | 155 // static Handle<Type>::type union_get(Handle<Unioned>::type, int); |
| 156 // static void union_set(Handle<Unioned>::type, int, Handle<Type>::type); |
| 157 // static int union_length(Handle<Unioned>::type); |
| 156 // } | 158 // } |
| 157 template<class Config> | 159 template<class Config> |
| 158 class TypeImpl : public Config::Base { | 160 class TypeImpl : public Config::Base { |
| 159 public: | 161 public: |
| 160 typedef typename Config::template Handle<TypeImpl>::type TypeHandle; | 162 typedef typename Config::template Handle<TypeImpl>::type TypeHandle; |
| 161 typedef typename Config::Region Region; | 163 typedef typename Config::Region Region; |
| 162 | 164 |
| 163 #define DEFINE_TYPE_CONSTRUCTOR(type, value) \ | 165 #define DEFINE_TYPE_CONSTRUCTOR(type, value) \ |
| 164 static TypeImpl* type() { return Config::from_bitset(k##type); } \ | 166 static TypeImpl* type() { return Config::from_bitset(k##type); } \ |
| 165 static TypeHandle type(Region* region) { \ | 167 static TypeHandle type(Region* region) { \ |
| (...skipping 10 matching lines...) Expand all Loading... |
| 176 } | 178 } |
| 177 | 179 |
| 178 static TypeHandle Union(TypeHandle type1, TypeHandle type2, Region* reg); | 180 static TypeHandle Union(TypeHandle type1, TypeHandle type2, Region* reg); |
| 179 static TypeHandle Intersect(TypeHandle type1, TypeHandle type2, Region* reg); | 181 static TypeHandle Intersect(TypeHandle type1, TypeHandle type2, Region* reg); |
| 180 | 182 |
| 181 static TypeHandle Of(i::Handle<i::Object> value, Region* region) { | 183 static TypeHandle Of(i::Handle<i::Object> value, Region* region) { |
| 182 return Config::from_bitset(LubBitset(*value), region); | 184 return Config::from_bitset(LubBitset(*value), region); |
| 183 } | 185 } |
| 184 | 186 |
| 185 bool Is(TypeImpl* that) { return this == that || this->SlowIs(that); } | 187 bool Is(TypeImpl* that) { return this == that || this->SlowIs(that); } |
| 188 template<class TypeHandle> |
| 186 bool Is(TypeHandle that) { return this->Is(*that); } | 189 bool Is(TypeHandle that) { return this->Is(*that); } |
| 187 bool Maybe(TypeImpl* that); | 190 bool Maybe(TypeImpl* that); |
| 191 template<class TypeHandle> |
| 188 bool Maybe(TypeHandle that) { return this->Maybe(*that); } | 192 bool Maybe(TypeHandle that) { return this->Maybe(*that); } |
| 189 | 193 |
| 190 // State-dependent versions of Of and Is that consider subtyping between | 194 // State-dependent versions of Of and Is that consider subtyping between |
| 191 // a constant and its map class. | 195 // a constant and its map class. |
| 192 static TypeHandle OfCurrently(i::Handle<i::Object> value, Region* region); | 196 static TypeHandle OfCurrently(i::Handle<i::Object> value, Region* region); |
| 193 bool IsCurrently(TypeImpl* that); | 197 bool IsCurrently(TypeImpl* that); |
| 198 template<class TypeHandle> |
| 194 bool IsCurrently(TypeHandle that) { return this->IsCurrently(*that); } | 199 bool IsCurrently(TypeHandle that) { return this->IsCurrently(*that); } |
| 195 | 200 |
| 196 bool IsClass() { return Config::is_class(this); } | 201 bool IsClass() { return Config::is_class(this); } |
| 197 bool IsConstant() { return Config::is_constant(this); } | 202 bool IsConstant() { return Config::is_constant(this); } |
| 198 i::Handle<i::Map> AsClass() { return Config::as_class(this); } | 203 i::Handle<i::Map> AsClass() { return Config::as_class(this); } |
| 199 i::Handle<i::Object> AsConstant() { return Config::as_constant(this); } | 204 i::Handle<i::Object> AsConstant() { return Config::as_constant(this); } |
| 200 | 205 |
| 201 int NumClasses(); | 206 int NumClasses(); |
| 202 int NumConstants(); | 207 int NumConstants(); |
| 203 | 208 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 225 | 230 |
| 226 Iterator<i::Map> Classes() { | 231 Iterator<i::Map> Classes() { |
| 227 if (this->IsBitset()) return Iterator<i::Map>(); | 232 if (this->IsBitset()) return Iterator<i::Map>(); |
| 228 return Iterator<i::Map>(Config::handle(this)); | 233 return Iterator<i::Map>(Config::handle(this)); |
| 229 } | 234 } |
| 230 Iterator<i::Object> Constants() { | 235 Iterator<i::Object> Constants() { |
| 231 if (this->IsBitset()) return Iterator<i::Object>(); | 236 if (this->IsBitset()) return Iterator<i::Object>(); |
| 232 return Iterator<i::Object>(Config::handle(this)); | 237 return Iterator<i::Object>(Config::handle(this)); |
| 233 } | 238 } |
| 234 | 239 |
| 235 static TypeImpl* cast(i::Object* object) { | 240 static TypeImpl* cast(typename Config::Base* object) { |
| 236 TypeImpl* t = static_cast<TypeImpl*>(object); | 241 TypeImpl* t = static_cast<TypeImpl*>(object); |
| 237 ASSERT(t->IsBitset() || t->IsClass() || t->IsConstant() || t->IsUnion()); | 242 ASSERT(t->IsBitset() || t->IsClass() || t->IsConstant() || t->IsUnion()); |
| 238 return t; | 243 return t; |
| 239 } | 244 } |
| 240 | 245 |
| 246 template<class OtherTypeImpl> |
| 247 static TypeHandle Convert( |
| 248 typename OtherTypeImpl::TypeHandle type, Region* region); |
| 249 |
| 241 #ifdef OBJECT_PRINT | 250 #ifdef OBJECT_PRINT |
| 242 void TypePrint(); | 251 void TypePrint(); |
| 243 void TypePrint(FILE* out); | 252 void TypePrint(FILE* out); |
| 244 #endif | 253 #endif |
| 245 | 254 |
| 246 private: | 255 private: |
| 247 template<class> friend class Iterator; | 256 template<class> friend class Iterator; |
| 257 template<class> friend class TypeImpl; |
| 248 | 258 |
| 249 // A union is a fixed array containing types. Invariants: | 259 // A union is a fixed array containing types. Invariants: |
| 250 // - its length is at least 2 | 260 // - its length is at least 2 |
| 251 // - at most one field is a bitset, and it must go into index 0 | 261 // - at most one field is a bitset, and it must go into index 0 |
| 252 // - no field is a union | 262 // - no field is a union |
| 253 typedef typename Config::Unioned Unioned; | 263 typedef typename Config::Unioned Unioned; |
| 254 typedef typename Config::template Handle<Unioned>::type UnionedHandle; | 264 typedef typename Config::template Handle<Unioned>::type UnionedHandle; |
| 255 | 265 |
| 256 enum { | 266 enum { |
| 257 #define DECLARE_TYPE(type, value) k##type = (value), | 267 #define DECLARE_TYPE(type, value) k##type = (value), |
| 258 BITSET_TYPE_LIST(DECLARE_TYPE) | 268 BITSET_TYPE_LIST(DECLARE_TYPE) |
| 259 #undef DECLARE_TYPE | 269 #undef DECLARE_TYPE |
| 260 kUnusedEOL = 0 | 270 kUnusedEOL = 0 |
| 261 }; | 271 }; |
| 262 | 272 |
| 263 bool IsNone() { return this == None(); } | 273 bool IsNone() { return this == None(); } |
| 264 bool IsAny() { return this == Any(); } | 274 bool IsAny() { return this == Any(); } |
| 265 bool IsBitset() { return Config::is_bitset(this); } | 275 bool IsBitset() { return Config::is_bitset(this); } |
| 266 bool IsUnion() { return Config::is_union(this); } | 276 bool IsUnion() { return Config::is_union(this); } |
| 267 int AsBitset() { return Config::as_bitset(this); } | 277 int AsBitset() { return Config::as_bitset(this); } |
| 268 UnionedHandle AsUnion() { return Config::as_union(this); } | 278 UnionedHandle AsUnion() { return Config::as_union(this); } |
| 269 | 279 |
| 280 static int UnionLength(UnionedHandle unioned) { |
| 281 return Config::union_length(unioned); |
| 282 } |
| 283 static TypeHandle UnionGet(UnionedHandle unioned, int i) { |
| 284 return Config::union_get(unioned, i); |
| 285 } |
| 286 |
| 270 bool SlowIs(TypeImpl* that); | 287 bool SlowIs(TypeImpl* that); |
| 271 | 288 |
| 272 int LubBitset(); // least upper bound that's a bitset | 289 int LubBitset(); // least upper bound that's a bitset |
| 273 int GlbBitset(); // greatest lower bound that's a bitset | 290 int GlbBitset(); // greatest lower bound that's a bitset |
| 274 | 291 |
| 275 static int LubBitset(i::Object* value); | 292 static int LubBitset(i::Object* value); |
| 276 static int LubBitset(i::Map* map); | 293 static int LubBitset(i::Map* map); |
| 277 | 294 |
| 278 bool InUnion(UnionedHandle unioned, int current_size); | 295 bool InUnion(UnionedHandle unioned, int current_size); |
| 279 int ExtendUnion(UnionedHandle unioned, int current_size); | 296 static int ExtendUnion( |
| 280 int ExtendIntersection( | 297 UnionedHandle unioned, TypeHandle t, int current_size); |
| 281 UnionedHandle unioned, TypeHandle type, int current_size); | 298 static int ExtendIntersection( |
| 299 UnionedHandle unioned, TypeHandle t, TypeHandle other, int current_size); |
| 282 | 300 |
| 283 #ifdef OBJECT_PRINT | 301 #ifdef OBJECT_PRINT |
| 284 static const char* bitset_name(int bitset); | 302 static const char* bitset_name(int bitset); |
| 285 #endif | 303 #endif |
| 286 }; | 304 }; |
| 287 | 305 |
| 288 | 306 |
| 307 // Zone-allocated types are either (odd) integers to represent bitsets, or |
| 308 // (even) pointers to zone lists for everything else. The first slot of every |
| 309 // list is an explicit tag value to distinguish representation. |
| 310 struct ZoneTypeConfig { |
| 311 private: |
| 312 typedef i::ZoneList<void*> Tagged; |
| 313 |
| 314 enum Tag { |
| 315 kClassTag, |
| 316 kConstantTag, |
| 317 kUnionTag |
| 318 }; |
| 319 |
| 320 static Tagged* tagged_create(Tag tag, int size, Zone* zone) { |
| 321 Tagged* tagged = new(zone) Tagged(size + 1, zone); |
| 322 tagged->Add(reinterpret_cast<void*>(tag), zone); |
| 323 tagged->AddBlock(NULL, size, zone); |
| 324 return tagged; |
| 325 } |
| 326 static void tagged_shrink(Tagged* tagged, int size) { |
| 327 tagged->Rewind(size + 1); |
| 328 } |
| 329 static Tag tagged_tag(Tagged* tagged) { |
| 330 return static_cast<Tag>(reinterpret_cast<intptr_t>(tagged->at(0))); |
| 331 } |
| 332 template<class T> |
| 333 static T tagged_get(Tagged* tagged, int i) { |
| 334 return reinterpret_cast<T>(tagged->at(i + 1)); |
| 335 } |
| 336 template<class T> |
| 337 static void tagged_set(Tagged* tagged, int i, T value) { |
| 338 tagged->at(i + 1) = reinterpret_cast<T>(value); |
| 339 } |
| 340 static int tagged_length(Tagged* tagged) { |
| 341 return tagged->length() - 1; |
| 342 } |
| 343 |
| 344 public: |
| 345 typedef TypeImpl<ZoneTypeConfig> Type; |
| 346 class Base {}; |
| 347 typedef i::ZoneList<Type*> Unioned; |
| 348 typedef i::Zone Region; |
| 349 template<class T> struct Handle { typedef T* type; }; |
| 350 |
| 351 static Type* handle(Type* type) { return type; } |
| 352 |
| 353 static bool is(Type* type, Tag tag) { |
| 354 return is_tagged(type) && tagged_tag(as_tagged(type)) == tag; |
| 355 } |
| 356 |
| 357 static bool is_bitset(Type* type) { |
| 358 return reinterpret_cast<intptr_t>(type) & 1; |
| 359 } |
| 360 static bool is_tagged(Type* type) { return !is_bitset(type); } |
| 361 static bool is_class(Type* type) { return is(type, kClassTag); } |
| 362 static bool is_constant(Type* type) { return is(type, kConstantTag); } |
| 363 static bool is_union(Type* type) { return is(type, kUnionTag); } |
| 364 static bool tagged_is_union(Tagged* tagged) { |
| 365 return is(from_tagged(tagged), kUnionTag); |
| 366 } |
| 367 |
| 368 static int as_bitset(Type* type) { |
| 369 ASSERT(is_bitset(type)); |
| 370 return static_cast<int>(reinterpret_cast<intptr_t>(type) >> 1); |
| 371 } |
| 372 static Tagged* as_tagged(Type* type) { |
| 373 ASSERT(is_tagged(type)); |
| 374 return reinterpret_cast<Tagged*>(type); |
| 375 } |
| 376 static i::Handle<i::Map> as_class(Type* type) { |
| 377 ASSERT(is_class(type)); |
| 378 return i::Handle<i::Map>(tagged_get<i::Map**>(as_tagged(type), 0)); |
| 379 } |
| 380 static i::Handle<i::Object> as_constant(Type* type) { |
| 381 ASSERT(is_constant(type)); |
| 382 return i::Handle<i::Object>(tagged_get<i::Object**>(as_tagged(type), 0)); |
| 383 } |
| 384 static Unioned* as_union(Type* type) { |
| 385 ASSERT(is_union(type)); |
| 386 return tagged_as_union(as_tagged(type)); |
| 387 } |
| 388 static Unioned* tagged_as_union(Tagged* tagged) { |
| 389 ASSERT(tagged_is_union(tagged)); |
| 390 return reinterpret_cast<Unioned*>(tagged); |
| 391 } |
| 392 |
| 393 static Type* from_bitset(int bitset) { |
| 394 return reinterpret_cast<Type*>((bitset << 1) | 1); |
| 395 } |
| 396 static Type* from_bitset(int bitset, Zone* Zone) { |
| 397 return from_bitset(bitset); |
| 398 } |
| 399 static Type* from_tagged(Tagged* tagged) { |
| 400 return reinterpret_cast<Type*>(tagged); |
| 401 } |
| 402 static Type* from_class(i::Handle<i::Map> map, Zone* zone) { |
| 403 Tagged* tagged = tagged_create(kClassTag, 1, zone); |
| 404 tagged_set(tagged, 0, map.location()); |
| 405 return from_tagged(tagged); |
| 406 } |
| 407 static Type* from_constant(i::Handle<i::Object> value, Zone* zone) { |
| 408 Tagged* tagged = tagged_create(kConstantTag, 1, zone); |
| 409 tagged_set(tagged, 0, value.location()); |
| 410 return from_tagged(tagged); |
| 411 } |
| 412 static Type* from_union(Unioned* unioned) { |
| 413 return from_tagged(tagged_from_union(unioned)); |
| 414 } |
| 415 static Tagged* tagged_from_union(Unioned* unioned) { |
| 416 return reinterpret_cast<Tagged*>(unioned); |
| 417 } |
| 418 |
| 419 static Unioned* union_create(int size, Zone* zone) { |
| 420 return tagged_as_union(tagged_create(kUnionTag, size, zone)); |
| 421 } |
| 422 static void union_shrink(Unioned* unioned, int size) { |
| 423 tagged_shrink(tagged_from_union(unioned), size); |
| 424 } |
| 425 static Type* union_get(Unioned* unioned, int i) { |
| 426 Type* type = tagged_get<Type*>(tagged_from_union(unioned), i); |
| 427 ASSERT(!is_union(type)); |
| 428 return type; |
| 429 } |
| 430 static void union_set(Unioned* unioned, int i, Type* type) { |
| 431 ASSERT(!is_union(type)); |
| 432 tagged_set(tagged_from_union(unioned), i, type); |
| 433 } |
| 434 static int union_length(Unioned* unioned) { |
| 435 return tagged_length(tagged_from_union(unioned)); |
| 436 } |
| 437 }; |
| 438 |
| 439 |
| 440 // Heap-allocated types are either smis for bitsets, maps for classes, boxes for |
| 441 // constants, or fixed arrays for unions. |
| 289 struct HeapTypeConfig { | 442 struct HeapTypeConfig { |
| 290 typedef TypeImpl<HeapTypeConfig> Type; | 443 typedef TypeImpl<HeapTypeConfig> Type; |
| 291 typedef i::Object Base; | 444 typedef i::Object Base; |
| 292 typedef i::FixedArray Unioned; | 445 typedef i::FixedArray Unioned; |
| 293 typedef i::Isolate Region; | 446 typedef i::Isolate Region; |
| 294 template<class T> struct Handle { typedef i::Handle<T> type; }; | 447 template<class T> struct Handle { typedef i::Handle<T> type; }; |
| 295 | 448 |
| 296 static i::Handle<Type> handle(Type* type) { | 449 static i::Handle<Type> handle(Type* type) { |
| 297 return i::handle(type, i::HeapObject::cast(type)->GetIsolate()); | 450 return i::handle(type, i::HeapObject::cast(type)->GetIsolate()); |
| 298 } | 451 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 320 return Type::cast(i::Smi::FromInt(bitset)); | 473 return Type::cast(i::Smi::FromInt(bitset)); |
| 321 } | 474 } |
| 322 static i::Handle<Type> from_bitset(int bitset, Isolate* isolate) { | 475 static i::Handle<Type> from_bitset(int bitset, Isolate* isolate) { |
| 323 return i::handle(from_bitset(bitset), isolate); | 476 return i::handle(from_bitset(bitset), isolate); |
| 324 } | 477 } |
| 325 static i::Handle<Type> from_class(i::Handle<i::Map> map, Isolate* isolate) { | 478 static i::Handle<Type> from_class(i::Handle<i::Map> map, Isolate* isolate) { |
| 326 return i::Handle<Type>::cast(i::Handle<Object>::cast(map)); | 479 return i::Handle<Type>::cast(i::Handle<Object>::cast(map)); |
| 327 } | 480 } |
| 328 static i::Handle<Type> from_constant( | 481 static i::Handle<Type> from_constant( |
| 329 i::Handle<i::Object> value, Isolate* isolate) { | 482 i::Handle<i::Object> value, Isolate* isolate) { |
| 330 ASSERT(isolate || value->IsHeapObject()); | |
| 331 if (!isolate) isolate = i::HeapObject::cast(*value)->GetIsolate(); | |
| 332 i::Handle<Box> box = isolate->factory()->NewBox(value); | 483 i::Handle<Box> box = isolate->factory()->NewBox(value); |
| 333 return i::Handle<Type>::cast(i::Handle<Object>::cast(box)); | 484 return i::Handle<Type>::cast(i::Handle<Object>::cast(box)); |
| 334 } | 485 } |
| 335 static i::Handle<Type> from_union(i::Handle<Unioned> unioned) { | 486 static i::Handle<Type> from_union(i::Handle<Unioned> unioned) { |
| 336 return i::Handle<Type>::cast(i::Handle<Object>::cast(unioned)); | 487 return i::Handle<Type>::cast(i::Handle<Object>::cast(unioned)); |
| 337 } | 488 } |
| 338 | 489 |
| 339 static i::Handle<Unioned> union_create(int size, Isolate* isolate) { | 490 static i::Handle<Unioned> union_create(int size, Isolate* isolate) { |
| 340 return isolate->factory()->NewFixedArray(size); | 491 return isolate->factory()->NewFixedArray(size); |
| 341 } | 492 } |
| 493 static void union_shrink(i::Handle<Unioned> unioned, int size) { |
| 494 unioned->Shrink(size); |
| 495 } |
| 342 static i::Handle<Type> union_get(i::Handle<Unioned> unioned, int i) { | 496 static i::Handle<Type> union_get(i::Handle<Unioned> unioned, int i) { |
| 343 Type* type = static_cast<Type*>(unioned->get(i)); | 497 Type* type = static_cast<Type*>(unioned->get(i)); |
| 344 ASSERT(!is_union(type)); | 498 ASSERT(!is_union(type)); |
| 345 return i::handle(type, unioned->GetIsolate()); | 499 return i::handle(type, unioned->GetIsolate()); |
| 346 } | 500 } |
| 501 static void union_set( |
| 502 i::Handle<Unioned> unioned, int i, i::Handle<Type> type) { |
| 503 ASSERT(!is_union(*type)); |
| 504 unioned->set(i, *type); |
| 505 } |
| 506 static int union_length(i::Handle<Unioned> unioned) { |
| 507 return unioned->length(); |
| 508 } |
| 347 }; | 509 }; |
| 348 | 510 |
| 349 typedef TypeImpl<HeapTypeConfig> Type; | 511 typedef TypeImpl<ZoneTypeConfig> Type; |
| 512 typedef TypeImpl<HeapTypeConfig> HeapType; |
| 350 | 513 |
| 351 | 514 |
| 352 // A simple struct to represent a pair of lower/upper type bounds. | 515 // A simple struct to represent a pair of lower/upper type bounds. |
| 353 template<class Config> | 516 template<class Config> |
| 354 struct BoundsImpl { | 517 struct BoundsImpl { |
| 355 typedef TypeImpl<Config> Type; | 518 typedef TypeImpl<Config> Type; |
| 356 typedef typename Type::TypeHandle TypeHandle; | 519 typedef typename Type::TypeHandle TypeHandle; |
| 357 typedef typename Type::Region Region; | 520 typedef typename Type::Region Region; |
| 358 | 521 |
| 359 TypeHandle lower; | 522 TypeHandle lower; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 390 // Lower bounds are considered approximate, correct as necessary. | 553 // Lower bounds are considered approximate, correct as necessary. |
| 391 t = Type::Intersect(t, b.upper, region); | 554 t = Type::Intersect(t, b.upper, region); |
| 392 TypeHandle lower = Type::Union(b.lower, t, region); | 555 TypeHandle lower = Type::Union(b.lower, t, region); |
| 393 return BoundsImpl(lower, b.upper); | 556 return BoundsImpl(lower, b.upper); |
| 394 } | 557 } |
| 395 static BoundsImpl NarrowUpper(BoundsImpl b, TypeHandle t, Region* region) { | 558 static BoundsImpl NarrowUpper(BoundsImpl b, TypeHandle t, Region* region) { |
| 396 TypeHandle lower = Type::Intersect(b.lower, t, region); | 559 TypeHandle lower = Type::Intersect(b.lower, t, region); |
| 397 TypeHandle upper = Type::Intersect(b.upper, t, region); | 560 TypeHandle upper = Type::Intersect(b.upper, t, region); |
| 398 return BoundsImpl(lower, upper); | 561 return BoundsImpl(lower, upper); |
| 399 } | 562 } |
| 563 |
| 564 bool Narrows(BoundsImpl that) { |
| 565 return that.lower->Is(this->lower) && this->upper->Is(that.upper); |
| 566 } |
| 400 }; | 567 }; |
| 401 | 568 |
| 402 typedef BoundsImpl<HeapTypeConfig> Bounds; | 569 typedef BoundsImpl<ZoneTypeConfig> Bounds; |
| 403 | 570 |
| 404 | 571 |
| 405 } } // namespace v8::internal | 572 } } // namespace v8::internal |
| 406 | 573 |
| 407 #endif // V8_TYPES_H_ | 574 #endif // V8_TYPES_H_ |
| OLD | NEW |