| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 11358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11369 Handle<Object> hresult = | 11369 Handle<Object> hresult = |
| 11370 array->GetElementsAccessor()->SetLength(array, new_length_handle); | 11370 array->GetElementsAccessor()->SetLength(array, new_length_handle); |
| 11371 RETURN_IF_EMPTY_HANDLE_VALUE(isolate, hresult, hresult); | 11371 RETURN_IF_EMPTY_HANDLE_VALUE(isolate, hresult, hresult); |
| 11372 | 11372 |
| 11373 CHECK(array->length()->ToArrayIndex(&new_length)); | 11373 CHECK(array->length()->ToArrayIndex(&new_length)); |
| 11374 if (old_length == new_length) return hresult; | 11374 if (old_length == new_length) return hresult; |
| 11375 | 11375 |
| 11376 BeginPerformSplice(array); | 11376 BeginPerformSplice(array); |
| 11377 | 11377 |
| 11378 for (int i = 0; i < indices.length(); ++i) { | 11378 for (int i = 0; i < indices.length(); ++i) { |
| 11379 // For deletions where the property was an accessor, old_values[i] |
| 11380 // will be the hole, which instructs EnqueueChangeRecord to elide |
| 11381 // the "oldValue" property. |
| 11379 JSObject::EnqueueChangeRecord( | 11382 JSObject::EnqueueChangeRecord( |
| 11380 array, "delete", isolate->factory()->Uint32ToString(indices[i]), | 11383 array, "delete", isolate->factory()->Uint32ToString(indices[i]), |
| 11381 old_values[i]); | 11384 old_values[i]); |
| 11382 } | 11385 } |
| 11383 JSObject::EnqueueChangeRecord( | 11386 JSObject::EnqueueChangeRecord( |
| 11384 array, "update", isolate->factory()->length_string(), | 11387 array, "update", isolate->factory()->length_string(), |
| 11385 old_length_handle); | 11388 old_length_handle); |
| 11386 | 11389 |
| 11387 EndPerformSplice(array); | 11390 EndPerformSplice(array); |
| 11388 | 11391 |
| 11389 uint32_t index = Min(old_length, new_length); | 11392 uint32_t index = Min(old_length, new_length); |
| 11390 uint32_t add_count = new_length > old_length ? new_length - old_length : 0; | 11393 uint32_t add_count = new_length > old_length ? new_length - old_length : 0; |
| 11391 uint32_t delete_count = new_length < old_length ? old_length - new_length : 0; | 11394 uint32_t delete_count = new_length < old_length ? old_length - new_length : 0; |
| 11392 Handle<JSArray> deleted = isolate->factory()->NewJSArray(0); | 11395 Handle<JSArray> deleted = isolate->factory()->NewJSArray(0); |
| 11393 if (delete_count > 0) { | 11396 if (delete_count > 0) { |
| 11394 for (int i = indices.length() - 1; i >= 0; i--) { | 11397 for (int i = indices.length() - 1; i >= 0; i--) { |
| 11398 // Skip deletions where the property was an accessor, leaving holes |
| 11399 // in the array of old values. |
| 11400 if (old_values[i]->IsTheHole()) continue; |
| 11395 JSObject::SetElement(deleted, indices[i] - index, old_values[i], NONE, | 11401 JSObject::SetElement(deleted, indices[i] - index, old_values[i], NONE, |
| 11396 SLOPPY); | 11402 SLOPPY); |
| 11397 } | 11403 } |
| 11398 | 11404 |
| 11399 SetProperty(deleted, isolate->factory()->length_string(), | 11405 SetProperty(deleted, isolate->factory()->length_string(), |
| 11400 isolate->factory()->NewNumberFromUint(delete_count), | 11406 isolate->factory()->NewNumberFromUint(delete_count), |
| 11401 NONE, SLOPPY); | 11407 NONE, SLOPPY); |
| 11402 } | 11408 } |
| 11403 | 11409 |
| 11404 EnqueueSpliceRecord(array, index, deleted, add_count); | 11410 EnqueueSpliceRecord(array, index, deleted, add_count); |
| (...skipping 5028 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16433 #define ERROR_MESSAGES_TEXTS(C, T) T, | 16439 #define ERROR_MESSAGES_TEXTS(C, T) T, |
| 16434 static const char* error_messages_[] = { | 16440 static const char* error_messages_[] = { |
| 16435 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) | 16441 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) |
| 16436 }; | 16442 }; |
| 16437 #undef ERROR_MESSAGES_TEXTS | 16443 #undef ERROR_MESSAGES_TEXTS |
| 16438 return error_messages_[reason]; | 16444 return error_messages_[reason]; |
| 16439 } | 16445 } |
| 16440 | 16446 |
| 16441 | 16447 |
| 16442 } } // namespace v8::internal | 16448 } } // namespace v8::internal |
| OLD | NEW |