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 5321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5332 } | 5332 } |
5333 return Just(true); | 5333 return Just(true); |
5334 } | 5334 } |
5335 } | 5335 } |
5336 } | 5336 } |
5337 | 5337 |
5338 return AddDataProperty(it, value, attributes, should_throw, | 5338 return AddDataProperty(it, value, attributes, should_throw, |
5339 CERTAINLY_NOT_STORE_FROM_KEYED); | 5339 CERTAINLY_NOT_STORE_FROM_KEYED); |
5340 } | 5340 } |
5341 | 5341 |
5342 | |
5343 MaybeHandle<Object> JSObject::SetOwnPropertyIgnoreAttributes( | 5342 MaybeHandle<Object> JSObject::SetOwnPropertyIgnoreAttributes( |
5344 Handle<JSObject> object, Handle<Name> name, Handle<Object> value, | 5343 Handle<JSObject> object, Handle<Name> name, Handle<Object> value, |
5345 PropertyAttributes attributes, AccessorInfoHandling handling) { | 5344 PropertyAttributes attributes) { |
5346 DCHECK(!value->IsTheHole()); | 5345 DCHECK(!value->IsTheHole()); |
5347 LookupIterator it(object, name, LookupIterator::OWN); | 5346 LookupIterator it(object, name, LookupIterator::OWN); |
5348 return DefineOwnPropertyIgnoreAttributes(&it, value, attributes, handling); | 5347 return DefineOwnPropertyIgnoreAttributes(&it, value, attributes); |
| 5348 } |
| 5349 |
| 5350 MaybeHandle<Object> JSObject::SetOwnElementIgnoreAttributes( |
| 5351 Handle<JSObject> object, uint32_t index, Handle<Object> value, |
| 5352 PropertyAttributes attributes) { |
| 5353 Isolate* isolate = object->GetIsolate(); |
| 5354 LookupIterator it(isolate, object, index, LookupIterator::OWN); |
| 5355 return DefineOwnPropertyIgnoreAttributes(&it, value, attributes); |
| 5356 } |
| 5357 |
| 5358 MaybeHandle<Object> JSObject::DefinePropertyOrElementIgnoreAttributes( |
| 5359 Handle<JSObject> object, Handle<Name> name, Handle<Object> value, |
| 5360 PropertyAttributes attributes) { |
| 5361 Isolate* isolate = object->GetIsolate(); |
| 5362 LookupIterator it = LookupIterator::PropertyOrElement(isolate, object, name, |
| 5363 LookupIterator::OWN); |
| 5364 return DefineOwnPropertyIgnoreAttributes(&it, value, attributes); |
5349 } | 5365 } |
5350 | 5366 |
5351 | 5367 |
5352 MaybeHandle<Object> JSObject::SetOwnElementIgnoreAttributes( | |
5353 Handle<JSObject> object, uint32_t index, Handle<Object> value, | |
5354 PropertyAttributes attributes, AccessorInfoHandling handling) { | |
5355 Isolate* isolate = object->GetIsolate(); | |
5356 LookupIterator it(isolate, object, index, LookupIterator::OWN); | |
5357 return DefineOwnPropertyIgnoreAttributes(&it, value, attributes, handling); | |
5358 } | |
5359 | |
5360 | |
5361 MaybeHandle<Object> JSObject::DefinePropertyOrElementIgnoreAttributes( | |
5362 Handle<JSObject> object, Handle<Name> name, Handle<Object> value, | |
5363 PropertyAttributes attributes, AccessorInfoHandling handling) { | |
5364 Isolate* isolate = object->GetIsolate(); | |
5365 LookupIterator it = LookupIterator::PropertyOrElement(isolate, object, name, | |
5366 LookupIterator::OWN); | |
5367 return DefineOwnPropertyIgnoreAttributes(&it, value, attributes, handling); | |
5368 } | |
5369 | |
5370 | |
5371 Maybe<PropertyAttributes> JSObject::GetPropertyAttributesWithInterceptor( | 5368 Maybe<PropertyAttributes> JSObject::GetPropertyAttributesWithInterceptor( |
5372 LookupIterator* it) { | 5369 LookupIterator* it) { |
5373 Isolate* isolate = it->isolate(); | 5370 Isolate* isolate = it->isolate(); |
5374 // Make sure that the top context does not change when doing | 5371 // Make sure that the top context does not change when doing |
5375 // callbacks or interceptor calls. | 5372 // callbacks or interceptor calls. |
5376 AssertNoContextChange ncc(isolate); | 5373 AssertNoContextChange ncc(isolate); |
5377 HandleScope scope(isolate); | 5374 HandleScope scope(isolate); |
5378 | 5375 |
5379 Handle<JSObject> holder = it->GetHolder<JSObject>(); | 5376 Handle<JSObject> holder = it->GetHolder<JSObject>(); |
5380 Handle<InterceptorInfo> interceptor(it->GetInterceptor()); | 5377 Handle<InterceptorInfo> interceptor(it->GetInterceptor()); |
(...skipping 1214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6595 // created property is set to its default value. | 6592 // created property is set to its default value. |
6596 if (it != NULL) { | 6593 if (it != NULL) { |
6597 if (!desc->has_writable()) desc->set_writable(false); | 6594 if (!desc->has_writable()) desc->set_writable(false); |
6598 if (!desc->has_enumerable()) desc->set_enumerable(false); | 6595 if (!desc->has_enumerable()) desc->set_enumerable(false); |
6599 if (!desc->has_configurable()) desc->set_configurable(false); | 6596 if (!desc->has_configurable()) desc->set_configurable(false); |
6600 Handle<Object> value( | 6597 Handle<Object> value( |
6601 desc->has_value() | 6598 desc->has_value() |
6602 ? desc->value() | 6599 ? desc->value() |
6603 : Handle<Object>::cast(isolate->factory()->undefined_value())); | 6600 : Handle<Object>::cast(isolate->factory()->undefined_value())); |
6604 MaybeHandle<Object> result = | 6601 MaybeHandle<Object> result = |
6605 JSObject::DefineOwnPropertyIgnoreAttributes( | 6602 JSObject::DefineOwnPropertyIgnoreAttributes(it, value, |
6606 it, value, desc->ToAttributes(), JSObject::DONT_FORCE_FIELD); | 6603 desc->ToAttributes()); |
6607 if (result.is_null()) return Nothing<bool>(); | 6604 if (result.is_null()) return Nothing<bool>(); |
6608 } | 6605 } |
6609 } else { | 6606 } else { |
6610 // 2d. Else Desc must be an accessor Property Descriptor, | 6607 // 2d. Else Desc must be an accessor Property Descriptor, |
6611 DCHECK(desc_is_accessor_descriptor); | 6608 DCHECK(desc_is_accessor_descriptor); |
6612 // 2d i. If O is not undefined, create an own accessor property named P | 6609 // 2d i. If O is not undefined, create an own accessor property named P |
6613 // of object O whose [[Get]], [[Set]], [[Enumerable]] and | 6610 // of object O whose [[Get]], [[Set]], [[Enumerable]] and |
6614 // [[Configurable]] attribute values are described by Desc. If the value | 6611 // [[Configurable]] attribute values are described by Desc. If the value |
6615 // of an attribute field of Desc is absent, the attribute of the newly | 6612 // of an attribute field of Desc is absent, the attribute of the newly |
6616 // created property is set to its default value. | 6613 // created property is set to its default value. |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6788 } else { | 6785 } else { |
6789 attrs = static_cast<PropertyAttributes>( | 6786 attrs = static_cast<PropertyAttributes>( |
6790 attrs | (current->writable() ? NONE : READ_ONLY)); | 6787 attrs | (current->writable() ? NONE : READ_ONLY)); |
6791 } | 6788 } |
6792 Handle<Object> value( | 6789 Handle<Object> value( |
6793 desc->has_value() ? desc->value() | 6790 desc->has_value() ? desc->value() |
6794 : current->has_value() | 6791 : current->has_value() |
6795 ? current->value() | 6792 ? current->value() |
6796 : Handle<Object>::cast( | 6793 : Handle<Object>::cast( |
6797 isolate->factory()->undefined_value())); | 6794 isolate->factory()->undefined_value())); |
6798 MaybeHandle<Object> result = JSObject::DefineOwnPropertyIgnoreAttributes( | 6795 MaybeHandle<Object> result = |
6799 it, value, attrs, JSObject::DONT_FORCE_FIELD); | 6796 JSObject::DefineOwnPropertyIgnoreAttributes(it, value, attrs); |
6800 if (result.is_null()) return Nothing<bool>(); | 6797 if (result.is_null()) return Nothing<bool>(); |
6801 } else { | 6798 } else { |
6802 DCHECK(desc_is_accessor_descriptor || | 6799 DCHECK(desc_is_accessor_descriptor || |
6803 (desc_is_generic_descriptor && | 6800 (desc_is_generic_descriptor && |
6804 PropertyDescriptor::IsAccessorDescriptor(current))); | 6801 PropertyDescriptor::IsAccessorDescriptor(current))); |
6805 Handle<Object> getter( | 6802 Handle<Object> getter( |
6806 desc->has_get() | 6803 desc->has_get() |
6807 ? desc->get() | 6804 ? desc->get() |
6808 : current->has_get() | 6805 : current->has_get() |
6809 ? current->get() | 6806 ? current->get() |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6853 DCHECK(it->GetReceiver()->IsJSObject()); | 6850 DCHECK(it->GetReceiver()->IsJSObject()); |
6854 MAYBE_RETURN(JSReceiver::GetPropertyAttributes(it), Nothing<bool>()); | 6851 MAYBE_RETURN(JSReceiver::GetPropertyAttributes(it), Nothing<bool>()); |
6855 | 6852 |
6856 if (it->IsFound()) { | 6853 if (it->IsFound()) { |
6857 if (!it->IsConfigurable()) return Just(false); | 6854 if (!it->IsConfigurable()) return Just(false); |
6858 } else { | 6855 } else { |
6859 if (!JSObject::IsExtensible(Handle<JSObject>::cast(it->GetReceiver()))) | 6856 if (!JSObject::IsExtensible(Handle<JSObject>::cast(it->GetReceiver()))) |
6860 return Just(false); | 6857 return Just(false); |
6861 } | 6858 } |
6862 | 6859 |
6863 RETURN_ON_EXCEPTION_VALUE( | 6860 RETURN_ON_EXCEPTION_VALUE(it->isolate(), |
6864 it->isolate(), | 6861 DefineOwnPropertyIgnoreAttributes(it, value, NONE), |
6865 DefineOwnPropertyIgnoreAttributes(it, value, NONE, DONT_FORCE_FIELD), | 6862 Nothing<bool>()); |
6866 Nothing<bool>()); | |
6867 | 6863 |
6868 return Just(true); | 6864 return Just(true); |
6869 } | 6865 } |
6870 | 6866 |
6871 | 6867 |
6872 // TODO(jkummerow): Consider unification with FastAsArrayLength() in | 6868 // TODO(jkummerow): Consider unification with FastAsArrayLength() in |
6873 // accessors.cc. | 6869 // accessors.cc. |
6874 bool PropertyKeyToArrayLength(Handle<Object> value, uint32_t* length) { | 6870 bool PropertyKeyToArrayLength(Handle<Object> value, uint32_t* length) { |
6875 DCHECK(value->IsNumber() || value->IsName()); | 6871 DCHECK(value->IsNumber() || value->IsName()); |
6876 if (value->ToArrayLength(length)) return true; | 6872 if (value->ToArrayLength(length)) return true; |
(...skipping 12906 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
19783 if (cell->value() != *new_value) { | 19779 if (cell->value() != *new_value) { |
19784 cell->set_value(*new_value); | 19780 cell->set_value(*new_value); |
19785 Isolate* isolate = cell->GetIsolate(); | 19781 Isolate* isolate = cell->GetIsolate(); |
19786 cell->dependent_code()->DeoptimizeDependentCodeGroup( | 19782 cell->dependent_code()->DeoptimizeDependentCodeGroup( |
19787 isolate, DependentCode::kPropertyCellChangedGroup); | 19783 isolate, DependentCode::kPropertyCellChangedGroup); |
19788 } | 19784 } |
19789 } | 19785 } |
19790 | 19786 |
19791 } // namespace internal | 19787 } // namespace internal |
19792 } // namespace v8 | 19788 } // namespace v8 |
OLD | NEW |