Commit 3072ac53 authored by bmeurer's avatar bmeurer Committed by Commit bot

[turbofan] More inlinable Math builtins.

Turn Math.acos, Math.asin, Math.atan, Math.atan2, Math.sign and Math.trunc
into inlinable builtins.

R=yangguo@chromium.org
BUG=v8:3952
LOG=n

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

Cr-Commit-Position: refs/heads/master@{#27336}
parent 877c99f7
......@@ -1536,6 +1536,10 @@ Bounds Typer::Visitor::TypeJSCallRuntime(Node* node) {
case Runtime::kInlineConstructDouble:
case Runtime::kInlineMathFloor:
case Runtime::kInlineMathSqrt:
case Runtime::kInlineMathAcos:
case Runtime::kInlineMathAsin:
case Runtime::kInlineMathAtan:
case Runtime::kInlineMathAtan2:
return Bounds(Type::None(zone()), Type::Number());
case Runtime::kInlineMathClz32:
return Bounds(Type::None(), Type::Range(0, 32, zone()));
......
......@@ -30,24 +30,26 @@ function MathAbs(x) {
// ECMA 262 - 15.8.2.2
function MathAcosJS(x) {
return %MathAcos(TO_NUMBER_INLINE(x));
return %_MathAcos(+x);
}
// ECMA 262 - 15.8.2.3
function MathAsinJS(x) {
return %MathAsin(TO_NUMBER_INLINE(x));
return %_MathAsin(+x);
}
// ECMA 262 - 15.8.2.4
function MathAtanJS(x) {
return %MathAtan(TO_NUMBER_INLINE(x));
return %_MathAtan(+x);
}
// ECMA 262 - 15.8.2.5
// The naming of y and x matches the spec, as does the order in which
// ToNumber (valueOf) is called.
function MathAtan2JS(y, x) {
return %MathAtan2(TO_NUMBER_INLINE(y), TO_NUMBER_INLINE(x));
y = +y;
x = +x;
return %_MathAtan2(y, x);
}
// ECMA 262 - 15.8.2.6
......@@ -157,7 +159,7 @@ function MathImul(x, y) {
// ES6 draft 09-27-13, section 20.2.2.28.
function MathSign(x) {
x = TO_NUMBER_INLINE(x);
x = +x;
if (x > 0) return 1;
if (x < 0) return -1;
// -0, 0 or NaN.
......@@ -166,9 +168,9 @@ function MathSign(x) {
// ES6 draft 09-27-13, section 20.2.2.34.
function MathTrunc(x) {
x = TO_NUMBER_INLINE(x);
if (x > 0) return MathFloorJS(x);
if (x < 0) return MathCeil(x);
x = +x;
if (x > 0) return %_MathFloor(x);
if (x < 0) return -%_MathFloor(-x);
// -0, 0 or NaN.
return x;
}
......@@ -341,11 +343,17 @@ InstallFunctions(Math, DONT_ENUM, GlobalArray(
));
%SetInlineBuiltinFlag(MathAbs);
%SetInlineBuiltinFlag(MathAcosJS);
%SetInlineBuiltinFlag(MathAsinJS);
%SetInlineBuiltinFlag(MathAtanJS);
%SetInlineBuiltinFlag(MathAtan2JS);
%SetInlineBuiltinFlag(MathCeil);
%SetInlineBuiltinFlag(MathClz32JS);
%SetInlineBuiltinFlag(MathFloorJS);
%SetInlineBuiltinFlag(MathRandom);
%SetInlineBuiltinFlag(MathSign);
%SetInlineBuiltinFlag(MathSqrtJS);
%SetInlineBuiltinFlag(MathTrunc);
// Expose to the global scope.
$abs = MathAbs;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment