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/lookup.h" | 5 #include "src/lookup.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/elements.h" | 9 #include "src/elements.h" |
10 #include "src/field-type.h" | 10 #include "src/field-type.h" |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 holder_map_ = handle(holder->map(), isolate_); | 174 holder_map_ = handle(holder->map(), isolate_); |
175 } | 175 } |
176 | 176 |
177 // Copy the backing store if it is copy-on-write. | 177 // Copy the backing store if it is copy-on-write. |
178 if (IsFastSmiOrObjectElementsKind(to)) { | 178 if (IsFastSmiOrObjectElementsKind(to)) { |
179 JSObject::EnsureWritableFastElements(holder); | 179 JSObject::EnsureWritableFastElements(holder); |
180 } | 180 } |
181 | 181 |
182 if (kind == to) return; | 182 if (kind == to) return; |
183 | 183 |
| 184 } else if (holder_map_->is_dictionary_map()) { |
| 185 return; |
184 } else { | 186 } else { |
185 if (holder_map_->is_dictionary_map()) return; | |
186 holder_map_ = | 187 holder_map_ = |
187 Map::PrepareForDataProperty(holder_map_, descriptor_number(), value); | 188 Map::PrepareForDataProperty(holder_map_, descriptor_number(), value); |
188 | 189 |
189 if (holder->map() == *holder_map_) { | 190 if (holder->map() == *holder_map_) { |
190 // Update the property details if the representation was None. | 191 // Update the property details if the representation was None. |
191 if (representation().IsNone()) { | 192 if (representation().IsNone()) { |
192 property_details_ = holder_map_->instance_descriptors()->GetDetails( | 193 property_details_ = holder_map_->instance_descriptors()->GetDetails( |
193 descriptor_number()); | 194 descriptor_number()); |
194 } | 195 } |
195 return; | 196 return; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 Handle<JSObject> receiver, Handle<Object> value, | 241 Handle<JSObject> receiver, Handle<Object> value, |
241 PropertyAttributes attributes, Object::StoreFromKeyed store_mode) { | 242 PropertyAttributes attributes, Object::StoreFromKeyed store_mode) { |
242 DCHECK(receiver.is_identical_to(GetStoreTarget())); | 243 DCHECK(receiver.is_identical_to(GetStoreTarget())); |
243 if (state_ == TRANSITION) return; | 244 if (state_ == TRANSITION) return; |
244 DCHECK(state_ != LookupIterator::ACCESSOR || | 245 DCHECK(state_ != LookupIterator::ACCESSOR || |
245 (GetAccessors()->IsAccessorInfo() && | 246 (GetAccessors()->IsAccessorInfo() && |
246 AccessorInfo::cast(*GetAccessors())->is_special_data_property())); | 247 AccessorInfo::cast(*GetAccessors())->is_special_data_property())); |
247 DCHECK_NE(INTEGER_INDEXED_EXOTIC, state_); | 248 DCHECK_NE(INTEGER_INDEXED_EXOTIC, state_); |
248 DCHECK(state_ == NOT_FOUND || !HolderIsReceiverOrHiddenPrototype()); | 249 DCHECK(state_ == NOT_FOUND || !HolderIsReceiverOrHiddenPrototype()); |
249 | 250 |
250 auto transition = Map::TransitionToDataProperty( | 251 Handle<Map> map(receiver->map(), isolate_); |
251 handle(receiver->map(), isolate_), name_, value, attributes, store_mode); | 252 |
| 253 // Dictionary maps can always have additional data properties. |
| 254 if (map->is_dictionary_map()) { |
| 255 state_ = TRANSITION; |
| 256 if (map->IsJSGlobalObjectMap()) { |
| 257 // Install a property cell. |
| 258 InternalizeName(); |
| 259 auto cell = JSGlobalObject::EnsurePropertyCell( |
| 260 Handle<JSGlobalObject>::cast(receiver), name()); |
| 261 DCHECK(cell->value()->IsTheHole()); |
| 262 transition_ = cell; |
| 263 } else { |
| 264 transition_ = map; |
| 265 } |
| 266 return; |
| 267 } |
| 268 |
| 269 Handle<Map> transition = |
| 270 Map::TransitionToDataProperty(map, name_, value, attributes, store_mode); |
252 state_ = TRANSITION; | 271 state_ = TRANSITION; |
253 transition_ = transition; | 272 transition_ = transition; |
254 | 273 |
255 if (receiver->IsJSGlobalObject()) { | 274 if (!transition->is_dictionary_map()) { |
256 // Install a property cell. | |
257 InternalizeName(); | |
258 auto cell = JSGlobalObject::EnsurePropertyCell( | |
259 Handle<JSGlobalObject>::cast(receiver), name()); | |
260 DCHECK(cell->value()->IsTheHole()); | |
261 transition_ = cell; | |
262 } else if (!transition->is_dictionary_map()) { | |
263 property_details_ = transition->GetLastDescriptorDetails(); | 275 property_details_ = transition->GetLastDescriptorDetails(); |
264 has_property_ = true; | 276 has_property_ = true; |
265 } | 277 } |
266 } | 278 } |
267 | 279 |
268 void LookupIterator::ApplyTransitionToDataProperty(Handle<JSObject> receiver) { | 280 void LookupIterator::ApplyTransitionToDataProperty(Handle<JSObject> receiver) { |
269 DCHECK_EQ(TRANSITION, state_); | 281 DCHECK_EQ(TRANSITION, state_); |
270 | 282 |
271 DCHECK(receiver.is_identical_to(GetStoreTarget())); | 283 DCHECK(receiver.is_identical_to(GetStoreTarget())); |
272 | 284 |
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
688 // Fall through. | 700 // Fall through. |
689 default: | 701 default: |
690 return NOT_FOUND; | 702 return NOT_FOUND; |
691 } | 703 } |
692 UNREACHABLE(); | 704 UNREACHABLE(); |
693 return state_; | 705 return state_; |
694 } | 706 } |
695 | 707 |
696 } // namespace internal | 708 } // namespace internal |
697 } // namespace v8 | 709 } // namespace v8 |
OLD | NEW |