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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 ReloadPropertyInformation(); | 95 ReloadPropertyInformation(); |
96 } | 96 } |
97 | 97 |
98 | 98 |
99 void LookupIterator::ReconfigureDataProperty(Handle<Object> value, | 99 void LookupIterator::ReconfigureDataProperty(Handle<Object> value, |
100 PropertyAttributes attributes) { | 100 PropertyAttributes attributes) { |
101 DCHECK(state_ == DATA || state_ == ACCESSOR); | 101 DCHECK(state_ == DATA || state_ == ACCESSOR); |
102 DCHECK(HolderIsReceiverOrHiddenPrototype()); | 102 DCHECK(HolderIsReceiverOrHiddenPrototype()); |
103 Handle<JSObject> holder = GetHolder<JSObject>(); | 103 Handle<JSObject> holder = GetHolder<JSObject>(); |
104 if (holder_map_->is_dictionary_map()) { | 104 if (holder_map_->is_dictionary_map()) { |
105 PropertyDetails details(attributes, v8::internal::DATA, 0); | 105 PropertyDetails details(attributes, v8::internal::DATA, 0, |
| 106 PropertyCellType::kMutable); |
106 JSObject::SetNormalizedProperty(holder, name(), value, details); | 107 JSObject::SetNormalizedProperty(holder, name(), value, details); |
107 } else { | 108 } else { |
108 holder_map_ = Map::ReconfigureExistingProperty( | 109 holder_map_ = Map::ReconfigureExistingProperty( |
109 holder_map_, descriptor_number(), i::kData, attributes); | 110 holder_map_, descriptor_number(), i::kData, attributes); |
110 holder_map_ = | 111 holder_map_ = |
111 Map::PrepareForDataProperty(holder_map_, descriptor_number(), value); | 112 Map::PrepareForDataProperty(holder_map_, descriptor_number(), value); |
112 JSObject::MigrateToMap(holder, holder_map_); | 113 JSObject::MigrateToMap(holder, holder_map_); |
113 } | 114 } |
114 | 115 |
115 ReloadPropertyInformation(); | 116 ReloadPropertyInformation(); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 holder_ = receiver; | 176 holder_ = receiver; |
176 holder_map_ = | 177 holder_map_ = |
177 Map::TransitionToAccessorProperty(handle(receiver->map(), isolate_), | 178 Map::TransitionToAccessorProperty(handle(receiver->map(), isolate_), |
178 name_, component, accessor, attributes); | 179 name_, component, accessor, attributes); |
179 JSObject::MigrateToMap(receiver, holder_map_); | 180 JSObject::MigrateToMap(receiver, holder_map_); |
180 | 181 |
181 ReloadPropertyInformation(); | 182 ReloadPropertyInformation(); |
182 | 183 |
183 if (!holder_map_->is_dictionary_map()) return; | 184 if (!holder_map_->is_dictionary_map()) return; |
184 | 185 |
185 // We have to deoptimize since accesses to data properties may have been | |
186 // inlined without a corresponding map-check. | |
187 if (holder_map_->IsGlobalObjectMap()) { | |
188 Deoptimizer::DeoptimizeGlobalObject(*receiver); | |
189 } | |
190 | 186 |
191 // Install the accessor into the dictionary-mode object. | 187 // Install the accessor into the dictionary-mode object. |
192 PropertyDetails details(attributes, ACCESSOR_CONSTANT, 0); | 188 PropertyDetails details(attributes, ACCESSOR_CONSTANT, 0, |
| 189 PropertyCellType::kMutable); |
193 Handle<AccessorPair> pair; | 190 Handle<AccessorPair> pair; |
194 if (state() == ACCESSOR && GetAccessors()->IsAccessorPair()) { | 191 if (state() == ACCESSOR && GetAccessors()->IsAccessorPair()) { |
195 pair = Handle<AccessorPair>::cast(GetAccessors()); | 192 pair = Handle<AccessorPair>::cast(GetAccessors()); |
196 // If the component and attributes are identical, nothing has to be done. | 193 // If the component and attributes are identical, nothing has to be done. |
197 if (pair->get(component) == *accessor) { | 194 if (pair->get(component) == *accessor) { |
198 if (property_details().attributes() == attributes) return; | 195 if (property_details().attributes() == attributes) return; |
199 } else { | 196 } else { |
200 pair = AccessorPair::Copy(pair); | 197 pair = AccessorPair::Copy(pair); |
201 pair->set(component, *accessor); | 198 pair->set(component, *accessor); |
202 } | 199 } |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 DCHECK_EQ(DATA, state_); | 306 DCHECK_EQ(DATA, state_); |
310 Handle<Object> value = FetchValue(); | 307 Handle<Object> value = FetchValue(); |
311 return value; | 308 return value; |
312 } | 309 } |
313 | 310 |
314 | 311 |
315 Handle<Object> LookupIterator::WriteDataValue(Handle<Object> value) { | 312 Handle<Object> LookupIterator::WriteDataValue(Handle<Object> value) { |
316 DCHECK_EQ(DATA, state_); | 313 DCHECK_EQ(DATA, state_); |
317 Handle<JSObject> holder = GetHolder<JSObject>(); | 314 Handle<JSObject> holder = GetHolder<JSObject>(); |
318 if (holder_map_->is_dictionary_map()) { | 315 if (holder_map_->is_dictionary_map()) { |
319 NameDictionary* property_dictionary = holder->property_dictionary(); | 316 Handle<NameDictionary> property_dictionary = |
| 317 handle(holder->property_dictionary()); |
320 if (holder->IsGlobalObject()) { | 318 if (holder->IsGlobalObject()) { |
321 Handle<PropertyCell> cell( | 319 value = PropertyCell::UpdateCell(property_dictionary, dictionary_entry(), |
322 PropertyCell::cast(property_dictionary->ValueAt(dictionary_entry()))); | 320 value, property_details_); |
323 value = PropertyCell::SetValueInferType(cell, value); | |
324 } else { | 321 } else { |
325 property_dictionary->ValueAtPut(dictionary_entry(), *value); | 322 property_dictionary->ValueAtPut(dictionary_entry(), *value); |
326 } | 323 } |
327 } else if (property_details_.type() == v8::internal::DATA) { | 324 } else if (property_details_.type() == v8::internal::DATA) { |
328 holder->WriteToField(descriptor_number(), *value); | 325 holder->WriteToField(descriptor_number(), *value); |
329 } else { | 326 } else { |
330 DCHECK_EQ(v8::internal::DATA_CONSTANT, property_details_.type()); | 327 DCHECK_EQ(v8::internal::DATA_CONSTANT, property_details_.type()); |
331 } | 328 } |
332 return value; | 329 return value; |
333 } | 330 } |
(...skipping 17 matching lines...) Expand all Loading... |
351 result ? ExoticIndexState::kIndex : ExoticIndexState::kNoIndex; | 348 result ? ExoticIndexState::kIndex : ExoticIndexState::kNoIndex; |
352 return result; | 349 return result; |
353 } | 350 } |
354 | 351 |
355 | 352 |
356 void LookupIterator::InternalizeName() { | 353 void LookupIterator::InternalizeName() { |
357 if (name_->IsUniqueName()) return; | 354 if (name_->IsUniqueName()) return; |
358 name_ = factory()->InternalizeString(Handle<String>::cast(name_)); | 355 name_ = factory()->InternalizeString(Handle<String>::cast(name_)); |
359 } | 356 } |
360 } } // namespace v8::internal | 357 } } // namespace v8::internal |
OLD | NEW |