| 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 1647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1658 RUNTIME_ASSERT(index->IsNumber()); | 1658 RUNTIME_ASSERT(index->IsNumber()); |
| 1659 | 1659 |
| 1660 uint32_t i = 0; | 1660 uint32_t i = 0; |
| 1661 if (index->IsSmi()) { | 1661 if (index->IsSmi()) { |
| 1662 int value = Smi::cast(index)->value(); | 1662 int value = Smi::cast(index)->value(); |
| 1663 if (value < 0) return Heap::nan_value(); | 1663 if (value < 0) return Heap::nan_value(); |
| 1664 i = value; | 1664 i = value; |
| 1665 } else { | 1665 } else { |
| 1666 ASSERT(index->IsHeapNumber()); | 1666 ASSERT(index->IsHeapNumber()); |
| 1667 double value = HeapNumber::cast(index)->value(); | 1667 double value = HeapNumber::cast(index)->value(); |
| 1668 i = static_cast<uint32_t>(value); | 1668 i = static_cast<uint32_t>(DoubleToInteger(value)); |
| 1669 } | 1669 } |
| 1670 | 1670 |
| 1671 // Flatten the string. If someone wants to get a char at an index | 1671 // Flatten the string. If someone wants to get a char at an index |
| 1672 // in a cons string, it is likely that more indices will be | 1672 // in a cons string, it is likely that more indices will be |
| 1673 // accessed. | 1673 // accessed. |
| 1674 Object* flat = subject->TryFlatten(); | 1674 Object* flat = subject->TryFlatten(); |
| 1675 if (flat->IsFailure()) return flat; | 1675 if (flat->IsFailure()) return flat; |
| 1676 subject = String::cast(flat); | 1676 subject = String::cast(flat); |
| 1677 | 1677 |
| 1678 if (i >= static_cast<uint32_t>(subject->length())) { | 1678 if (i >= static_cast<uint32_t>(subject->length())) { |
| (...skipping 8625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10304 } else { | 10304 } else { |
| 10305 // Handle last resort GC and make sure to allow future allocations | 10305 // Handle last resort GC and make sure to allow future allocations |
| 10306 // to grow the heap without causing GCs (if possible). | 10306 // to grow the heap without causing GCs (if possible). |
| 10307 Counters::gc_last_resort_from_js.Increment(); | 10307 Counters::gc_last_resort_from_js.Increment(); |
| 10308 Heap::CollectAllGarbage(false); | 10308 Heap::CollectAllGarbage(false); |
| 10309 } | 10309 } |
| 10310 } | 10310 } |
| 10311 | 10311 |
| 10312 | 10312 |
| 10313 } } // namespace v8::internal | 10313 } } // namespace v8::internal |
| OLD | NEW |