diff --git a/src/api.cc b/src/api.cc index 8830c2b926..f259c1c406 100644 --- a/src/api.cc +++ b/src/api.cc @@ -3557,8 +3557,7 @@ static i::MaybeHandle DefineObjectProperty( isolate, js_object, key, &success, i::LookupIterator::OWN); if (!success) return i::MaybeHandle(); - return i::JSObject::DefineOwnPropertyIgnoreAttributes( - &it, value, attrs, i::JSObject::FORCE_FIELD); + return i::JSObject::DefineOwnPropertyIgnoreAttributes(&it, value, attrs); } diff --git a/src/objects.cc b/src/objects.cc index 2f8a6db3c4..ab6fa54859 100644 --- a/src/objects.cc +++ b/src/objects.cc @@ -5337,29 +5337,32 @@ Maybe JSObject::DefineOwnPropertyIgnoreAttributes( CERTAINLY_NOT_STORE_FROM_KEYED); } + MaybeHandle JSObject::SetOwnPropertyIgnoreAttributes( Handle object, Handle name, Handle value, - PropertyAttributes attributes) { + PropertyAttributes attributes, AccessorInfoHandling handling) { DCHECK(!value->IsTheHole()); LookupIterator it(object, name, LookupIterator::OWN); - return DefineOwnPropertyIgnoreAttributes(&it, value, attributes); + return DefineOwnPropertyIgnoreAttributes(&it, value, attributes, handling); } + MaybeHandle JSObject::SetOwnElementIgnoreAttributes( Handle object, uint32_t index, Handle value, - PropertyAttributes attributes) { + PropertyAttributes attributes, AccessorInfoHandling handling) { Isolate* isolate = object->GetIsolate(); LookupIterator it(isolate, object, index, LookupIterator::OWN); - return DefineOwnPropertyIgnoreAttributes(&it, value, attributes); + return DefineOwnPropertyIgnoreAttributes(&it, value, attributes, handling); } + MaybeHandle JSObject::DefinePropertyOrElementIgnoreAttributes( Handle object, Handle name, Handle value, - PropertyAttributes attributes) { + PropertyAttributes attributes, AccessorInfoHandling handling) { Isolate* isolate = object->GetIsolate(); LookupIterator it = LookupIterator::PropertyOrElement(isolate, object, name, LookupIterator::OWN); - return DefineOwnPropertyIgnoreAttributes(&it, value, attributes); + return DefineOwnPropertyIgnoreAttributes(&it, value, attributes, handling); } @@ -6591,8 +6594,8 @@ Maybe JSReceiver::ValidateAndApplyPropertyDescriptor( ? desc->value() : Handle::cast(isolate->factory()->undefined_value())); MaybeHandle result = - JSObject::DefineOwnPropertyIgnoreAttributes(it, value, - desc->ToAttributes()); + JSObject::DefineOwnPropertyIgnoreAttributes( + it, value, desc->ToAttributes(), JSObject::DONT_FORCE_FIELD); if (result.is_null()) return Nothing(); } } else { @@ -6784,8 +6787,8 @@ Maybe JSReceiver::ValidateAndApplyPropertyDescriptor( ? current->value() : Handle::cast( isolate->factory()->undefined_value())); - MaybeHandle result = - JSObject::DefineOwnPropertyIgnoreAttributes(it, value, attrs); + MaybeHandle result = JSObject::DefineOwnPropertyIgnoreAttributes( + it, value, attrs, JSObject::DONT_FORCE_FIELD); if (result.is_null()) return Nothing(); } else { DCHECK(desc_is_accessor_descriptor || @@ -6849,9 +6852,10 @@ Maybe JSObject::CreateDataProperty(LookupIterator* it, return Just(false); } - RETURN_ON_EXCEPTION_VALUE(it->isolate(), - DefineOwnPropertyIgnoreAttributes(it, value, NONE), - Nothing()); + RETURN_ON_EXCEPTION_VALUE( + it->isolate(), + DefineOwnPropertyIgnoreAttributes(it, value, NONE, DONT_FORCE_FIELD), + Nothing()); return Just(true); } diff --git a/src/objects.h b/src/objects.h index 11771ff4c5..21e6c70e35 100644 --- a/src/objects.h +++ b/src/objects.h @@ -2067,35 +2067,36 @@ class JSObject: public JSReceiver { MUST_USE_RESULT static Maybe SetPropertyWithInterceptor( LookupIterator* it, ShouldThrow should_throw, Handle value); - // The API currently still wants DefineOwnPropertyIgnoreAttributes to convert - // AccessorInfo objects to data fields. We allow FORCE_FIELD as an exception - // to the default behavior that calls the setter. - enum AccessorInfoHandling { FORCE_FIELD, DONT_FORCE_FIELD }; + // SetLocalPropertyIgnoreAttributes converts callbacks to fields. We need to + // grant an exemption to AccessorInfo callbacks in some cases. + enum AccessorInfoHandling { DEFAULT_HANDLING, DONT_FORCE_FIELD }; MUST_USE_RESULT static MaybeHandle DefineOwnPropertyIgnoreAttributes( LookupIterator* it, Handle value, PropertyAttributes attributes, - AccessorInfoHandling handling = DONT_FORCE_FIELD); + AccessorInfoHandling handling = DEFAULT_HANDLING); MUST_USE_RESULT static Maybe DefineOwnPropertyIgnoreAttributes( LookupIterator* it, Handle value, PropertyAttributes attributes, ShouldThrow should_throw, - AccessorInfoHandling handling = DONT_FORCE_FIELD); + AccessorInfoHandling handling = DEFAULT_HANDLING); MUST_USE_RESULT static MaybeHandle SetOwnPropertyIgnoreAttributes( Handle object, Handle name, Handle value, - PropertyAttributes attributes); + PropertyAttributes attributes, + AccessorInfoHandling handling = DEFAULT_HANDLING); MUST_USE_RESULT static MaybeHandle SetOwnElementIgnoreAttributes( Handle object, uint32_t index, Handle value, - PropertyAttributes attributes); + PropertyAttributes attributes, + AccessorInfoHandling handling = DEFAULT_HANDLING); // Equivalent to one of the above depending on whether |name| can be converted // to an array index. MUST_USE_RESULT static MaybeHandle - DefinePropertyOrElementIgnoreAttributes(Handle object, - Handle name, - Handle value, - PropertyAttributes attributes = NONE); + DefinePropertyOrElementIgnoreAttributes( + Handle object, Handle name, Handle value, + PropertyAttributes attributes = NONE, + AccessorInfoHandling handling = DEFAULT_HANDLING); // Adds or reconfigures a property to attributes NONE. It will fail when it // cannot. diff --git a/src/runtime/runtime-scopes.cc b/src/runtime/runtime-scopes.cc index 1da0e6a8e0..13f04479ae 100644 --- a/src/runtime/runtime-scopes.cc +++ b/src/runtime/runtime-scopes.cc @@ -78,8 +78,8 @@ static Object* DeclareGlobals(Isolate* isolate, Handle global, } // Define or redefine own property. - RETURN_FAILURE_ON_EXCEPTION( - isolate, JSObject::DefineOwnPropertyIgnoreAttributes(&it, value, attr)); + RETURN_FAILURE_ON_EXCEPTION(isolate, JSObject::SetOwnPropertyIgnoreAttributes( + global, name, value, attr)); return isolate->heap()->undefined_value(); } @@ -196,8 +196,8 @@ RUNTIME_FUNCTION(Runtime_InitializeConstGlobal) { } } - RETURN_FAILURE_ON_EXCEPTION( - isolate, JSObject::DefineOwnPropertyIgnoreAttributes(&it, value, attr)); + RETURN_FAILURE_ON_EXCEPTION(isolate, JSObject::SetOwnPropertyIgnoreAttributes( + global, name, value, attr)); return *value; }