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 <iomanip> | 5 #include <iomanip> |
6 #include <sstream> | 6 #include <sstream> |
7 | 7 |
8 #include "src/v8.h" | 8 #include "src/v8.h" |
9 | 9 |
10 #include "src/accessors.h" | 10 #include "src/accessors.h" |
(...skipping 4115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4126 | 4126 |
4127 | 4127 |
4128 // static | 4128 // static |
4129 void ExecutableAccessorInfo::ClearSetter(Handle<ExecutableAccessorInfo> info) { | 4129 void ExecutableAccessorInfo::ClearSetter(Handle<ExecutableAccessorInfo> info) { |
4130 Handle<Object> object = v8::FromCData(info->GetIsolate(), nullptr); | 4130 Handle<Object> object = v8::FromCData(info->GetIsolate(), nullptr); |
4131 info->set_setter(*object); | 4131 info->set_setter(*object); |
4132 } | 4132 } |
4133 | 4133 |
4134 | 4134 |
4135 MaybeHandle<Object> JSObject::ReconfigureAsDataProperty( | 4135 MaybeHandle<Object> JSObject::ReconfigureAsDataProperty( |
4136 LookupIterator* it, Handle<Object> value, PropertyAttributes attributes) { | 4136 LookupIterator* it, Handle<Object> value, PropertyAttributes attributes, |
| 4137 ExecutableAccessorInfoHandling handling) { |
4137 Handle<JSObject> object = Handle<JSObject>::cast(it->GetReceiver()); | 4138 Handle<JSObject> object = Handle<JSObject>::cast(it->GetReceiver()); |
4138 bool is_observed = object->map()->is_observed() && | 4139 bool is_observed = object->map()->is_observed() && |
4139 (it->IsElement() || | 4140 (it->IsElement() || |
4140 !it->isolate()->IsInternallyUsedPropertyName(it->name())); | 4141 !it->isolate()->IsInternallyUsedPropertyName(it->name())); |
4141 | 4142 |
4142 switch (it->state()) { | 4143 switch (it->state()) { |
4143 case LookupIterator::INTERCEPTOR: | 4144 case LookupIterator::INTERCEPTOR: |
4144 case LookupIterator::JSPROXY: | 4145 case LookupIterator::JSPROXY: |
4145 case LookupIterator::NOT_FOUND: | 4146 case LookupIterator::NOT_FOUND: |
4146 case LookupIterator::TRANSITION: | 4147 case LookupIterator::TRANSITION: |
4147 case LookupIterator::ACCESS_CHECK: | 4148 case LookupIterator::ACCESS_CHECK: |
4148 UNREACHABLE(); | 4149 UNREACHABLE(); |
4149 | 4150 |
4150 case LookupIterator::INTEGER_INDEXED_EXOTIC: | 4151 case LookupIterator::INTEGER_INDEXED_EXOTIC: |
4151 return value; | 4152 return value; |
4152 | 4153 |
4153 case LookupIterator::ACCESSOR: { | 4154 case LookupIterator::ACCESSOR: { |
4154 PropertyDetails details = it->property_details(); | 4155 PropertyDetails details = it->property_details(); |
4155 // Ensure the context isn't changed after calling into accessors. | 4156 // Ensure the context isn't changed after calling into accessors. |
4156 AssertNoContextChange ncc(it->isolate()); | 4157 AssertNoContextChange ncc(it->isolate()); |
4157 | 4158 |
4158 Handle<Object> accessors = it->GetAccessors(); | 4159 Handle<Object> accessors = it->GetAccessors(); |
4159 | 4160 |
4160 // Special handling for ExecutableAccessorInfo, which behaves like a | 4161 // Special handling for ExecutableAccessorInfo, which behaves like a |
4161 // data property. | 4162 // data property. |
4162 if (accessors->IsExecutableAccessorInfo()) { | 4163 if (accessors->IsExecutableAccessorInfo() && |
| 4164 handling == DONT_FORCE_FIELD) { |
4163 Handle<Object> result; | 4165 Handle<Object> result; |
4164 ASSIGN_RETURN_ON_EXCEPTION( | 4166 ASSIGN_RETURN_ON_EXCEPTION( |
4165 it->isolate(), result, | 4167 it->isolate(), result, |
4166 JSObject::SetPropertyWithAccessor(it, value, STRICT), Object); | 4168 JSObject::SetPropertyWithAccessor(it, value, STRICT), Object); |
4167 DCHECK(result->SameValue(*value)); | 4169 DCHECK(result->SameValue(*value)); |
4168 | 4170 |
4169 if (details.attributes() == attributes) return value; | 4171 if (details.attributes() == attributes) return value; |
4170 | 4172 |
4171 // Reconfigure the accessor if attributes mismatch. | 4173 // Reconfigure the accessor if attributes mismatch. |
4172 Handle<ExecutableAccessorInfo> new_data = Accessors::CloneAccessor( | 4174 Handle<ExecutableAccessorInfo> new_data = Accessors::CloneAccessor( |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4245 } | 4247 } |
4246 | 4248 |
4247 return value; | 4249 return value; |
4248 } | 4250 } |
4249 | 4251 |
4250 | 4252 |
4251 // Reconfigures a property to a data property with attributes, even if it is not | 4253 // Reconfigures a property to a data property with attributes, even if it is not |
4252 // reconfigurable. | 4254 // reconfigurable. |
4253 MaybeHandle<Object> JSObject::SetOwnPropertyIgnoreAttributes( | 4255 MaybeHandle<Object> JSObject::SetOwnPropertyIgnoreAttributes( |
4254 Handle<JSObject> object, Handle<Name> name, Handle<Object> value, | 4256 Handle<JSObject> object, Handle<Name> name, Handle<Object> value, |
4255 PropertyAttributes attributes) { | 4257 PropertyAttributes attributes, ExecutableAccessorInfoHandling handling) { |
4256 DCHECK(!value->IsTheHole()); | 4258 DCHECK(!value->IsTheHole()); |
4257 LookupIterator it(object, name, LookupIterator::OWN_SKIP_INTERCEPTOR); | 4259 LookupIterator it(object, name, LookupIterator::OWN_SKIP_INTERCEPTOR); |
4258 if (it.state() == LookupIterator::ACCESS_CHECK) { | 4260 if (it.state() == LookupIterator::ACCESS_CHECK) { |
4259 if (!it.isolate()->MayAccess(object)) { | 4261 if (!it.isolate()->MayAccess(object)) { |
4260 return SetPropertyWithFailedAccessCheck(&it, value, SLOPPY); | 4262 return SetPropertyWithFailedAccessCheck(&it, value, SLOPPY); |
4261 } | 4263 } |
4262 it.Next(); | 4264 it.Next(); |
4263 } | 4265 } |
4264 | 4266 |
4265 if (it.IsFound()) { | 4267 if (it.IsFound()) { |
4266 return ReconfigureAsDataProperty(&it, value, attributes); | 4268 return ReconfigureAsDataProperty(&it, value, attributes, handling); |
4267 } | 4269 } |
4268 | 4270 |
4269 return AddDataProperty(&it, value, attributes, STRICT, | 4271 return AddDataProperty(&it, value, attributes, STRICT, |
4270 CERTAINLY_NOT_STORE_FROM_KEYED); | 4272 CERTAINLY_NOT_STORE_FROM_KEYED); |
4271 } | 4273 } |
4272 | 4274 |
4273 | 4275 |
4274 MaybeHandle<Object> JSObject::SetOwnElementIgnoreAttributes( | 4276 MaybeHandle<Object> JSObject::SetOwnElementIgnoreAttributes( |
4275 Handle<JSObject> object, uint32_t index, Handle<Object> value, | 4277 Handle<JSObject> object, uint32_t index, Handle<Object> value, |
4276 PropertyAttributes attributes) { | 4278 PropertyAttributes attributes, ExecutableAccessorInfoHandling handling) { |
4277 DCHECK(!object->HasExternalArrayElements()); | 4279 DCHECK(!object->HasExternalArrayElements()); |
4278 Isolate* isolate = object->GetIsolate(); | 4280 Isolate* isolate = object->GetIsolate(); |
4279 LookupIterator it(isolate, object, index, | 4281 LookupIterator it(isolate, object, index, |
4280 LookupIterator::OWN_SKIP_INTERCEPTOR); | 4282 LookupIterator::OWN_SKIP_INTERCEPTOR); |
4281 if (it.state() == LookupIterator::ACCESS_CHECK) { | 4283 if (it.state() == LookupIterator::ACCESS_CHECK) { |
4282 if (!isolate->MayAccess(object)) { | 4284 if (!isolate->MayAccess(object)) { |
4283 return SetPropertyWithFailedAccessCheck(&it, value, STRICT); | 4285 return SetPropertyWithFailedAccessCheck(&it, value, STRICT); |
4284 } | 4286 } |
4285 it.Next(); | 4287 it.Next(); |
4286 } | 4288 } |
4287 | 4289 |
4288 if (it.IsFound()) { | 4290 if (it.IsFound()) { |
4289 return ReconfigureAsDataProperty(&it, value, attributes); | 4291 return ReconfigureAsDataProperty(&it, value, attributes, handling); |
4290 } | 4292 } |
4291 | 4293 |
4292 return AddDataProperty(&it, value, attributes, STRICT, | 4294 return AddDataProperty(&it, value, attributes, STRICT, |
4293 MAY_BE_STORE_FROM_KEYED); | 4295 MAY_BE_STORE_FROM_KEYED); |
4294 } | 4296 } |
4295 | 4297 |
4296 | 4298 |
4297 Maybe<PropertyAttributes> JSObject::GetPropertyAttributesWithInterceptor( | 4299 Maybe<PropertyAttributes> JSObject::GetPropertyAttributesWithInterceptor( |
4298 LookupIterator* it) { | 4300 LookupIterator* it) { |
4299 Isolate* isolate = it->isolate(); | 4301 Isolate* isolate = it->isolate(); |
(...skipping 12428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16728 Handle<Object> new_value) { | 16730 Handle<Object> new_value) { |
16729 if (cell->value() != *new_value) { | 16731 if (cell->value() != *new_value) { |
16730 cell->set_value(*new_value); | 16732 cell->set_value(*new_value); |
16731 Isolate* isolate = cell->GetIsolate(); | 16733 Isolate* isolate = cell->GetIsolate(); |
16732 cell->dependent_code()->DeoptimizeDependentCodeGroup( | 16734 cell->dependent_code()->DeoptimizeDependentCodeGroup( |
16733 isolate, DependentCode::kPropertyCellChangedGroup); | 16735 isolate, DependentCode::kPropertyCellChangedGroup); |
16734 } | 16736 } |
16735 } | 16737 } |
16736 } // namespace internal | 16738 } // namespace internal |
16737 } // namespace v8 | 16739 } // namespace v8 |
OLD | NEW |