Chromium Code Reviews| Index: src/harmony-math.js |
| diff --git a/src/harmony-math.js b/src/harmony-math.js |
| index ee426ef1191f417b2178b17581c1a516704ecaab..7b5883f8e93138301f1b5547baa6ad81460546e9 100644 |
| --- a/src/harmony-math.js |
| +++ b/src/harmony-math.js |
| @@ -154,6 +154,20 @@ function MathHypot(x, y) { // Function length is 2. |
| } |
| +function MathClz32(x) { |
|
Sven Panne
2014/02/18 07:21:24
What TC39 seems to intend is basically exposing so
|
| + x = ToUint32(TO_NUMBER_INLINE(x)); |
| + if (x == 0) return 32; |
| + var result = 0; |
| + // Binary search. |
| + if ((x & 0xFFFF0000) === 0) { x <<= 16; result += 16; }; |
| + if ((x & 0xFF000000) === 0) { x <<= 8; result += 8; }; |
| + if ((x & 0xF0000000) === 0) { x <<= 4; result += 4; }; |
| + if ((x & 0xC0000000) === 0) { x <<= 2; result += 2; }; |
| + if ((x & 0x80000000) === 0) { x <<= 1; result += 1; }; |
| + return result; |
| +} |
| + |
| + |
| function ExtendMath() { |
| %CheckIsBootstrapping(); |
| @@ -169,8 +183,10 @@ function ExtendMath() { |
| "atanh", MathAtanh, |
| "log10", MathLog10, |
| "log2", MathLog2, |
| - "hypot", MathHypot |
| + "hypot", MathHypot, |
| + "clz32", MathClz32 |
| )); |
| } |
| + |
| ExtendMath(); |