| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/objects.h" | 5 #include "src/objects.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 #include <iomanip> | 8 #include <iomanip> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <sstream> | 10 #include <sstream> |
| (...skipping 15481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15492 | 15492 |
| 15493 ElementsKind to = value->OptimalElementsKind(); | 15493 ElementsKind to = value->OptimalElementsKind(); |
| 15494 if (IsHoleyElementsKind(kind) || !object->IsJSArray() || index > old_length) { | 15494 if (IsHoleyElementsKind(kind) || !object->IsJSArray() || index > old_length) { |
| 15495 to = GetHoleyElementsKind(to); | 15495 to = GetHoleyElementsKind(to); |
| 15496 kind = GetHoleyElementsKind(kind); | 15496 kind = GetHoleyElementsKind(kind); |
| 15497 } | 15497 } |
| 15498 to = GetMoreGeneralElementsKind(kind, to); | 15498 to = GetMoreGeneralElementsKind(kind, to); |
| 15499 ElementsAccessor* accessor = ElementsAccessor::ForKind(to); | 15499 ElementsAccessor* accessor = ElementsAccessor::ForKind(to); |
| 15500 accessor->Add(object, index, value, attributes, new_capacity); | 15500 accessor->Add(object, index, value, attributes, new_capacity); |
| 15501 | 15501 |
| 15502 uint32_t new_length = old_length; | |
| 15503 Handle<Object> new_length_handle; | |
| 15504 if (object->IsJSArray() && index >= old_length) { | 15502 if (object->IsJSArray() && index >= old_length) { |
| 15505 new_length = index + 1; | 15503 Handle<Object> new_length = |
| 15506 new_length_handle = isolate->factory()->NewNumberFromUint(new_length); | 15504 isolate->factory()->NewNumberFromUint(index + 1); |
| 15507 JSArray::cast(*object)->set_length(*new_length_handle); | 15505 JSArray::cast(*object)->set_length(*new_length); |
| 15508 } | 15506 } |
| 15509 | 15507 |
| 15510 return Just(true); | 15508 return Just(true); |
| 15511 } | 15509 } |
| 15512 | 15510 |
| 15513 | 15511 |
| 15514 bool JSArray::SetLengthWouldNormalize(uint32_t new_length) { | 15512 bool JSArray::SetLengthWouldNormalize(uint32_t new_length) { |
| 15515 if (!HasFastElements()) return false; | 15513 if (!HasFastElements()) return false; |
| 15516 uint32_t capacity = static_cast<uint32_t>(elements()->length()); | 15514 uint32_t capacity = static_cast<uint32_t>(elements()->length()); |
| 15517 uint32_t new_capacity; | 15515 uint32_t new_capacity; |
| (...skipping 4507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 20025 // depend on this. | 20023 // depend on this. |
| 20026 return DICTIONARY_ELEMENTS; | 20024 return DICTIONARY_ELEMENTS; |
| 20027 } | 20025 } |
| 20028 DCHECK_LE(kind, LAST_ELEMENTS_KIND); | 20026 DCHECK_LE(kind, LAST_ELEMENTS_KIND); |
| 20029 return kind; | 20027 return kind; |
| 20030 } | 20028 } |
| 20031 } | 20029 } |
| 20032 | 20030 |
| 20033 } // namespace internal | 20031 } // namespace internal |
| 20034 } // namespace v8 | 20032 } // namespace v8 |
| OLD | NEW |