| 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 4162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4173 | 4173 |
| 4174 static Object* Runtime_NumberToJSInt32(Arguments args) { | 4174 static Object* Runtime_NumberToJSInt32(Arguments args) { |
| 4175 NoHandleAllocation ha; | 4175 NoHandleAllocation ha; |
| 4176 ASSERT(args.length() == 1); | 4176 ASSERT(args.length() == 1); |
| 4177 | 4177 |
| 4178 CONVERT_DOUBLE_CHECKED(number, args[0]); | 4178 CONVERT_DOUBLE_CHECKED(number, args[0]); |
| 4179 | 4179 |
| 4180 // We do not include 0 so that we don't have to treat +0 / -0 cases. | 4180 // We do not include 0 so that we don't have to treat +0 / -0 cases. |
| 4181 if (number > 0 && number <= Smi::kMaxValue) { | 4181 if (number > 0 && number <= Smi::kMaxValue) { |
| 4182 return Smi::FromInt(static_cast<int>(number)); | 4182 return Smi::FromInt(static_cast<int>(number)); |
| 4183 } | 4183 } |
| 4184 return Heap::NumberFromInt32(DoubleToInt32(number)); | 4184 return Heap::NumberFromInt32(DoubleToInt32(number)); |
| 4185 } | 4185 } |
| 4186 | 4186 |
| 4187 | 4187 |
| 4188 // Converts a Number to a Smi, if possible. Returns NaN if the number is not | 4188 // Converts a Number to a Smi, if possible. Returns NaN if the number is not |
| 4189 // a small integer. | 4189 // a small integer. |
| 4190 static Object* Runtime_NumberToSmi(Arguments args) { | 4190 static Object* Runtime_NumberToSmi(Arguments args) { |
| 4191 NoHandleAllocation ha; | 4191 NoHandleAllocation ha; |
| 4192 ASSERT(args.length() == 1); | 4192 ASSERT(args.length() == 1); |
| 4193 | 4193 |
| (...skipping 4137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8331 } else { | 8331 } else { |
| 8332 // Handle last resort GC and make sure to allow future allocations | 8332 // Handle last resort GC and make sure to allow future allocations |
| 8333 // to grow the heap without causing GCs (if possible). | 8333 // to grow the heap without causing GCs (if possible). |
| 8334 Counters::gc_last_resort_from_js.Increment(); | 8334 Counters::gc_last_resort_from_js.Increment(); |
| 8335 Heap::CollectAllGarbage(false); | 8335 Heap::CollectAllGarbage(false); |
| 8336 } | 8336 } |
| 8337 } | 8337 } |
| 8338 | 8338 |
| 8339 | 8339 |
| 8340 } } // namespace v8::internal | 8340 } } // namespace v8::internal |
| OLD | NEW |