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

Unified Diff: src/compiler/typer.cc

Issue 602693002: Give more precise types to some Math functions. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 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.h ('k') | no next file » | 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 bfecdef61e9b5f80413d3a0c653cd0d9e5c9ba81..b6349c9e010f02a3fe9b8e33e50b5589cf7e6a0f 100644
--- a/src/compiler/typer.cc
+++ b/src/compiler/typer.cc
@@ -15,16 +15,26 @@ namespace internal {
namespace compiler {
Typer::Typer(Zone* zone) : zone_(zone) {
- Type* number = Type::Number(zone);
- Type* signed32 = Type::Signed32(zone);
- Type* unsigned32 = Type::Unsigned32(zone);
- Type* integral32 = Type::Integral32(zone);
- Type* object = Type::Object(zone);
- Type* undefined = Type::Undefined(zone);
+ Factory* f = zone->isolate()->factory();
+
+ Type* number = Type::Number();
+ Type* signed32 = Type::Signed32();
+ Type* unsigned32 = Type::Unsigned32();
+ Type* integral32 = Type::Integral32();
+ Type* object = Type::Object();
+ Type* undefined = Type::Undefined();
+ Type* weakint = Type::Union(
+ Type::Range(f->NewNumber(-V8_INFINITY), f->NewNumber(+V8_INFINITY), zone),
+ Type::Union(Type::NaN(), Type::MinusZero(), zone), zone);
+
number_fun0_ = Type::Function(number, zone);
number_fun1_ = Type::Function(number, number, zone);
number_fun2_ = Type::Function(number, number, number, zone);
+ weakint_fun1_ = Type::Function(weakint, number, zone);
imul_fun_ = Type::Function(signed32, integral32, integral32, zone);
+ random_fun_ = Type::Function(Type::Union(
+ Type::UnsignedSmall(), Type::OtherNumber(), zone), zone);
+
#define NATIVE_TYPE(sem, rep) \
Type::Intersect(Type::sem(zone), Type::rep(zone), zone)
@@ -834,13 +844,13 @@ Type* Typer::Visitor::TypeConstant(Handle<Object> value) {
} else if (*value == native->math_atan2_fun()) {
return typer_->number_fun2_;
} else if (*value == native->math_ceil_fun()) {
- return typer_->number_fun1_;
+ return typer_->weakint_fun1_;
} else if (*value == native->math_cos_fun()) {
return typer_->number_fun1_;
} else if (*value == native->math_exp_fun()) {
return typer_->number_fun1_;
} else if (*value == native->math_floor_fun()) {
- return typer_->number_fun1_;
+ return typer_->weakint_fun1_;
} else if (*value == native->math_imul_fun()) {
return typer_->imul_fun_;
} else if (*value == native->math_log_fun()) {
@@ -848,9 +858,9 @@ Type* Typer::Visitor::TypeConstant(Handle<Object> value) {
} else if (*value == native->math_pow_fun()) {
return typer_->number_fun2_;
} else if (*value == native->math_random_fun()) {
- return typer_->number_fun0_;
+ return typer_->random_fun_;
} else if (*value == native->math_round_fun()) {
- return typer_->number_fun1_;
+ return typer_->weakint_fun1_;
} else if (*value == native->math_sin_fun()) {
return typer_->number_fun1_;
} else if (*value == native->math_sqrt_fun()) {
« no previous file with comments | « src/compiler/typer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698