Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(331)

Side by Side Diff: src/objects.cc

Issue 1643563002: [runtime] further dismantle AccessorInfoHandling, reducing it to the single API usecase. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/objects.h ('k') | src/runtime/runtime-scopes.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 5319 matching lines...) Expand 10 before | Expand all | Expand 10 after
5330 } 5330 }
5331 return Just(true); 5331 return Just(true);
5332 } 5332 }
5333 } 5333 }
5334 } 5334 }
5335 5335
5336 return AddDataProperty(it, value, attributes, should_throw, 5336 return AddDataProperty(it, value, attributes, should_throw,
5337 CERTAINLY_NOT_STORE_FROM_KEYED); 5337 CERTAINLY_NOT_STORE_FROM_KEYED);
5338 } 5338 }
5339 5339
5340
5341 MaybeHandle<Object> JSObject::SetOwnPropertyIgnoreAttributes( 5340 MaybeHandle<Object> JSObject::SetOwnPropertyIgnoreAttributes(
5342 Handle<JSObject> object, Handle<Name> name, Handle<Object> value, 5341 Handle<JSObject> object, Handle<Name> name, Handle<Object> value,
5343 PropertyAttributes attributes, AccessorInfoHandling handling) { 5342 PropertyAttributes attributes) {
5344 DCHECK(!value->IsTheHole()); 5343 DCHECK(!value->IsTheHole());
5345 LookupIterator it(object, name, LookupIterator::OWN); 5344 LookupIterator it(object, name, LookupIterator::OWN);
5346 return DefineOwnPropertyIgnoreAttributes(&it, value, attributes, handling); 5345 return DefineOwnPropertyIgnoreAttributes(&it, value, attributes);
5346 }
5347
5348 MaybeHandle<Object> JSObject::SetOwnElementIgnoreAttributes(
5349 Handle<JSObject> object, uint32_t index, Handle<Object> value,
5350 PropertyAttributes attributes) {
5351 Isolate* isolate = object->GetIsolate();
5352 LookupIterator it(isolate, object, index, LookupIterator::OWN);
5353 return DefineOwnPropertyIgnoreAttributes(&it, value, attributes);
5354 }
5355
5356 MaybeHandle<Object> JSObject::DefinePropertyOrElementIgnoreAttributes(
5357 Handle<JSObject> object, Handle<Name> name, Handle<Object> value,
5358 PropertyAttributes attributes) {
5359 Isolate* isolate = object->GetIsolate();
5360 LookupIterator it = LookupIterator::PropertyOrElement(isolate, object, name,
5361 LookupIterator::OWN);
5362 return DefineOwnPropertyIgnoreAttributes(&it, value, attributes);
5347 } 5363 }
5348 5364
5349 5365
5350 MaybeHandle<Object> JSObject::SetOwnElementIgnoreAttributes(
5351 Handle<JSObject> object, uint32_t index, Handle<Object> value,
5352 PropertyAttributes attributes, AccessorInfoHandling handling) {
5353 Isolate* isolate = object->GetIsolate();
5354 LookupIterator it(isolate, object, index, LookupIterator::OWN);
5355 return DefineOwnPropertyIgnoreAttributes(&it, value, attributes, handling);
5356 }
5357
5358
5359 MaybeHandle<Object> JSObject::DefinePropertyOrElementIgnoreAttributes(
5360 Handle<JSObject> object, Handle<Name> name, Handle<Object> value,
5361 PropertyAttributes attributes, AccessorInfoHandling handling) {
5362 Isolate* isolate = object->GetIsolate();
5363 LookupIterator it = LookupIterator::PropertyOrElement(isolate, object, name,
5364 LookupIterator::OWN);
5365 return DefineOwnPropertyIgnoreAttributes(&it, value, attributes, handling);
5366 }
5367
5368
5369 Maybe<PropertyAttributes> JSObject::GetPropertyAttributesWithInterceptor( 5366 Maybe<PropertyAttributes> JSObject::GetPropertyAttributesWithInterceptor(
5370 LookupIterator* it) { 5367 LookupIterator* it) {
5371 Isolate* isolate = it->isolate(); 5368 Isolate* isolate = it->isolate();
5372 // Make sure that the top context does not change when doing 5369 // Make sure that the top context does not change when doing
5373 // callbacks or interceptor calls. 5370 // callbacks or interceptor calls.
5374 AssertNoContextChange ncc(isolate); 5371 AssertNoContextChange ncc(isolate);
5375 HandleScope scope(isolate); 5372 HandleScope scope(isolate);
5376 5373
5377 Handle<JSObject> holder = it->GetHolder<JSObject>(); 5374 Handle<JSObject> holder = it->GetHolder<JSObject>();
5378 Handle<InterceptorInfo> interceptor(it->GetInterceptor()); 5375 Handle<InterceptorInfo> interceptor(it->GetInterceptor());
(...skipping 1208 matching lines...) Expand 10 before | Expand all | Expand 10 after
6587 // created property is set to its default value. 6584 // created property is set to its default value.
6588 if (it != NULL) { 6585 if (it != NULL) {
6589 if (!desc->has_writable()) desc->set_writable(false); 6586 if (!desc->has_writable()) desc->set_writable(false);
6590 if (!desc->has_enumerable()) desc->set_enumerable(false); 6587 if (!desc->has_enumerable()) desc->set_enumerable(false);
6591 if (!desc->has_configurable()) desc->set_configurable(false); 6588 if (!desc->has_configurable()) desc->set_configurable(false);
6592 Handle<Object> value( 6589 Handle<Object> value(
6593 desc->has_value() 6590 desc->has_value()
6594 ? desc->value() 6591 ? desc->value()
6595 : Handle<Object>::cast(isolate->factory()->undefined_value())); 6592 : Handle<Object>::cast(isolate->factory()->undefined_value()));
6596 MaybeHandle<Object> result = 6593 MaybeHandle<Object> result =
6597 JSObject::DefineOwnPropertyIgnoreAttributes( 6594 JSObject::DefineOwnPropertyIgnoreAttributes(it, value,
6598 it, value, desc->ToAttributes(), JSObject::DONT_FORCE_FIELD); 6595 desc->ToAttributes());
6599 if (result.is_null()) return Nothing<bool>(); 6596 if (result.is_null()) return Nothing<bool>();
6600 } 6597 }
6601 } else { 6598 } else {
6602 // 2d. Else Desc must be an accessor Property Descriptor, 6599 // 2d. Else Desc must be an accessor Property Descriptor,
6603 DCHECK(desc_is_accessor_descriptor); 6600 DCHECK(desc_is_accessor_descriptor);
6604 // 2d i. If O is not undefined, create an own accessor property named P 6601 // 2d i. If O is not undefined, create an own accessor property named P
6605 // of object O whose [[Get]], [[Set]], [[Enumerable]] and 6602 // of object O whose [[Get]], [[Set]], [[Enumerable]] and
6606 // [[Configurable]] attribute values are described by Desc. If the value 6603 // [[Configurable]] attribute values are described by Desc. If the value
6607 // of an attribute field of Desc is absent, the attribute of the newly 6604 // of an attribute field of Desc is absent, the attribute of the newly
6608 // created property is set to its default value. 6605 // created property is set to its default value.
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
6780 } else { 6777 } else {
6781 attrs = static_cast<PropertyAttributes>( 6778 attrs = static_cast<PropertyAttributes>(
6782 attrs | (current->writable() ? NONE : READ_ONLY)); 6779 attrs | (current->writable() ? NONE : READ_ONLY));
6783 } 6780 }
6784 Handle<Object> value( 6781 Handle<Object> value(
6785 desc->has_value() ? desc->value() 6782 desc->has_value() ? desc->value()
6786 : current->has_value() 6783 : current->has_value()
6787 ? current->value() 6784 ? current->value()
6788 : Handle<Object>::cast( 6785 : Handle<Object>::cast(
6789 isolate->factory()->undefined_value())); 6786 isolate->factory()->undefined_value()));
6790 MaybeHandle<Object> result = JSObject::DefineOwnPropertyIgnoreAttributes( 6787 MaybeHandle<Object> result =
6791 it, value, attrs, JSObject::DONT_FORCE_FIELD); 6788 JSObject::DefineOwnPropertyIgnoreAttributes(it, value, attrs);
6792 if (result.is_null()) return Nothing<bool>(); 6789 if (result.is_null()) return Nothing<bool>();
6793 } else { 6790 } else {
6794 DCHECK(desc_is_accessor_descriptor || 6791 DCHECK(desc_is_accessor_descriptor ||
6795 (desc_is_generic_descriptor && 6792 (desc_is_generic_descriptor &&
6796 PropertyDescriptor::IsAccessorDescriptor(current))); 6793 PropertyDescriptor::IsAccessorDescriptor(current)));
6797 Handle<Object> getter( 6794 Handle<Object> getter(
6798 desc->has_get() 6795 desc->has_get()
6799 ? desc->get() 6796 ? desc->get()
6800 : current->has_get() 6797 : current->has_get()
6801 ? current->get() 6798 ? current->get()
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
6845 DCHECK(it->GetReceiver()->IsJSObject()); 6842 DCHECK(it->GetReceiver()->IsJSObject());
6846 MAYBE_RETURN(JSReceiver::GetPropertyAttributes(it), Nothing<bool>()); 6843 MAYBE_RETURN(JSReceiver::GetPropertyAttributes(it), Nothing<bool>());
6847 6844
6848 if (it->IsFound()) { 6845 if (it->IsFound()) {
6849 if (!it->IsConfigurable()) return Just(false); 6846 if (!it->IsConfigurable()) return Just(false);
6850 } else { 6847 } else {
6851 if (!JSObject::IsExtensible(Handle<JSObject>::cast(it->GetReceiver()))) 6848 if (!JSObject::IsExtensible(Handle<JSObject>::cast(it->GetReceiver())))
6852 return Just(false); 6849 return Just(false);
6853 } 6850 }
6854 6851
6855 RETURN_ON_EXCEPTION_VALUE( 6852 RETURN_ON_EXCEPTION_VALUE(it->isolate(),
6856 it->isolate(), 6853 DefineOwnPropertyIgnoreAttributes(it, value, NONE),
6857 DefineOwnPropertyIgnoreAttributes(it, value, NONE, DONT_FORCE_FIELD), 6854 Nothing<bool>());
6858 Nothing<bool>());
6859 6855
6860 return Just(true); 6856 return Just(true);
6861 } 6857 }
6862 6858
6863 6859
6864 // TODO(jkummerow): Consider unification with FastAsArrayLength() in 6860 // TODO(jkummerow): Consider unification with FastAsArrayLength() in
6865 // accessors.cc. 6861 // accessors.cc.
6866 bool PropertyKeyToArrayLength(Handle<Object> value, uint32_t* length) { 6862 bool PropertyKeyToArrayLength(Handle<Object> value, uint32_t* length) {
6867 DCHECK(value->IsNumber() || value->IsName()); 6863 DCHECK(value->IsNumber() || value->IsName());
6868 if (value->ToArrayLength(length)) return true; 6864 if (value->ToArrayLength(length)) return true;
(...skipping 12880 matching lines...) Expand 10 before | Expand all | Expand 10 after
19749 if (cell->value() != *new_value) { 19745 if (cell->value() != *new_value) {
19750 cell->set_value(*new_value); 19746 cell->set_value(*new_value);
19751 Isolate* isolate = cell->GetIsolate(); 19747 Isolate* isolate = cell->GetIsolate();
19752 cell->dependent_code()->DeoptimizeDependentCodeGroup( 19748 cell->dependent_code()->DeoptimizeDependentCodeGroup(
19753 isolate, DependentCode::kPropertyCellChangedGroup); 19749 isolate, DependentCode::kPropertyCellChangedGroup);
19754 } 19750 }
19755 } 19751 }
19756 19752
19757 } // namespace internal 19753 } // namespace internal
19758 } // namespace v8 19754 } // namespace v8
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/runtime/runtime-scopes.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698