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(); |