Chromium Code Reviews| Index: src/objects.cc |
| diff --git a/src/objects.cc b/src/objects.cc |
| index 5e03e8abde4910923800e099cd6e921881ae921f..516c68dfb42b6d7a84b68fe1942b65b788286572 100644 |
| --- a/src/objects.cc |
| +++ b/src/objects.cc |
| @@ -11930,28 +11930,22 @@ static bool GetOldValue(Isolate* isolate, |
| return true; |
| } |
| -MaybeHandle<Object> JSArray::SetElementsLength( |
| - Handle<JSArray> array, |
| - Handle<Object> new_length_handle) { |
| - if (array->HasFastElements() && |
| - SetElementsLengthWouldNormalize(array->GetHeap(), new_length_handle)) { |
| - NormalizeElements(array); |
| - } |
| +void JSArray::SetLength(Handle<JSArray> array, uint32_t new_length) { |
| // We should never end in here with a pixel or external array. |
| - DCHECK(array->AllowsSetElementsLength()); |
| - if (!array->map()->is_observed()) { |
| - return array->GetElementsAccessor()->SetLength(array, new_length_handle); |
| - } |
| + DCHECK(array->AllowsSetLength()); |
| + array->GetElementsAccessor()->SetLength(array, new_length); |
| +} |
| + |
| +MaybeHandle<Object> JSArray::ObserveableSetLength(Handle<JSArray> array, |
|
Jakob Kummerow
2015/06/19 13:23:12
nit: "observable" (one less 'e') is the far more c
|
| + uint32_t new_length) { |
| Isolate* isolate = array->GetIsolate(); |
| List<uint32_t> indices; |
| List<Handle<Object> > old_values; |
| Handle<Object> old_length_handle(array->length(), isolate); |
| uint32_t old_length = 0; |
| CHECK(old_length_handle->ToArrayLength(&old_length)); |
| - uint32_t new_length = 0; |
| - CHECK(new_length_handle->ToArrayLength(&new_length)); |
| static const PropertyAttributes kNoAttrFilter = NONE; |
| int num_elements = array->NumberOfOwnElements(kNoAttrFilter); |
| @@ -11975,14 +11969,10 @@ MaybeHandle<Object> JSArray::SetElementsLength( |
| } |
| } |
| - Handle<Object> hresult; |
| - ASSIGN_RETURN_ON_EXCEPTION( |
| - isolate, hresult, |
| - array->GetElementsAccessor()->SetLength(array, new_length_handle), |
| - Object); |
| + SetLength(array, new_length); |
| CHECK(array->length()->ToArrayLength(&new_length)); |
| - if (old_length == new_length) return hresult; |
| + if (old_length == new_length) return array; |
| RETURN_ON_EXCEPTION(isolate, BeginPerformSplice(array), Object); |
| @@ -11997,6 +11987,7 @@ MaybeHandle<Object> JSArray::SetElementsLength( |
| old_values[i]), |
| Object); |
| } |
| + |
| RETURN_ON_EXCEPTION(isolate, |
| JSObject::EnqueueChangeRecord( |
| array, "update", isolate->factory()->length_string(), |
| @@ -12018,15 +12009,13 @@ MaybeHandle<Object> JSArray::SetElementsLength( |
| .Assert(); |
| } |
| - ElementsAccessor* accessor = deleted->GetElementsAccessor(); |
| - accessor->SetLength(deleted, isolate->factory()->NewNumberFromUint( |
| - delete_count)).Check(); |
| + JSArray::SetLength(deleted, delete_count); |
| } |
| RETURN_ON_EXCEPTION( |
| isolate, EnqueueSpliceRecord(array, index, deleted, add_count), Object); |
| - return hresult; |
| + return array; |
| } |