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

Unified Diff: src/types.h

Issue 1328193003: Construct Range rather than Constant when typing integers. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix typo. Created 5 years, 3 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') | 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 84fbe38776aa29cd94d60aef3e6066b2e02150de..67a8550d9146d2e0d880b76976d41ab2252567f2 100644
--- a/src/types.h
+++ b/src/types.h
@@ -95,10 +95,13 @@ namespace internal {
// RANGE TYPES
//
// A range type represents a continuous integer interval by its minimum and
-// maximum value. Either value might be an infinity.
+// maximum value. Either value may be an infinity, in which case that infinity
+// itself is also included in the range. A range never contains NaN or -0.
//
-// Constant(v) is considered a subtype of Range(x..y) if v happens to be an
-// integer between x and y.
+// If a value v happens to be an integer n, then Constant(v) is considered a
+// subtype of Range(n, n) (and therefore also a subtype of any larger range).
+// In order to avoid large unions, however, it is usually a good idea to use
+// Range rather than Constant.
//
//
// PREDICATES
@@ -513,11 +516,17 @@ class TypeImpl : public Config::Base {
double Min();
double Max();
- // Extracts a range from the type. If the type is a range, it just
- // returns it; if it is a union, it returns the range component.
- // Note that it does not contain range for constants.
+ // Extracts a range from the type: if the type is a range or a union
+ // containing a range, that range is returned; otherwise, NULL is returned.
RangeType* GetRange();
+ static bool IsInteger(double x) {
+ return nearbyint(x) == x && !i::IsMinusZero(x); // Allows for infinities.
+ }
+ static bool IsInteger(i::Object* x) {
+ return x->IsNumber() && IsInteger(x->Number());
+ }
+
int NumClasses();
int NumConstants();
@@ -589,13 +598,6 @@ class TypeImpl : public Config::Base {
bool SlowIs(TypeImpl* that);
bool SemanticIs(TypeImpl* that);
- static bool IsInteger(double x) {
- return nearbyint(x) == x && !i::IsMinusZero(x); // Allows for infinities.
- }
- static bool IsInteger(i::Object* x) {
- return x->IsNumber() && IsInteger(x->Number());
- }
-
struct Limits {
double min;
double max;
« no previous file with comments | « src/compiler/typer.cc ('k') | src/types.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698