| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 if (length == 0) { | 121 if (length == 0) { |
| 122 return -1/0; // Compiler constant-folds this to -Infinity. | 122 return -1/0; // Compiler constant-folds this to -Infinity. |
| 123 } | 123 } |
| 124 var r = arg1; | 124 var r = arg1; |
| 125 if (!IS_NUMBER(r)) r = ToNumber(r); | 125 if (!IS_NUMBER(r)) r = ToNumber(r); |
| 126 if (NUMBER_IS_NAN(r)) return r; | 126 if (NUMBER_IS_NAN(r)) return r; |
| 127 for (var i = 1; i < length; i++) { | 127 for (var i = 1; i < length; i++) { |
| 128 var n = %_Arguments(i); | 128 var n = %_Arguments(i); |
| 129 if (!IS_NUMBER(n)) n = ToNumber(n); | 129 if (!IS_NUMBER(n)) n = ToNumber(n); |
| 130 if (NUMBER_IS_NAN(n)) return n; | 130 if (NUMBER_IS_NAN(n)) return n; |
| 131 // Make sure +0 is considered greater than -0. | 131 // Make sure +0 is considered greater than -0. -0 is never a Smi, +0 can be |
| 132 if (n > r || (r === 0 && n === 0 && !%_IsSmi(r))) r = n; | 132 // a Smi or heap number. |
| 133 if (n > r || (r === 0 && n === 0 && !%_IsSmi(r) && 1 / r < 0)) r = n; |
| 133 } | 134 } |
| 134 return r; | 135 return r; |
| 135 } | 136 } |
| 136 | 137 |
| 137 // ECMA 262 - 15.8.2.12 | 138 // ECMA 262 - 15.8.2.12 |
| 138 function MathMin(arg1, arg2) { // length == 2 | 139 function MathMin(arg1, arg2) { // length == 2 |
| 139 var length = %_ArgumentsLength(); | 140 var length = %_ArgumentsLength(); |
| 140 if (length == 0) { | 141 if (length == 0) { |
| 141 return 1/0; // Compiler constant-folds this to Infinity. | 142 return 1/0; // Compiler constant-folds this to Infinity. |
| 142 } | 143 } |
| 143 var r = arg1; | 144 var r = arg1; |
| 144 if (!IS_NUMBER(r)) r = ToNumber(r); | 145 if (!IS_NUMBER(r)) r = ToNumber(r); |
| 145 if (NUMBER_IS_NAN(r)) return r; | 146 if (NUMBER_IS_NAN(r)) return r; |
| 146 for (var i = 1; i < length; i++) { | 147 for (var i = 1; i < length; i++) { |
| 147 var n = %_Arguments(i); | 148 var n = %_Arguments(i); |
| 148 if (!IS_NUMBER(n)) n = ToNumber(n); | 149 if (!IS_NUMBER(n)) n = ToNumber(n); |
| 149 if (NUMBER_IS_NAN(n)) return n; | 150 if (NUMBER_IS_NAN(n)) return n; |
| 150 // Make sure -0 is considered less than +0. | 151 // Make sure -0 is considered less than +0. -0 is never a Smi, +0 can b a |
| 151 if (n < r || (r === 0 && n === 0 && !%_IsSmi(n))) r = n; | 152 // Smi or a heap number. |
| 153 if (n < r || (r === 0 && n === 0 && !%_IsSmi(n) && 1 / n < 0)) r = n; |
| 152 } | 154 } |
| 153 return r; | 155 return r; |
| 154 } | 156 } |
| 155 | 157 |
| 156 // ECMA 262 - 15.8.2.13 | 158 // ECMA 262 - 15.8.2.13 |
| 157 function MathPow(x, y) { | 159 function MathPow(x, y) { |
| 158 if (!IS_NUMBER(x)) x = ToNumber(x); | 160 if (!IS_NUMBER(x)) x = ToNumber(x); |
| 159 if (!IS_NUMBER(y)) y = ToNumber(y); | 161 if (!IS_NUMBER(y)) y = ToNumber(y); |
| 160 return %Math_pow(x, y); | 162 return %Math_pow(x, y); |
| 161 } | 163 } |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 "tan", MathTan, | 254 "tan", MathTan, |
| 253 "atan2", MathAtan2, | 255 "atan2", MathAtan2, |
| 254 "pow", MathPow, | 256 "pow", MathPow, |
| 255 "max", MathMax, | 257 "max", MathMax, |
| 256 "min", MathMin | 258 "min", MathMin |
| 257 )); | 259 )); |
| 258 }; | 260 }; |
| 259 | 261 |
| 260 | 262 |
| 261 SetupMath(); | 263 SetupMath(); |
| OLD | NEW |