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

Unified Diff: src/types.h

Issue 26959004: Ensure lower <= upper bound (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 2 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 | « no previous file | src/types.cc » ('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 80772d841af3b06c057bab9d13d976f9d634e12c..5d437e26b243654691102507ca6a6986f2e46fad 100644
--- a/src/types.h
+++ b/src/types.h
@@ -226,6 +226,7 @@ class Type : public Object {
kUnusedEOL = 0
};
+ bool is_none() { return this == None(); }
bool is_bitset() { return this->IsSmi(); }
bool is_class() { return this->IsMap(); }
bool is_constant() { return this->IsBox(); }
@@ -299,10 +300,18 @@ struct Bounds {
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) {}
+ Bounds(Handle<Type> l, Handle<Type> u) : lower(l), upper(u) {
+ ASSERT(lower->Is(upper));
+ }
+ Bounds(Type* l, Type* u, Isolate* isl) : lower(l, isl), upper(u, isl) {
+ ASSERT(lower->Is(upper));
+ }
+ explicit Bounds(Handle<Type> t) : lower(t), upper(t) {
+ ASSERT(lower->Is(upper));
+ }
+ Bounds(Type* t, Isolate* isl) : lower(t, isl), upper(t, isl) {
+ ASSERT(lower->Is(upper));
+ }
// Unrestricted bounds.
static Bounds Unbounded(Isolate* isl) {
@@ -311,9 +320,11 @@ struct Bounds {
// 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));
+ Handle<Type> lower(Type::Union(b1.lower, b2.lower), isl);
+ Handle<Type> upper(Type::Intersect(b1.upper, b2.upper), isl);
+ // Lower bounds are considered approximate, correct as necessary.
+ lower = handle(Type::Intersect(lower, upper), isl);
+ return Bounds(lower, upper);
}
// Join: either b1 or b2 is known to hold.
@@ -324,10 +335,14 @@ struct Bounds {
}
static Bounds NarrowLower(Bounds b, Handle<Type> t, Isolate* isl) {
+ // Lower bounds are considered approximate, correct as necessary.
+ t = handle(Type::Intersect(t, b.upper), 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));
+ return Bounds(
+ handle(Type::Intersect(b.lower, t), isl),
+ handle(Type::Intersect(b.upper, t), isl));
}
};
« no previous file with comments | « no previous file | src/types.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698