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

Unified Diff: src/types.h

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 | « src/compiler/typer.cc ('k') | test/cctest/compiler/test-typer.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 8490cbb2ed1ecb74493d8f9d20cc8bc9f7443af9..bd96ddefce08f4935b9ddb4788b761bb259b47d1 100644
--- a/src/types.h
+++ b/src/types.h
@@ -787,6 +787,7 @@ class TypeImpl<Config>::RangeType : public StructuralType {
static RangeHandle New(
i::Handle<i::Object> min, i::Handle<i::Object> max, Region* region) {
+ DCHECK(IsInteger(min->Number()) && IsInteger(max->Number()));
DCHECK(min->Number() <= max->Number());
RangeHandle type = Config::template cast<RangeType>(
StructuralType::New(StructuralType::kRangeTag, 3, region));
@@ -801,6 +802,18 @@ class TypeImpl<Config>::RangeType : public StructuralType {
return New(lim.min, lim.max, region);
}
+ // Returns the least integers-only supertype that's not a range. If there is
+ // no such supertype, it returns Range(-inf, +inf) instead.
+ TypeHandle Weaken(Region* region) {
+ bitset lub = this->BitsetLub();
+ if (BitsetType::Is(SEMANTIC(BitsetType::kOtherNumber), lub)) {
+ return New(
+ Config::factory(region)->NewNumber(-V8_INFINITY),
+ Config::factory(region)->NewNumber(+V8_INFINITY), region);
+ }
+ return BitsetType::New(lub, region);
+ }
+
static RangeType* cast(TypeImpl* type) {
DCHECK(type->IsRange());
return static_cast<RangeType*>(type);
@@ -947,6 +960,10 @@ struct ZoneTypeConfig {
static inline i::Handle<V> struct_get_value(Struct* structure, int i);
template<class V> static inline void struct_set_value(
Struct* structure, int i, i::Handle<V> x);
+
+ static inline Factory* factory(Zone* zone) {
+ return zone->isolate()->factory();
+ }
};
typedef TypeImpl<ZoneTypeConfig> Type;
@@ -995,6 +1012,10 @@ struct HeapTypeConfig {
template<class V>
static inline void struct_set_value(
i::Handle<Struct> structure, int i, i::Handle<V> x);
+
+ static inline Factory* factory(Isolate* isolate) {
+ return isolate->factory();
+ }
};
typedef TypeImpl<HeapTypeConfig> HeapType;
« no previous file with comments | « src/compiler/typer.cc ('k') | test/cctest/compiler/test-typer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698