| 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 5171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5182 CONVERT_DOUBLE_CHECKED(number, args[0]); | 5182 CONVERT_DOUBLE_CHECKED(number, args[0]); |
| 5183 | 5183 |
| 5184 // We do not include 0 so that we don't have to treat +0 / -0 cases. | 5184 // We do not include 0 so that we don't have to treat +0 / -0 cases. |
| 5185 if (number > 0 && number <= Smi::kMaxValue) { | 5185 if (number > 0 && number <= Smi::kMaxValue) { |
| 5186 return Smi::FromInt(static_cast<int>(number)); | 5186 return Smi::FromInt(static_cast<int>(number)); |
| 5187 } | 5187 } |
| 5188 return Heap::NumberFromDouble(DoubleToInteger(number)); | 5188 return Heap::NumberFromDouble(DoubleToInteger(number)); |
| 5189 } | 5189 } |
| 5190 | 5190 |
| 5191 | 5191 |
| 5192 static Object* Runtime_NumberToIntegerMapMinusZero(Arguments args) { |
| 5193 NoHandleAllocation ha; |
| 5194 ASSERT(args.length() == 1); |
| 5195 |
| 5196 CONVERT_DOUBLE_CHECKED(number, args[0]); |
| 5197 |
| 5198 // We do not include 0 so that we don't have to treat +0 / -0 cases. |
| 5199 if (number > 0 && number <= Smi::kMaxValue) { |
| 5200 return Smi::FromInt(static_cast<int>(number)); |
| 5201 } |
| 5202 |
| 5203 double double_value = DoubleToInteger(number); |
| 5204 // Map both -0 and +0 to +0. |
| 5205 if (double_value == 0) double_value = 0; |
| 5206 |
| 5207 return Heap::NumberFromDouble(double_value); |
| 5208 } |
| 5209 |
| 5210 |
| 5192 static Object* Runtime_NumberToJSUint32(Arguments args) { | 5211 static Object* Runtime_NumberToJSUint32(Arguments args) { |
| 5193 NoHandleAllocation ha; | 5212 NoHandleAllocation ha; |
| 5194 ASSERT(args.length() == 1); | 5213 ASSERT(args.length() == 1); |
| 5195 | 5214 |
| 5196 CONVERT_NUMBER_CHECKED(int32_t, number, Uint32, args[0]); | 5215 CONVERT_NUMBER_CHECKED(int32_t, number, Uint32, args[0]); |
| 5197 return Heap::NumberFromUint32(number); | 5216 return Heap::NumberFromUint32(number); |
| 5198 } | 5217 } |
| 5199 | 5218 |
| 5200 | 5219 |
| 5201 static Object* Runtime_NumberToJSInt32(Arguments args) { | 5220 static Object* Runtime_NumberToJSInt32(Arguments args) { |
| (...skipping 4786 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9988 } else { | 10007 } else { |
| 9989 // Handle last resort GC and make sure to allow future allocations | 10008 // Handle last resort GC and make sure to allow future allocations |
| 9990 // to grow the heap without causing GCs (if possible). | 10009 // to grow the heap without causing GCs (if possible). |
| 9991 Counters::gc_last_resort_from_js.Increment(); | 10010 Counters::gc_last_resort_from_js.Increment(); |
| 9992 Heap::CollectAllGarbage(false); | 10011 Heap::CollectAllGarbage(false); |
| 9993 } | 10012 } |
| 9994 } | 10013 } |
| 9995 | 10014 |
| 9996 | 10015 |
| 9997 } } // namespace v8::internal | 10016 } } // namespace v8::internal |
| OLD | NEW |