Index: src/compiler/js-builtin-reducer.cc |
diff --git a/src/compiler/js-builtin-reducer.cc b/src/compiler/js-builtin-reducer.cc |
index 3023031c2f4f82f0a923652cd47198bae98fd512..7be3a50ed07f95dbef8a1bc534e562afd003c48f 100644 |
--- a/src/compiler/js-builtin-reducer.cc |
+++ b/src/compiler/js-builtin-reducer.cc |
@@ -168,6 +168,17 @@ Reduction JSBuiltinReducer::ReduceMathRound(Node* node) { |
return NoChange(); |
} |
+// ES6 section 20.2.2.32 Math.sqrt ( x ) |
+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(); |
+} |
+ |
Reduction JSBuiltinReducer::Reduce(Node* node) { |
Reduction reduction = NoChange(); |
JSCallReduction r(node); |
@@ -187,6 +198,9 @@ Reduction JSBuiltinReducer::Reduce(Node* node) { |
case kMathRound: |
reduction = ReduceMathRound(node); |
break; |
+ case kMathSqrt: |
+ reduction = ReduceMathSqrt(node); |
+ break; |
default: |
break; |
} |