| OLD | NEW |
| 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 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 4800 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4811 | 4811 |
| 4812 if (y == 0) { | 4812 if (y == 0) { |
| 4813 return Smi::FromInt(1); | 4813 return Smi::FromInt(1); |
| 4814 } else if (isnan(y) || ((x == 1 || x == -1) && isinf(y))) { | 4814 } else if (isnan(y) || ((x == 1 || x == -1) && isinf(y))) { |
| 4815 return Heap::nan_value(); | 4815 return Heap::nan_value(); |
| 4816 } else { | 4816 } else { |
| 4817 return Heap::AllocateHeapNumber(pow(x, y)); | 4817 return Heap::AllocateHeapNumber(pow(x, y)); |
| 4818 } | 4818 } |
| 4819 } | 4819 } |
| 4820 | 4820 |
| 4821 // Fast version of Math.pow if we know that y is not an integer and |
| 4822 // y is not -0.5 or 0.5. Used as slowcase from codegen. |
| 4823 static Object* Runtime_Math_pow_cfunction(Arguments args) { |
| 4824 NoHandleAllocation ha; |
| 4825 ASSERT(args.length() == 2); |
| 4826 CONVERT_DOUBLE_CHECKED(x, args[0]); |
| 4827 CONVERT_DOUBLE_CHECKED(y, args[1]); |
| 4828 if (y == 0) { |
| 4829 return Smi::FromInt(1); |
| 4830 } else if (isnan(y) || ((x == 1 || x == -1) && isinf(y))) { |
| 4831 return Heap::nan_value(); |
| 4832 } else { |
| 4833 return Heap::AllocateHeapNumber(pow(x, y)); |
| 4834 } |
| 4835 } |
| 4836 |
| 4821 | 4837 |
| 4822 static Object* Runtime_Math_round(Arguments args) { | 4838 static Object* Runtime_Math_round(Arguments args) { |
| 4823 NoHandleAllocation ha; | 4839 NoHandleAllocation ha; |
| 4824 ASSERT(args.length() == 1); | 4840 ASSERT(args.length() == 1); |
| 4825 Counters::math_round.Increment(); | 4841 Counters::math_round.Increment(); |
| 4826 | 4842 |
| 4827 CONVERT_DOUBLE_CHECKED(x, args[0]); | 4843 CONVERT_DOUBLE_CHECKED(x, args[0]); |
| 4828 if (signbit(x) && x >= -0.5) return Heap::minus_zero_value(); | 4844 if (signbit(x) && x >= -0.5) return Heap::minus_zero_value(); |
| 4829 double integer = ceil(x); | 4845 double integer = ceil(x); |
| 4830 if (integer - x > 0.5) { integer -= 1.0; } | 4846 if (integer - x > 0.5) { integer -= 1.0; } |
| (...skipping 3448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8279 } else { | 8295 } else { |
| 8280 // Handle last resort GC and make sure to allow future allocations | 8296 // Handle last resort GC and make sure to allow future allocations |
| 8281 // to grow the heap without causing GCs (if possible). | 8297 // to grow the heap without causing GCs (if possible). |
| 8282 Counters::gc_last_resort_from_js.Increment(); | 8298 Counters::gc_last_resort_from_js.Increment(); |
| 8283 Heap::CollectAllGarbage(false); | 8299 Heap::CollectAllGarbage(false); |
| 8284 } | 8300 } |
| 8285 } | 8301 } |
| 8286 | 8302 |
| 8287 | 8303 |
| 8288 } } // namespace v8::internal | 8304 } } // namespace v8::internal |
| OLD | NEW |