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

Unified Diff: src/compiler/typer.cc

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 | « no previous file | src/types.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/typer.cc
diff --git a/src/compiler/typer.cc b/src/compiler/typer.cc
index 594e4bd61369e5b0caa6830127ab211a698722ed..67246688105471cbeebef112054246f0f99c0617 100644
--- a/src/compiler/typer.cc
+++ b/src/compiler/typer.cc
@@ -48,6 +48,8 @@ Typer::Typer(Isolate* isolate, Graph* graph, Type::FunctionType* function_type)
Type* infinity = Type::Constant(factory->infinity_value(), zone);
Type* minus_infinity = Type::Constant(factory->minus_infinity_value(), zone);
+ // TODO(neis): Unfortunately, the infinities created in other places might
+ // be different ones (eg the result of NewNumber in TypeNumberConstant).
Type* truncating_to_zero =
Type::Union(Type::Union(infinity, minus_infinity, zone),
Type::MinusZeroOrNaN(), zone);
@@ -535,8 +537,11 @@ Bounds Typer::Visitor::TypeFloat64Constant(Node* node) {
Bounds Typer::Visitor::TypeNumberConstant(Node* node) {
Factory* f = isolate()->factory();
- return Bounds(Type::Constant(
- f->NewNumber(OpParameter<double>(node)), zone()));
+ double number = OpParameter<double>(node);
+ if (Type::IsInteger(number)) {
+ return Bounds(Type::Range(number, number, zone()));
+ }
+ return Bounds(Type::Constant(f->NewNumber(number), zone()));
}
@@ -2288,6 +2293,9 @@ Type* Typer::Visitor::TypeConstant(Handle<Object> value) {
#undef TYPED_ARRAY_CASE
}
}
+ if (Type::IsInteger(*value)) {
+ return Type::Range(value->Number(), value->Number(), zone());
+ }
return Type::Constant(value, zone());
}
« no previous file with comments | « no previous file | src/types.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698