Index: src/compiler/js-builtin-reducer.cc |
diff --git a/src/compiler/js-builtin-reducer.cc b/src/compiler/js-builtin-reducer.cc |
index d2759b5f5b7809bb5a723356b69cfd50cb2803c2..363ad9db4e8ed946858ce5b89c70338c9b9bdf67 100644 |
--- a/src/compiler/js-builtin-reducer.cc |
+++ b/src/compiler/js-builtin-reducer.cc |
@@ -259,6 +259,28 @@ Reduction JSBuiltinReducer::ReduceMathMin(Node* node) { |
return NoChange(); |
} |
+// ES6 section 20.2.2.23 Math.log2 ( x ) |
+Reduction JSBuiltinReducer::ReduceMathLog2(Node* node) { |
+ JSCallReduction r(node); |
+ if (r.InputsMatchOne(Type::Number())) { |
+ // Math.log2(a:number) -> NumberLog(a) |
+ Node* value = graph()->NewNode(simplified()->NumberLog2(), r.left()); |
+ return Replace(value); |
+ } |
+ return NoChange(); |
+} |
+ |
+// ES6 section 20.2.2.22 Math.log10 ( x ) |
+Reduction JSBuiltinReducer::ReduceMathLog10(Node* node) { |
+ JSCallReduction r(node); |
+ if (r.InputsMatchOne(Type::Number())) { |
+ // Math.log10(a:number) -> NumberLog10(a) |
+ Node* value = graph()->NewNode(simplified()->NumberLog10(), r.left()); |
+ return Replace(value); |
+ } |
+ return NoChange(); |
+} |
+ |
// ES6 section 20.2.2.28 Math.round ( x ) |
Reduction JSBuiltinReducer::ReduceMathRound(Node* node) { |
JSCallReduction r(node); |
@@ -341,6 +363,12 @@ Reduction JSBuiltinReducer::Reduce(Node* node) { |
case kMathLog1p: |
reduction = ReduceMathLog1p(node); |
break; |
+ case kMathLog2: |
+ reduction = ReduceMathLog2(node); |
+ break; |
+ case kMathLog10: |
+ reduction = ReduceMathLog10(node); |
+ break; |
case kMathMax: |
reduction = ReduceMathMax(node); |
break; |