OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
192 #ifdef DEBUG | 192 #ifdef DEBUG |
193 // FAST_ELEMENT arrays cannot be uninitialized. Ensure they are already | 193 // FAST_ELEMENT arrays cannot be uninitialized. Ensure they are already |
194 // marked with the hole. | 194 // marked with the hole. |
195 if (raw_copy_size == ElementsAccessor::kCopyToEndAndInitializeToHole) { | 195 if (raw_copy_size == ElementsAccessor::kCopyToEndAndInitializeToHole) { |
196 for (int i = to_start + copy_size; i < to->length(); ++i) { | 196 for (int i = to_start + copy_size; i < to->length(); ++i) { |
197 ASSERT(to->get(i)->IsTheHole()); | 197 ASSERT(to->get(i)->IsTheHole()); |
198 } | 198 } |
199 } | 199 } |
200 #endif | 200 #endif |
201 } | 201 } |
202 ASSERT((copy_size + static_cast<int>(to_start)) <= to->length()); | |
203 ASSERT(to != from); | 202 ASSERT(to != from); |
204 ASSERT(to_kind == FAST_ELEMENTS || to_kind == FAST_SMI_ONLY_ELEMENTS); | 203 ASSERT(to_kind == FAST_ELEMENTS || to_kind == FAST_SMI_ONLY_ELEMENTS); |
205 if (copy_size == 0) return; | 204 if (copy_size == 0) return; |
205 uint32_t to_length = to->length(); | |
206 if (to_start + copy_size > to_length) { | |
Michael Starzinger
2012/04/03 08:13:18
I suspect that without the cast this will lead to
| |
207 copy_size = to_length - to_start; | |
208 } | |
206 for (int i = 0; i < copy_size; i++) { | 209 for (int i = 0; i < copy_size; i++) { |
207 int entry = from->FindEntry(i + from_start); | 210 int entry = from->FindEntry(i + from_start); |
208 if (entry != SeededNumberDictionary::kNotFound) { | 211 if (entry != SeededNumberDictionary::kNotFound) { |
209 Object* value = from->ValueAt(entry); | 212 Object* value = from->ValueAt(entry); |
210 ASSERT(!value->IsTheHole()); | 213 ASSERT(!value->IsTheHole()); |
211 to->set(i + to_start, value, SKIP_WRITE_BARRIER); | 214 to->set(i + to_start, value, SKIP_WRITE_BARRIER); |
212 } else { | 215 } else { |
213 to->set_the_hole(i + to_start); | 216 to->set_the_hole(i + to_start); |
214 } | 217 } |
215 } | 218 } |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
349 if (copy_size < 0) { | 352 if (copy_size < 0) { |
350 ASSERT(copy_size == ElementsAccessor::kCopyToEnd || | 353 ASSERT(copy_size == ElementsAccessor::kCopyToEnd || |
351 copy_size == ElementsAccessor::kCopyToEndAndInitializeToHole); | 354 copy_size == ElementsAccessor::kCopyToEndAndInitializeToHole); |
352 copy_size = from->max_number_key() + 1 - from_start; | 355 copy_size = from->max_number_key() + 1 - from_start; |
353 if (raw_copy_size == ElementsAccessor::kCopyToEndAndInitializeToHole) { | 356 if (raw_copy_size == ElementsAccessor::kCopyToEndAndInitializeToHole) { |
354 for (int i = to_start + copy_size; i < to->length(); ++i) { | 357 for (int i = to_start + copy_size; i < to->length(); ++i) { |
355 to->set_the_hole(i); | 358 to->set_the_hole(i); |
356 } | 359 } |
357 } | 360 } |
358 } | 361 } |
359 ASSERT(copy_size + static_cast<int>(to_start) <= to->length()); | |
360 if (copy_size == 0) return; | 362 if (copy_size == 0) return; |
363 uint32_t to_length = to->length(); | |
364 if (to_start + copy_size > to_length) { | |
365 copy_size = to_length - to_start; | |
366 } | |
361 for (int i = 0; i < copy_size; i++) { | 367 for (int i = 0; i < copy_size; i++) { |
362 int entry = from->FindEntry(i + from_start); | 368 int entry = from->FindEntry(i + from_start); |
363 if (entry != SeededNumberDictionary::kNotFound) { | 369 if (entry != SeededNumberDictionary::kNotFound) { |
364 to->set(i + to_start, from->ValueAt(entry)->Number()); | 370 to->set(i + to_start, from->ValueAt(entry)->Number()); |
365 } else { | 371 } else { |
366 to->set_the_hole(i + to_start); | 372 to->set_the_hole(i + to_start); |
367 } | 373 } |
368 } | 374 } |
369 } | 375 } |
370 | 376 |
(...skipping 1031 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1402 if (!maybe_obj->To(&new_backing_store)) return maybe_obj; | 1408 if (!maybe_obj->To(&new_backing_store)) return maybe_obj; |
1403 new_backing_store->set(0, length); | 1409 new_backing_store->set(0, length); |
1404 { MaybeObject* result = array->SetContent(new_backing_store); | 1410 { MaybeObject* result = array->SetContent(new_backing_store); |
1405 if (result->IsFailure()) return result; | 1411 if (result->IsFailure()) return result; |
1406 } | 1412 } |
1407 return array; | 1413 return array; |
1408 } | 1414 } |
1409 | 1415 |
1410 | 1416 |
1411 } } // namespace v8::internal | 1417 } } // namespace v8::internal |
OLD | NEW |