| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #include "src/bootstrapper.h" | 7 #include "src/bootstrapper.h" |
| 8 #include "src/deoptimizer.h" | 8 #include "src/deoptimizer.h" |
| 9 #include "src/lookup.h" | 9 #include "src/lookup.h" |
| 10 #include "src/lookup-inl.h" | 10 #include "src/lookup-inl.h" |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 } | 125 } |
| 126 | 126 |
| 127 | 127 |
| 128 void LookupIterator::PrepareForDataProperty(Handle<Object> value) { | 128 void LookupIterator::PrepareForDataProperty(Handle<Object> value) { |
| 129 DCHECK(state_ == DATA || state_ == ACCESSOR); | 129 DCHECK(state_ == DATA || state_ == ACCESSOR); |
| 130 DCHECK(HolderIsReceiverOrHiddenPrototype()); | 130 DCHECK(HolderIsReceiverOrHiddenPrototype()); |
| 131 | 131 |
| 132 Handle<JSObject> holder = GetHolder<JSObject>(); | 132 Handle<JSObject> holder = GetHolder<JSObject>(); |
| 133 | 133 |
| 134 if (IsElement()) { | 134 if (IsElement()) { |
| 135 ElementsKind old_kind = holder_map_->elements_kind(); | 135 ElementsKind kind = holder_map_->elements_kind(); |
| 136 holder_map_ = Map::PrepareForDataElement(holder_map_, value); | 136 ElementsKind to = value->OptimalElementsKind(); |
| 137 ElementsKind new_kind = holder_map_->elements_kind(); | 137 if (IsHoleyElementsKind(kind)) to = GetHoleyElementsKind(to); |
| 138 if (new_kind != old_kind) { | 138 to = IsMoreGeneralElementsKindTransition(kind, to) ? to : kind; |
| 139 // TODO(verwaest): Handle element migration in MigrateToMap. | 139 JSObject::TransitionElementsKind(holder, to); |
| 140 JSObject::UpdateAllocationSite(holder, new_kind); | 140 holder_map_ = handle(holder->map(), isolate_); |
| 141 if (IsFastDoubleElementsKind(old_kind) != | |
| 142 IsFastDoubleElementsKind(new_kind)) { | |
| 143 uint32_t capacity = holder->elements()->length(); | |
| 144 ElementsAccessor* accessor = ElementsAccessor::ForKind(new_kind); | |
| 145 accessor->GrowCapacityAndConvert(holder, capacity); | |
| 146 // GrowCapacityAndConvert migrated the object. No reloading of property | |
| 147 // infomation is necessary for elements. | |
| 148 return; | |
| 149 } else if (FLAG_trace_elements_transitions) { | |
| 150 Handle<FixedArrayBase> elements(holder->elements()); | |
| 151 JSObject::PrintElementsTransition(stdout, holder, old_kind, elements, | |
| 152 new_kind, elements); | |
| 153 } | |
| 154 } | |
| 155 | 141 |
| 156 // Copy the backing store if it is copy-on-write. | 142 // Copy the backing store if it is copy-on-write. |
| 157 if (IsFastSmiOrObjectElementsKind(new_kind)) { | 143 if (IsFastSmiOrObjectElementsKind(to)) { |
| 158 JSObject::EnsureWritableFastElements(holder); | 144 JSObject::EnsureWritableFastElements(holder); |
| 159 } | 145 } |
| 160 | 146 |
| 161 } else { | 147 } else { |
| 162 if (holder_map_->is_dictionary_map()) return; | 148 if (holder_map_->is_dictionary_map()) return; |
| 163 holder_map_ = | 149 holder_map_ = |
| 164 Map::PrepareForDataProperty(holder_map_, descriptor_number(), value); | 150 Map::PrepareForDataProperty(holder_map_, descriptor_number(), value); |
| 165 } | 151 } |
| 166 | 152 |
| 167 JSObject::MigrateToMap(holder, holder_map_); | 153 JSObject::MigrateToMap(holder, holder_map_); |
| (...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 557 case InterceptorState::kSkipNonMasking: | 543 case InterceptorState::kSkipNonMasking: |
| 558 return true; | 544 return true; |
| 559 case InterceptorState::kProcessNonMasking: | 545 case InterceptorState::kProcessNonMasking: |
| 560 return false; | 546 return false; |
| 561 } | 547 } |
| 562 } | 548 } |
| 563 return interceptor_state_ == InterceptorState::kProcessNonMasking; | 549 return interceptor_state_ == InterceptorState::kProcessNonMasking; |
| 564 } | 550 } |
| 565 } // namespace internal | 551 } // namespace internal |
| 566 } // namespace v8 | 552 } // namespace v8 |
| OLD | NEW |