Give simple types to Math.Min, Math.Max, Math.Fround, Math.Clz32.

R=rossberg@chromium.org
BUG=

Review URL: https://codereview.chromium.org/657793002

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@24640 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
neis@chromium.org 2014-10-15 14:12:20 +00:00
parent 4f9fd83d85
commit a6f06b4d1f
2 changed files with 33 additions and 22 deletions

View File

@ -65,6 +65,8 @@ Typer::Typer(Graph* graph, MaybeHandle<Context> context)
number_fun2_ = Type::Function(number, number, number, zone);
weakint_fun1_ = Type::Function(weakint, number, zone);
imul_fun_ = Type::Function(signed32, integral32, integral32, zone);
clz32_fun_ = Type::Function(
Type::Range(zero, f->NewNumber(32), zone), number, zone);
random_fun_ = Type::Function(Type::Union(
Type::UnsignedSmall(), Type::OtherNumber(), zone), zone);
@ -1554,8 +1556,34 @@ Type* Typer::Visitor::TypeConstant(Handle<Object> value) {
if (value->IsJSFunction()) {
if (JSFunction::cast(*value)->shared()->HasBuiltinFunctionId()) {
switch (JSFunction::cast(*value)->shared()->builtin_function_id()) {
// TODO(rossberg): can't express overloading
case kMathRandom:
return typer_->random_fun_;
case kMathFloor:
return typer_->weakint_fun1_;
case kMathRound:
return typer_->weakint_fun1_;
case kMathCeil:
return typer_->weakint_fun1_;
case kMathAbs:
// TODO(rossberg): can't express overloading
return typer_->number_fun1_;
case kMathLog:
return typer_->number_fun1_;
case kMathExp:
return typer_->number_fun1_;
case kMathSqrt:
return typer_->number_fun1_;
case kMathPow:
return typer_->number_fun2_;
case kMathMax:
return typer_->number_fun2_;
case kMathMin:
return typer_->number_fun2_;
case kMathCos:
return typer_->number_fun1_;
case kMathSin:
return typer_->number_fun1_;
case kMathTan:
return typer_->number_fun1_;
case kMathAcos:
return typer_->number_fun1_;
@ -1565,29 +1593,11 @@ Type* Typer::Visitor::TypeConstant(Handle<Object> value) {
return typer_->number_fun1_;
case kMathAtan2:
return typer_->number_fun2_;
case kMathCeil:
return typer_->weakint_fun1_;
case kMathCos:
return typer_->number_fun1_;
case kMathExp:
return typer_->number_fun1_;
case kMathFloor:
return typer_->weakint_fun1_;
case kMathImul:
return typer_->imul_fun_;
case kMathLog:
return typer_->number_fun1_;
case kMathPow:
return typer_->number_fun2_;
case kMathRandom:
return typer_->random_fun_;
case kMathRound:
return typer_->weakint_fun1_;
case kMathSin:
return typer_->number_fun1_;
case kMathSqrt:
return typer_->number_fun1_;
case kMathTan:
case kMathClz32:
return typer_->clz32_fun_;
case kMathFround:
return typer_->number_fun1_;
default:
break;

View File

@ -56,6 +56,7 @@ class Typer {
Type* number_fun2_;
Type* weakint_fun1_;
Type* imul_fun_;
Type* clz32_fun_;
Type* random_fun_;
Type* array_buffer_fun_;
Type* int8_array_fun_;