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

Unified Diff: src/crankshaft/hydrogen.cc

Issue 2621903002: [crankshaft] Also inline Math.ceil. (Closed)
Patch Set: Created 3 years, 11 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/crankshaft/hydrogen.cc
diff --git a/src/crankshaft/hydrogen.cc b/src/crankshaft/hydrogen.cc
index 2d0f755e4e3bf874ea2c3c8e01ec0d9ca85b18b3..b2c09d1e31d62d2421b72cb06c2a229ec1e05218 100644
--- a/src/crankshaft/hydrogen.cc
+++ b/src/crankshaft/hydrogen.cc
@@ -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();
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698