Commit a3859e48 authored by bmeurer's avatar bmeurer Committed by Commit bot

[crankshaft] Also inline Math.ceil.

Inline calls to Math.ceil(x) as -Math.floor(-x) via the existing fast
path in Crankshaft.

R=ishell@chromium.org
BUG=v8:5782

Review-Url: https://codereview.chromium.org/2621903002
Cr-Commit-Position: refs/heads/master@{#42161}
parent ca4d8136
......@@ -8366,6 +8366,23 @@ bool HOptimizedGraphBuilder::TryInlineBuiltinFunctionCall(Call* expr) {
return true;
}
break;
case kMathCeil:
if (expr->arguments()->length() == 1) {
// Math.ceil(x) = -Math.floor(-x)
HValue* minus_zero = Add<HConstant>(-0.0);
HValue* argument = Pop();
Drop(2); // Receiver and function.
argument = AddUncasted<HSub>(minus_zero, argument);
Add<HSimulate>(expr->id(), REMOVABLE_SIMULATE);
{
NoObservableSideEffectsScope scope(this);
argument = AddUncasted<HUnaryMathOperation>(argument, kMathFloor);
argument = AddUncasted<HSub>(minus_zero, argument);
}
ast_context()->ReturnValue(argument);
return true;
}
break;
case kMathImul:
if (expr->arguments()->length() == 2) {
HValue* right = Pop();
......@@ -8566,6 +8583,23 @@ bool HOptimizedGraphBuilder::TryInlineBuiltinMethodCall(
return true;
}
break;
case kMathCeil:
if (argument_count == 2) {
// Math.ceil(x) = -Math.floor(-x)
HValue* minus_zero = Add<HConstant>(-0.0);
HValue* argument = Pop();
Drop(2); // Receiver and function.
argument = AddUncasted<HSub>(minus_zero, argument);
Add<HSimulate>(ast_id, REMOVABLE_SIMULATE);
{
NoObservableSideEffectsScope scope(this);
argument = AddUncasted<HUnaryMathOperation>(argument, kMathFloor);
argument = AddUncasted<HSub>(minus_zero, argument);
}
ast_context()->ReturnValue(argument);
return true;
}
break;
case kMathPow:
if (argument_count == 3) {
HValue* right = Pop();
......
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