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

Unified Diff: test/cctest/test-types.cc

Issue 658743002: Refine typing of addition, subtraction, multiplication, and division. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rangify (unions of) constants to get monotonicity. Created 6 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 | « test/cctest/compiler/test-typer.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-types.cc
diff --git a/test/cctest/test-types.cc b/test/cctest/test-types.cc
index 86a8d4ee40dbf8bea93ffbcae139299d37205043..fdf5a0a9822d2c0704999141328c389a0c7e4b19 100644
--- a/test/cctest/test-types.cc
+++ b/test/cctest/test-types.cc
@@ -159,6 +159,10 @@ class Types {
if (!IsMinusZero(x)) integers.push_back(isolate->factory()->NewNumber(x));
}
+ Integer = Type::Range(
+ isolate->factory()->NewNumber(-V8_INFINITY),
+ isolate->factory()->NewNumber(-V8_INFINITY), region);
+
NumberArray = Type::Array(Number, region);
StringArray = Type::Array(String, region);
AnyArray = Type::Array(Any, region);
@@ -189,6 +193,8 @@ class Types {
BITSET_TYPE_LIST(DECLARE_TYPE)
#undef DECLARE_TYPE
+ TypeHandle Integer;
+
TypeHandle ObjectClass;
TypeHandle ArrayClass;
TypeHandle NumberClass;
@@ -653,6 +659,21 @@ struct Tests : Rep {
}
}
}
+
+ // Weakening:
+ // 1.) Range(x,y)->Is(Range(x,y)->Weaken())
+ // 2.) Range(x,y)->Weaken()->IsRange() iff Range(x,y)->Maybe(OtherNumber)
+ for (ValueIterator i = T.integers.begin(); i != T.integers.end(); ++i) {
+ for (ValueIterator j = T.integers.begin(); j != T.integers.end(); ++j) {
+ i::Handle<i::Object> min = *i;
+ i::Handle<i::Object> max = *j;
+ if (min->Number() > max->Number()) std::swap(min, max);
+ typename Type::RangeType* range = T.Range(min, max)->AsRange();
+ CHECK(range->Is(range->Weaken(T.region())));
+ CHECK(range->Weaken(T.region())->IsRange() ==
+ range->Maybe(T.OtherNumber));
+ }
+ }
}
void Context() {
@@ -867,6 +888,8 @@ struct Tests : Rep {
}
void MinMax() {
+ Factory* fac = isolate->factory();
+
// If b is regular numeric bitset, then Range(b->Min(), b->Max())->Is(b).
// TODO(neis): Need to ignore representation for this to be true.
/*
@@ -885,8 +908,7 @@ struct Tests : Rep {
// If b is regular numeric bitset, then b->Min() and b->Max() are integers.
for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) {
TypeHandle type = *it;
- if (this->IsBitset(type) && type->Is(T.Number) &&
- !type->Is(T.None) && !type->Is(T.NaN)) {
+ if (this->IsBitset(type) && type->Is(T.Number) && !type->Is(T.NaN)) {
CHECK(IsInteger(type->Min()) && IsInteger(type->Max()));
}
}
@@ -914,6 +936,16 @@ struct Tests : Rep {
CHECK(lub->Min() <= type->Min() && type->Max() <= lub->Max());
}
}
+
+ // Rangification: If T->Is(Range(-inf,+inf)) and !T->Is(None), then
+ // T->Is(Range(T->Min(), T->Max())).
+ for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) {
+ TypeHandle type = *it;
+ CHECK(
+ !(type->Is(T.Integer) && !type->Is(T.None)) ||
+ type->Is(T.Range(
+ fac->NewNumber(type->Min()), fac->NewNumber(type->Max()))));
+ }
}
void BitsetGlb() {
« no previous file with comments | « test/cctest/compiler/test-typer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698