Index: src/compiler/js-builtin-reducer.cc |
diff --git a/src/compiler/js-builtin-reducer.cc b/src/compiler/js-builtin-reducer.cc |
index c7a2326254fcde55a150d552746b747c887152ef..b5caf9f1fe6ecc3824a487de3359f76bc038d6a4 100644 |
--- a/src/compiler/js-builtin-reducer.cc |
+++ b/src/compiler/js-builtin-reducer.cc |
@@ -129,7 +129,7 @@ Reduction JSBuiltinReducer::ReduceMathImul(Node* node) { |
return NoChange(); |
} |
-// ES6 draft 08-24-14, section 20.2.2.16. |
+// ES6 section 20.2.2.10 Math.ceil ( x ) |
Reduction JSBuiltinReducer::ReduceMathCeil(Node* node) { |
JSCallReduction r(node); |
if (r.InputsMatchOne(Type::Number())) { |
@@ -140,6 +140,24 @@ Reduction JSBuiltinReducer::ReduceMathCeil(Node* node) { |
return NoChange(); |
} |
+// ES6 section 20.2.2.11 Math.clz32 ( x ) |
+Reduction JSBuiltinReducer::ReduceMathClz32(Node* node) { |
+ JSCallReduction r(node); |
+ if (r.InputsMatchOne(Type::Unsigned32())) { |
+ // Math.clz32(a:unsigned32) -> NumberClz32(a) |
+ Node* value = graph()->NewNode(simplified()->NumberClz32(), r.left()); |
+ return Replace(value); |
+ } |
+ if (r.InputsMatchOne(Type::Number())) { |
+ // Math.clz32(a:number) -> NumberClz32(NumberToUint32(a)) |
+ Node* value = graph()->NewNode( |
+ simplified()->NumberClz32(), |
+ graph()->NewNode(simplified()->NumberToUint32(), r.left())); |
+ return Replace(value); |
+ } |
+ return NoChange(); |
+} |
+ |
// ES6 draft 08-24-14, section 20.2.2.16. |
Reduction JSBuiltinReducer::ReduceMathFloor(Node* node) { |
JSCallReduction r(node); |
@@ -209,6 +227,9 @@ Reduction JSBuiltinReducer::Reduce(Node* node) { |
case kMathImul: |
reduction = ReduceMathImul(node); |
break; |
+ case kMathClz32: |
+ reduction = ReduceMathClz32(node); |
+ break; |
case kMathCeil: |
reduction = ReduceMathCeil(node); |
break; |