| 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 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 // - no field is a union | 219 // - no field is a union |
| 220 typedef FixedArray Unioned; | 220 typedef FixedArray Unioned; |
| 221 | 221 |
| 222 enum { | 222 enum { |
| 223 #define DECLARE_TYPE(type, value) k##type = (value), | 223 #define DECLARE_TYPE(type, value) k##type = (value), |
| 224 TYPE_LIST(DECLARE_TYPE) | 224 TYPE_LIST(DECLARE_TYPE) |
| 225 #undef DECLARE_TYPE | 225 #undef DECLARE_TYPE |
| 226 kUnusedEOL = 0 | 226 kUnusedEOL = 0 |
| 227 }; | 227 }; |
| 228 | 228 |
| 229 bool is_none() { return this == None(); } |
| 229 bool is_bitset() { return this->IsSmi(); } | 230 bool is_bitset() { return this->IsSmi(); } |
| 230 bool is_class() { return this->IsMap(); } | 231 bool is_class() { return this->IsMap(); } |
| 231 bool is_constant() { return this->IsBox(); } | 232 bool is_constant() { return this->IsBox(); } |
| 232 bool is_union() { return this->IsFixedArray(); } | 233 bool is_union() { return this->IsFixedArray(); } |
| 233 | 234 |
| 234 bool SlowIs(Type* that); | 235 bool SlowIs(Type* that); |
| 235 | 236 |
| 236 int as_bitset() { return Smi::cast(this)->value(); } | 237 int as_bitset() { return Smi::cast(this)->value(); } |
| 237 Handle<Map> as_class() { return Handle<Map>::cast(handle()); } | 238 Handle<Map> as_class() { return Handle<Map>::cast(handle()); } |
| 238 Handle<v8::internal::Object> as_constant() { | 239 Handle<v8::internal::Object> as_constant() { |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 } | 293 } |
| 293 }; | 294 }; |
| 294 | 295 |
| 295 | 296 |
| 296 // A simple struct to represent a pair of lower/upper type bounds. | 297 // A simple struct to represent a pair of lower/upper type bounds. |
| 297 struct Bounds { | 298 struct Bounds { |
| 298 Handle<Type> lower; | 299 Handle<Type> lower; |
| 299 Handle<Type> upper; | 300 Handle<Type> upper; |
| 300 | 301 |
| 301 Bounds() {} | 302 Bounds() {} |
| 302 Bounds(Handle<Type> l, Handle<Type> u) : lower(l), upper(u) {} | 303 Bounds(Handle<Type> l, Handle<Type> u) : lower(l), upper(u) { |
| 303 Bounds(Type* l, Type* u, Isolate* isl) : lower(l, isl), upper(u, isl) {} | 304 ASSERT(lower->Is(upper)); |
| 304 explicit Bounds(Handle<Type> t) : lower(t), upper(t) {} | 305 } |
| 305 Bounds(Type* t, Isolate* isl) : lower(t, isl), upper(t, isl) {} | 306 Bounds(Type* l, Type* u, Isolate* isl) : lower(l, isl), upper(u, isl) { |
| 307 ASSERT(lower->Is(upper)); |
| 308 } |
| 309 explicit Bounds(Handle<Type> t) : lower(t), upper(t) { |
| 310 ASSERT(lower->Is(upper)); |
| 311 } |
| 312 Bounds(Type* t, Isolate* isl) : lower(t, isl), upper(t, isl) { |
| 313 ASSERT(lower->Is(upper)); |
| 314 } |
| 306 | 315 |
| 307 // Unrestricted bounds. | 316 // Unrestricted bounds. |
| 308 static Bounds Unbounded(Isolate* isl) { | 317 static Bounds Unbounded(Isolate* isl) { |
| 309 return Bounds(Type::None(), Type::Any(), isl); | 318 return Bounds(Type::None(), Type::Any(), isl); |
| 310 } | 319 } |
| 311 | 320 |
| 312 // Meet: both b1 and b2 are known to hold. | 321 // Meet: both b1 and b2 are known to hold. |
| 313 static Bounds Both(Bounds b1, Bounds b2, Isolate* isl) { | 322 static Bounds Both(Bounds b1, Bounds b2, Isolate* isl) { |
| 314 return Bounds( | 323 Handle<Type> lower(Type::Union(b1.lower, b2.lower), isl); |
| 315 handle(Type::Union(b1.lower, b2.lower), isl), | 324 Handle<Type> upper(Type::Intersect(b1.upper, b2.upper), isl); |
| 316 handle(Type::Intersect(b1.upper, b2.upper), isl)); | 325 // Lower bounds are considered approximate, correct as necessary. |
| 326 lower = handle(Type::Intersect(lower, upper), isl); |
| 327 return Bounds(lower, upper); |
| 317 } | 328 } |
| 318 | 329 |
| 319 // Join: either b1 or b2 is known to hold. | 330 // Join: either b1 or b2 is known to hold. |
| 320 static Bounds Either(Bounds b1, Bounds b2, Isolate* isl) { | 331 static Bounds Either(Bounds b1, Bounds b2, Isolate* isl) { |
| 321 return Bounds( | 332 return Bounds( |
| 322 handle(Type::Intersect(b1.lower, b2.lower), isl), | 333 handle(Type::Intersect(b1.lower, b2.lower), isl), |
| 323 handle(Type::Union(b1.upper, b2.upper), isl)); | 334 handle(Type::Union(b1.upper, b2.upper), isl)); |
| 324 } | 335 } |
| 325 | 336 |
| 326 static Bounds NarrowLower(Bounds b, Handle<Type> t, Isolate* isl) { | 337 static Bounds NarrowLower(Bounds b, Handle<Type> t, Isolate* isl) { |
| 338 // Lower bounds are considered approximate, correct as necessary. |
| 339 t = handle(Type::Intersect(t, b.upper), isl); |
| 327 return Bounds(handle(Type::Union(b.lower, t), isl), b.upper); | 340 return Bounds(handle(Type::Union(b.lower, t), isl), b.upper); |
| 328 } | 341 } |
| 329 static Bounds NarrowUpper(Bounds b, Handle<Type> t, Isolate* isl) { | 342 static Bounds NarrowUpper(Bounds b, Handle<Type> t, Isolate* isl) { |
| 330 return Bounds(b.lower, handle(Type::Intersect(b.upper, t), isl)); | 343 return Bounds( |
| 344 handle(Type::Intersect(b.lower, t), isl), |
| 345 handle(Type::Intersect(b.upper, t), isl)); |
| 331 } | 346 } |
| 332 }; | 347 }; |
| 333 | 348 |
| 334 } } // namespace v8::internal | 349 } } // namespace v8::internal |
| 335 | 350 |
| 336 #endif // V8_TYPES_H_ | 351 #endif // V8_TYPES_H_ |
| OLD | NEW |