| 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 1256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1267 return *target; | 1267 return *target; |
| 1268 } | 1268 } |
| 1269 | 1269 |
| 1270 | 1270 |
| 1271 static Object* CharCodeAt(String* subject, Object* index) { | 1271 static Object* CharCodeAt(String* subject, Object* index) { |
| 1272 uint32_t i = 0; | 1272 uint32_t i = 0; |
| 1273 if (!Array::IndexFromObject(index, &i)) return Heap::nan_value(); | 1273 if (!Array::IndexFromObject(index, &i)) return Heap::nan_value(); |
| 1274 // Flatten the string. If someone wants to get a char at an index | 1274 // Flatten the string. If someone wants to get a char at an index |
| 1275 // in a cons string, it is likely that more indices will be | 1275 // in a cons string, it is likely that more indices will be |
| 1276 // accessed. | 1276 // accessed. |
| 1277 subject->TryFlattenIfNotFlat(); | 1277 Object* flat = subject->TryFlatten(); |
| 1278 if (flat->IsFailure()) return flat; |
| 1279 subject = String::cast(flat); |
| 1278 if (i >= static_cast<uint32_t>(subject->length())) { | 1280 if (i >= static_cast<uint32_t>(subject->length())) { |
| 1279 return Heap::nan_value(); | 1281 return Heap::nan_value(); |
| 1280 } | 1282 } |
| 1281 return Smi::FromInt(subject->Get(i)); | 1283 return Smi::FromInt(subject->Get(i)); |
| 1282 } | 1284 } |
| 1283 | 1285 |
| 1284 | 1286 |
| 1285 static Object* Runtime_StringCharCodeAt(Arguments args) { | 1287 static Object* Runtime_StringCharCodeAt(Arguments args) { |
| 1286 NoHandleAllocation ha; | 1288 NoHandleAllocation ha; |
| 1287 ASSERT(args.length() == 2); | 1289 ASSERT(args.length() == 2); |
| (...skipping 6614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7902 } else { | 7904 } else { |
| 7903 // Handle last resort GC and make sure to allow future allocations | 7905 // Handle last resort GC and make sure to allow future allocations |
| 7904 // to grow the heap without causing GCs (if possible). | 7906 // to grow the heap without causing GCs (if possible). |
| 7905 Counters::gc_last_resort_from_js.Increment(); | 7907 Counters::gc_last_resort_from_js.Increment(); |
| 7906 Heap::CollectAllGarbage(false); | 7908 Heap::CollectAllGarbage(false); |
| 7907 } | 7909 } |
| 7908 } | 7910 } |
| 7909 | 7911 |
| 7910 | 7912 |
| 7911 } } // namespace v8::internal | 7913 } } // namespace v8::internal |
| OLD | NEW |