Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(870)

Unified Diff: src/types.h

Issue 18415005: Introduce type Bounds record (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/hydrogen.cc ('k') | src/typing.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/types.h
diff --git a/src/types.h b/src/types.h
index 31aa9512f4c3a44433412fc836df800ea5efe524..cd3c920642596e32f588a354dea1997d507ff20c 100644
--- a/src/types.h
+++ b/src/types.h
@@ -274,6 +274,40 @@ class Type : public Object {
Handle<Unioned> unioned, Handle<Type> type, int current_size);
};
+
+// A simple struct to represent a pair of lower/upper type bounds.
+struct Bounds {
+ Handle<Type> lower;
+ Handle<Type> upper;
+
+ Bounds() {}
+ Bounds(Handle<Type> l, Handle<Type> u) : lower(l), upper(u) {}
+ Bounds(Type* l, Type* u, Isolate* isl) : lower(l, isl), upper(u, isl) {}
+ explicit Bounds(Handle<Type> t) : lower(t), upper(t) {}
+ Bounds(Type* t, Isolate* isl) : lower(t, isl), upper(t, isl) {}
+
+ // Meet: both b1 and b2 are known to hold.
+ static Bounds Both(Bounds b1, Bounds b2, Isolate* isl) {
+ return Bounds(
+ handle(Type::Union(b1.lower, b2.lower), isl),
+ handle(Type::Intersect(b1.upper, b2.upper), isl));
+ }
+
+ // Join: either b1 or b2 is known to hold.
+ static Bounds Either(Bounds b1, Bounds b2, Isolate* isl) {
+ return Bounds(
+ handle(Type::Intersect(b1.lower, b2.lower), isl),
+ handle(Type::Union(b1.upper, b2.upper), isl));
+ }
+
+ static Bounds NarrowLower(Bounds b, Handle<Type> t, Isolate* isl) {
+ return Bounds(handle(Type::Union(b.lower, t), isl), b.upper);
+ }
+ static Bounds NarrowUpper(Bounds b, Handle<Type> t, Isolate* isl) {
+ return Bounds(b.lower, handle(Type::Intersect(b.upper, t), isl));
+ }
+};
+
} } // namespace v8::internal
#endif // V8_TYPES_H_
« no previous file with comments | « src/hydrogen.cc ('k') | src/typing.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698