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 4644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4655 } | 4655 } |
4656 } | 4656 } |
4657 | 4657 |
4658 | 4658 |
4659 static Object* Runtime_Math_round(Arguments args) { | 4659 static Object* Runtime_Math_round(Arguments args) { |
4660 NoHandleAllocation ha; | 4660 NoHandleAllocation ha; |
4661 ASSERT(args.length() == 1); | 4661 ASSERT(args.length() == 1); |
4662 | 4662 |
4663 CONVERT_DOUBLE_CHECKED(x, args[0]); | 4663 CONVERT_DOUBLE_CHECKED(x, args[0]); |
4664 if (signbit(x) && x >= -0.5) return Heap::minus_zero_value(); | 4664 if (signbit(x) && x >= -0.5) return Heap::minus_zero_value(); |
4665 return Heap::NumberFromDouble(floor(x + 0.5)); | 4665 double integer = ceil(x); |
| 4666 return Heap::NumberFromDouble(integer - x > 0.5 ? integer - 1.0 : integer); |
4666 } | 4667 } |
4667 | 4668 |
4668 | 4669 |
4669 static Object* Runtime_Math_sin(Arguments args) { | 4670 static Object* Runtime_Math_sin(Arguments args) { |
4670 NoHandleAllocation ha; | 4671 NoHandleAllocation ha; |
4671 ASSERT(args.length() == 1); | 4672 ASSERT(args.length() == 1); |
4672 | 4673 |
4673 CONVERT_DOUBLE_CHECKED(x, args[0]); | 4674 CONVERT_DOUBLE_CHECKED(x, args[0]); |
4674 return TranscendentalCache::Get(TranscendentalCache::SIN, x); | 4675 return TranscendentalCache::Get(TranscendentalCache::SIN, x); |
4675 } | 4676 } |
(...skipping 3490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8166 } else { | 8167 } else { |
8167 // Handle last resort GC and make sure to allow future allocations | 8168 // Handle last resort GC and make sure to allow future allocations |
8168 // to grow the heap without causing GCs (if possible). | 8169 // to grow the heap without causing GCs (if possible). |
8169 Counters::gc_last_resort_from_js.Increment(); | 8170 Counters::gc_last_resort_from_js.Increment(); |
8170 Heap::CollectAllGarbage(false); | 8171 Heap::CollectAllGarbage(false); |
8171 } | 8172 } |
8172 } | 8173 } |
8173 | 8174 |
8174 | 8175 |
8175 } } // namespace v8::internal | 8176 } } // namespace v8::internal |
OLD | NEW |