| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 <iomanip> | 7 #include <iomanip> |
| 8 #include <sstream> | 8 #include <sstream> |
| 9 | 9 |
| 10 #include "src/accessors.h" | 10 #include "src/accessors.h" |
| (...skipping 4172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4183 return Execution::Call(isolate, trap, handler, argc, argv); | 4183 return Execution::Call(isolate, trap, handler, argc, argv); |
| 4184 } | 4184 } |
| 4185 | 4185 |
| 4186 | 4186 |
| 4187 void JSObject::AllocateStorageForMap(Handle<JSObject> object, Handle<Map> map) { | 4187 void JSObject::AllocateStorageForMap(Handle<JSObject> object, Handle<Map> map) { |
| 4188 DCHECK(object->map()->GetInObjectProperties() == | 4188 DCHECK(object->map()->GetInObjectProperties() == |
| 4189 map->GetInObjectProperties()); | 4189 map->GetInObjectProperties()); |
| 4190 ElementsKind obj_kind = object->map()->elements_kind(); | 4190 ElementsKind obj_kind = object->map()->elements_kind(); |
| 4191 ElementsKind map_kind = map->elements_kind(); | 4191 ElementsKind map_kind = map->elements_kind(); |
| 4192 if (map_kind != obj_kind) { | 4192 if (map_kind != obj_kind) { |
| 4193 ElementsKind to_kind = map_kind; | 4193 ElementsKind to_kind = GetMoreGeneralElementsKind(map_kind, obj_kind); |
| 4194 if (IsMoreGeneralElementsKindTransition(map_kind, obj_kind) || | 4194 if (IsDictionaryElementsKind(obj_kind)) { |
| 4195 IsDictionaryElementsKind(obj_kind)) { | |
| 4196 to_kind = obj_kind; | 4195 to_kind = obj_kind; |
| 4197 } | 4196 } |
| 4198 if (IsDictionaryElementsKind(to_kind)) { | 4197 if (IsDictionaryElementsKind(to_kind)) { |
| 4199 NormalizeElements(object); | 4198 NormalizeElements(object); |
| 4200 } else { | 4199 } else { |
| 4201 TransitionElementsKind(object, to_kind); | 4200 TransitionElementsKind(object, to_kind); |
| 4202 } | 4201 } |
| 4203 map = Map::AsElementsKind(map, to_kind); | 4202 map = Map::AsElementsKind(map, to_kind); |
| 4204 } | 4203 } |
| 4205 JSObject::MigrateToMap(object, map); | 4204 JSObject::MigrateToMap(object, map); |
| (...skipping 8395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12601 *object, static_cast<uint32_t>(elements->length()), index, | 12600 *object, static_cast<uint32_t>(elements->length()), index, |
| 12602 &new_capacity)) { | 12601 &new_capacity)) { |
| 12603 kind = dictionary_kind; | 12602 kind = dictionary_kind; |
| 12604 } | 12603 } |
| 12605 | 12604 |
| 12606 ElementsKind to = value->OptimalElementsKind(); | 12605 ElementsKind to = value->OptimalElementsKind(); |
| 12607 if (IsHoleyElementsKind(kind) || !object->IsJSArray() || index > old_length) { | 12606 if (IsHoleyElementsKind(kind) || !object->IsJSArray() || index > old_length) { |
| 12608 to = GetHoleyElementsKind(to); | 12607 to = GetHoleyElementsKind(to); |
| 12609 kind = GetHoleyElementsKind(kind); | 12608 kind = GetHoleyElementsKind(kind); |
| 12610 } | 12609 } |
| 12611 to = IsMoreGeneralElementsKindTransition(kind, to) ? to : kind; | 12610 to = GetMoreGeneralElementsKind(kind, to); |
| 12612 ElementsAccessor* accessor = ElementsAccessor::ForKind(to); | 12611 ElementsAccessor* accessor = ElementsAccessor::ForKind(to); |
| 12613 accessor->Add(object, index, value, attributes, new_capacity); | 12612 accessor->Add(object, index, value, attributes, new_capacity); |
| 12614 | 12613 |
| 12615 uint32_t new_length = old_length; | 12614 uint32_t new_length = old_length; |
| 12616 Handle<Object> new_length_handle; | 12615 Handle<Object> new_length_handle; |
| 12617 if (object->IsJSArray() && index >= old_length) { | 12616 if (object->IsJSArray() && index >= old_length) { |
| 12618 new_length = index + 1; | 12617 new_length = index + 1; |
| 12619 new_length_handle = isolate->factory()->NewNumberFromUint(new_length); | 12618 new_length_handle = isolate->factory()->NewNumberFromUint(new_length); |
| 12620 JSArray::cast(*object)->set_length(*new_length_handle); | 12619 JSArray::cast(*object)->set_length(*new_length_handle); |
| 12621 } | 12620 } |
| (...skipping 3546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16168 if (cell->value() != *new_value) { | 16167 if (cell->value() != *new_value) { |
| 16169 cell->set_value(*new_value); | 16168 cell->set_value(*new_value); |
| 16170 Isolate* isolate = cell->GetIsolate(); | 16169 Isolate* isolate = cell->GetIsolate(); |
| 16171 cell->dependent_code()->DeoptimizeDependentCodeGroup( | 16170 cell->dependent_code()->DeoptimizeDependentCodeGroup( |
| 16172 isolate, DependentCode::kPropertyCellChangedGroup); | 16171 isolate, DependentCode::kPropertyCellChangedGroup); |
| 16173 } | 16172 } |
| 16174 } | 16173 } |
| 16175 | 16174 |
| 16176 } // namespace internal | 16175 } // namespace internal |
| 16177 } // namespace v8 | 16176 } // namespace v8 |
| OLD | NEW |