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 <sstream> | 9 #include <sstream> |
10 | 10 |
(...skipping 5186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5197 DCHECK(!it.IsFound()); | 5197 DCHECK(!it.IsFound()); |
5198 DCHECK(object->map()->is_extensible() || | 5198 DCHECK(object->map()->is_extensible() || |
5199 it.isolate()->IsInternallyUsedPropertyName(name)); | 5199 it.isolate()->IsInternallyUsedPropertyName(name)); |
5200 #endif | 5200 #endif |
5201 CHECK(AddDataProperty(&it, value, attributes, THROW_ON_ERROR, | 5201 CHECK(AddDataProperty(&it, value, attributes, THROW_ON_ERROR, |
5202 CERTAINLY_NOT_STORE_FROM_KEYED) | 5202 CERTAINLY_NOT_STORE_FROM_KEYED) |
5203 .IsJust()); | 5203 .IsJust()); |
5204 } | 5204 } |
5205 | 5205 |
5206 | 5206 |
5207 // static | |
5208 void AccessorInfo::ClearSetter(Handle<AccessorInfo> info) { | |
5209 Handle<Object> object = v8::FromCData(info->GetIsolate(), nullptr); | |
5210 info->set_setter(*object); | |
5211 } | |
5212 | |
5213 | |
5214 // Reconfigures a property to a data property with attributes, even if it is not | 5207 // Reconfigures a property to a data property with attributes, even if it is not |
5215 // reconfigurable. | 5208 // reconfigurable. |
5216 // Requires a LookupIterator that does not look at the prototype chain beyond | 5209 // Requires a LookupIterator that does not look at the prototype chain beyond |
5217 // hidden prototypes. | 5210 // hidden prototypes. |
5218 MaybeHandle<Object> JSObject::DefineOwnPropertyIgnoreAttributes( | 5211 MaybeHandle<Object> JSObject::DefineOwnPropertyIgnoreAttributes( |
5219 LookupIterator* it, Handle<Object> value, PropertyAttributes attributes, | 5212 LookupIterator* it, Handle<Object> value, PropertyAttributes attributes, |
5220 AccessorInfoHandling handling) { | 5213 AccessorInfoHandling handling) { |
5221 MAYBE_RETURN_NULL(DefineOwnPropertyIgnoreAttributes( | 5214 MAYBE_RETURN_NULL(DefineOwnPropertyIgnoreAttributes( |
5222 it, value, attributes, THROW_ON_ERROR, handling)); | 5215 it, value, attributes, THROW_ON_ERROR, handling)); |
5223 return value; | 5216 return value; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5272 // Ensure the context isn't changed after calling into accessors. | 5265 // Ensure the context isn't changed after calling into accessors. |
5273 AssertNoContextChange ncc(it->isolate()); | 5266 AssertNoContextChange ncc(it->isolate()); |
5274 | 5267 |
5275 Maybe<bool> result = | 5268 Maybe<bool> result = |
5276 JSObject::SetPropertyWithAccessor(it, value, should_throw); | 5269 JSObject::SetPropertyWithAccessor(it, value, should_throw); |
5277 if (result.IsNothing() || !result.FromJust()) return result; | 5270 if (result.IsNothing() || !result.FromJust()) return result; |
5278 | 5271 |
5279 if (details.attributes() == attributes) return Just(true); | 5272 if (details.attributes() == attributes) return Just(true); |
5280 | 5273 |
5281 // Reconfigure the accessor if attributes mismatch. | 5274 // Reconfigure the accessor if attributes mismatch. |
5282 Handle<AccessorInfo> new_data = Accessors::CloneAccessor( | 5275 it->TransitionToAccessorPair(accessors, attributes); |
5283 it->isolate(), Handle<AccessorInfo>::cast(accessors)); | |
5284 new_data->set_property_attributes(attributes); | |
5285 // By clearing the setter we don't have to introduce a lookup to | |
5286 // the setter, simply make it unavailable to reflect the | |
5287 // attributes. | |
5288 if (attributes & READ_ONLY) AccessorInfo::ClearSetter(new_data); | |
5289 | |
5290 it->TransitionToAccessorPair(new_data, attributes); | |
5291 } else { | 5276 } else { |
5292 it->ReconfigureDataProperty(value, attributes); | 5277 it->ReconfigureDataProperty(value, attributes); |
5293 } | 5278 } |
5294 | 5279 |
5295 if (is_observed) { | 5280 if (is_observed) { |
5296 RETURN_ON_EXCEPTION_VALUE( | 5281 RETURN_ON_EXCEPTION_VALUE( |
5297 it->isolate(), | 5282 it->isolate(), |
5298 EnqueueChangeRecord(object, "reconfigure", it->GetName(), | 5283 EnqueueChangeRecord(object, "reconfigure", it->GetName(), |
5299 it->factory()->the_hole_value()), | 5284 it->factory()->the_hole_value()), |
5300 Nothing<bool>()); | 5285 Nothing<bool>()); |
(...skipping 14384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
19685 if (cell->value() != *new_value) { | 19670 if (cell->value() != *new_value) { |
19686 cell->set_value(*new_value); | 19671 cell->set_value(*new_value); |
19687 Isolate* isolate = cell->GetIsolate(); | 19672 Isolate* isolate = cell->GetIsolate(); |
19688 cell->dependent_code()->DeoptimizeDependentCodeGroup( | 19673 cell->dependent_code()->DeoptimizeDependentCodeGroup( |
19689 isolate, DependentCode::kPropertyCellChangedGroup); | 19674 isolate, DependentCode::kPropertyCellChangedGroup); |
19690 } | 19675 } |
19691 } | 19676 } |
19692 | 19677 |
19693 } // namespace internal | 19678 } // namespace internal |
19694 } // namespace v8 | 19679 } // namespace v8 |
OLD | NEW |