Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 147 var n = args[i] / max; | 147 var n = args[i] / max; |
| 148 var summand = n * n - compensation; | 148 var summand = n * n - compensation; |
| 149 var preliminary = sum + summand; | 149 var preliminary = sum + summand; |
| 150 compensation = (preliminary - sum) - summand; | 150 compensation = (preliminary - sum) - summand; |
| 151 sum = preliminary; | 151 sum = preliminary; |
| 152 } | 152 } |
| 153 return MathSqrt(sum) * max; | 153 return MathSqrt(sum) * max; |
| 154 } | 154 } |
| 155 | 155 |
| 156 | 156 |
| 157 function MathClz32(x) { | |
|
Sven Panne
2014/02/18 07:21:24
What TC39 seems to intend is basically exposing so
| |
| 158 x = ToUint32(TO_NUMBER_INLINE(x)); | |
| 159 if (x == 0) return 32; | |
| 160 var result = 0; | |
| 161 // Binary search. | |
| 162 if ((x & 0xFFFF0000) === 0) { x <<= 16; result += 16; }; | |
| 163 if ((x & 0xFF000000) === 0) { x <<= 8; result += 8; }; | |
| 164 if ((x & 0xF0000000) === 0) { x <<= 4; result += 4; }; | |
| 165 if ((x & 0xC0000000) === 0) { x <<= 2; result += 2; }; | |
| 166 if ((x & 0x80000000) === 0) { x <<= 1; result += 1; }; | |
| 167 return result; | |
| 168 } | |
| 169 | |
| 170 | |
| 157 function ExtendMath() { | 171 function ExtendMath() { |
| 158 %CheckIsBootstrapping(); | 172 %CheckIsBootstrapping(); |
| 159 | 173 |
| 160 // Set up the non-enumerable functions on the Math object. | 174 // Set up the non-enumerable functions on the Math object. |
| 161 InstallFunctions($Math, DONT_ENUM, $Array( | 175 InstallFunctions($Math, DONT_ENUM, $Array( |
| 162 "sign", MathSign, | 176 "sign", MathSign, |
| 163 "trunc", MathTrunc, | 177 "trunc", MathTrunc, |
| 164 "sinh", MathSinh, | 178 "sinh", MathSinh, |
| 165 "cosh", MathCosh, | 179 "cosh", MathCosh, |
| 166 "tanh", MathTanh, | 180 "tanh", MathTanh, |
| 167 "asinh", MathAsinh, | 181 "asinh", MathAsinh, |
| 168 "acosh", MathAcosh, | 182 "acosh", MathAcosh, |
| 169 "atanh", MathAtanh, | 183 "atanh", MathAtanh, |
| 170 "log10", MathLog10, | 184 "log10", MathLog10, |
| 171 "log2", MathLog2, | 185 "log2", MathLog2, |
| 172 "hypot", MathHypot | 186 "hypot", MathHypot, |
| 187 "clz32", MathClz32 | |
| 173 )); | 188 )); |
| 174 } | 189 } |
| 175 | 190 |
| 191 | |
| 176 ExtendMath(); | 192 ExtendMath(); |
| OLD | NEW |