Index: src/compiler/js-builtin-reducer.cc |
diff --git a/src/compiler/js-builtin-reducer.cc b/src/compiler/js-builtin-reducer.cc |
index 83161e14a5d5388582c23fa9a4617725a371aaa6..c57ac331defc84611a30732cefea7cb0ae348863 100644 |
--- a/src/compiler/js-builtin-reducer.cc |
+++ b/src/compiler/js-builtin-reducer.cc |
@@ -95,6 +95,18 @@ class JSCallReduction { |
}; |
+// ECMA-262, section 15.8.2.17. |
+Reduction JSBuiltinReducer::ReduceMathSqrt(Node* node) { |
+ JSCallReduction r(node); |
+ if (r.InputsMatchOne(Type::Number())) { |
+ // Math.sqrt(a:number) -> Float64Sqrt(a) |
+ Node* value = graph()->NewNode(machine()->Float64Sqrt(), r.left()); |
+ return Replace(value); |
+ } |
+ return NoChange(); |
+} |
+ |
+ |
// ECMA-262, section 15.8.2.11. |
Reduction JSBuiltinReducer::ReduceMathMax(Node* node) { |
JSCallReduction r(node); |
@@ -145,6 +157,8 @@ Reduction JSBuiltinReducer::Reduce(Node* node) { |
// Dispatch according to the BuiltinFunctionId if present. |
if (!r.HasBuiltinFunctionId()) return NoChange(); |
switch (r.GetBuiltinFunctionId()) { |
+ case kMathSqrt: |
+ return ReplaceWithPureReduction(node, ReduceMathSqrt(node)); |
case kMathMax: |
return ReplaceWithPureReduction(node, ReduceMathMax(node)); |
case kMathImul: |