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 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 } | 267 } |
268 | 268 |
269 int LubBitset(); // least upper bound that's a bitset | 269 int LubBitset(); // least upper bound that's a bitset |
270 int GlbBitset(); // greatest lower bound that's a bitset | 270 int GlbBitset(); // greatest lower bound that's a bitset |
271 bool InUnion(Handle<Unioned> unioned, int current_size); | 271 bool InUnion(Handle<Unioned> unioned, int current_size); |
272 int ExtendUnion(Handle<Unioned> unioned, int current_size); | 272 int ExtendUnion(Handle<Unioned> unioned, int current_size); |
273 int ExtendIntersection( | 273 int ExtendIntersection( |
274 Handle<Unioned> unioned, Handle<Type> type, int current_size); | 274 Handle<Unioned> unioned, Handle<Type> type, int current_size); |
275 }; | 275 }; |
276 | 276 |
| 277 |
| 278 // A simple struct to represent a pair of lower/upper type bounds. |
| 279 struct Bounds { |
| 280 Handle<Type> lower; |
| 281 Handle<Type> upper; |
| 282 |
| 283 Bounds() {} |
| 284 Bounds(Handle<Type> l, Handle<Type> u) : lower(l), upper(u) {} |
| 285 Bounds(Type* l, Type* u, Isolate* isl) : lower(l, isl), upper(u, isl) {} |
| 286 explicit Bounds(Handle<Type> t) : lower(t), upper(t) {} |
| 287 Bounds(Type* t, Isolate* isl) : lower(t, isl), upper(t, isl) {} |
| 288 |
| 289 // Meet: both b1 and b2 are known to hold. |
| 290 static Bounds Both(Bounds b1, Bounds b2, Isolate* isl) { |
| 291 return Bounds( |
| 292 handle(Type::Union(b1.lower, b2.lower), isl), |
| 293 handle(Type::Intersect(b1.upper, b2.upper), isl)); |
| 294 } |
| 295 |
| 296 // Join: either b1 or b2 is known to hold. |
| 297 static Bounds Either(Bounds b1, Bounds b2, Isolate* isl) { |
| 298 return Bounds( |
| 299 handle(Type::Intersect(b1.lower, b2.lower), isl), |
| 300 handle(Type::Union(b1.upper, b2.upper), isl)); |
| 301 } |
| 302 |
| 303 static Bounds NarrowLower(Bounds b, Handle<Type> t, Isolate* isl) { |
| 304 return Bounds(handle(Type::Union(b.lower, t), isl), b.upper); |
| 305 } |
| 306 static Bounds NarrowUpper(Bounds b, Handle<Type> t, Isolate* isl) { |
| 307 return Bounds(b.lower, handle(Type::Intersect(b.upper, t), isl)); |
| 308 } |
| 309 }; |
| 310 |
277 } } // namespace v8::internal | 311 } } // namespace v8::internal |
278 | 312 |
279 #endif // V8_TYPES_H_ | 313 #endif // V8_TYPES_H_ |
OLD | NEW |