Commit 85aba7df authored by verwaest's avatar verwaest Committed by Commit bot

[runtime] further dismantle AccessorInfoHandling, reducing it to the single API usecase.

BUG=

Review URL: https://codereview.chromium.org/1643563002

Cr-Commit-Position: refs/heads/master@{#33613}
parent 0637f5f6
......@@ -3557,7 +3557,8 @@ static i::MaybeHandle<i::Object> DefineObjectProperty(
isolate, js_object, key, &success, i::LookupIterator::OWN);
if (!success) return i::MaybeHandle<i::Object>();
return i::JSObject::DefineOwnPropertyIgnoreAttributes(&it, value, attrs);
return i::JSObject::DefineOwnPropertyIgnoreAttributes(
&it, value, attrs, i::JSObject::FORCE_FIELD);
}
......
......@@ -5337,32 +5337,29 @@ Maybe<bool> JSObject::DefineOwnPropertyIgnoreAttributes(
CERTAINLY_NOT_STORE_FROM_KEYED);
}
MaybeHandle<Object> JSObject::SetOwnPropertyIgnoreAttributes(
Handle<JSObject> object, Handle<Name> name, Handle<Object> value,
PropertyAttributes attributes, AccessorInfoHandling handling) {
PropertyAttributes attributes) {
DCHECK(!value->IsTheHole());
LookupIterator it(object, name, LookupIterator::OWN);
return DefineOwnPropertyIgnoreAttributes(&it, value, attributes, handling);
return DefineOwnPropertyIgnoreAttributes(&it, value, attributes);
}
MaybeHandle<Object> JSObject::SetOwnElementIgnoreAttributes(
Handle<JSObject> object, uint32_t index, Handle<Object> value,
PropertyAttributes attributes, AccessorInfoHandling handling) {
PropertyAttributes attributes) {
Isolate* isolate = object->GetIsolate();
LookupIterator it(isolate, object, index, LookupIterator::OWN);
return DefineOwnPropertyIgnoreAttributes(&it, value, attributes, handling);
return DefineOwnPropertyIgnoreAttributes(&it, value, attributes);
}
MaybeHandle<Object> JSObject::DefinePropertyOrElementIgnoreAttributes(
Handle<JSObject> object, Handle<Name> name, Handle<Object> value,
PropertyAttributes attributes, AccessorInfoHandling handling) {
PropertyAttributes attributes) {
Isolate* isolate = object->GetIsolate();
LookupIterator it = LookupIterator::PropertyOrElement(isolate, object, name,
LookupIterator::OWN);
return DefineOwnPropertyIgnoreAttributes(&it, value, attributes, handling);
return DefineOwnPropertyIgnoreAttributes(&it, value, attributes);
}
......@@ -6594,8 +6591,8 @@ Maybe<bool> JSReceiver::ValidateAndApplyPropertyDescriptor(
? desc->value()
: Handle<Object>::cast(isolate->factory()->undefined_value()));
MaybeHandle<Object> result =
JSObject::DefineOwnPropertyIgnoreAttributes(
it, value, desc->ToAttributes(), JSObject::DONT_FORCE_FIELD);
JSObject::DefineOwnPropertyIgnoreAttributes(it, value,
desc->ToAttributes());
if (result.is_null()) return Nothing<bool>();
}
} else {
......@@ -6787,8 +6784,8 @@ Maybe<bool> JSReceiver::ValidateAndApplyPropertyDescriptor(
? current->value()
: Handle<Object>::cast(
isolate->factory()->undefined_value()));
MaybeHandle<Object> result = JSObject::DefineOwnPropertyIgnoreAttributes(
it, value, attrs, JSObject::DONT_FORCE_FIELD);
MaybeHandle<Object> result =
JSObject::DefineOwnPropertyIgnoreAttributes(it, value, attrs);
if (result.is_null()) return Nothing<bool>();
} else {
DCHECK(desc_is_accessor_descriptor ||
......@@ -6852,10 +6849,9 @@ Maybe<bool> JSObject::CreateDataProperty(LookupIterator* it,
return Just(false);
}
RETURN_ON_EXCEPTION_VALUE(
it->isolate(),
DefineOwnPropertyIgnoreAttributes(it, value, NONE, DONT_FORCE_FIELD),
Nothing<bool>());
RETURN_ON_EXCEPTION_VALUE(it->isolate(),
DefineOwnPropertyIgnoreAttributes(it, value, NONE),
Nothing<bool>());
return Just(true);
}
......
......@@ -2067,36 +2067,35 @@ class JSObject: public JSReceiver {
MUST_USE_RESULT static Maybe<bool> SetPropertyWithInterceptor(
LookupIterator* it, ShouldThrow should_throw, Handle<Object> value);
// SetLocalPropertyIgnoreAttributes converts callbacks to fields. We need to
// grant an exemption to AccessorInfo callbacks in some cases.
enum AccessorInfoHandling { DEFAULT_HANDLING, DONT_FORCE_FIELD };
// 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 };
MUST_USE_RESULT static MaybeHandle<Object> DefineOwnPropertyIgnoreAttributes(
LookupIterator* it, Handle<Object> value, PropertyAttributes attributes,
AccessorInfoHandling handling = DEFAULT_HANDLING);
AccessorInfoHandling handling = DONT_FORCE_FIELD);
MUST_USE_RESULT static Maybe<bool> DefineOwnPropertyIgnoreAttributes(
LookupIterator* it, Handle<Object> value, PropertyAttributes attributes,
ShouldThrow should_throw,
AccessorInfoHandling handling = DEFAULT_HANDLING);
AccessorInfoHandling handling = DONT_FORCE_FIELD);
MUST_USE_RESULT static MaybeHandle<Object> SetOwnPropertyIgnoreAttributes(
Handle<JSObject> object, Handle<Name> name, Handle<Object> value,
PropertyAttributes attributes,
AccessorInfoHandling handling = DEFAULT_HANDLING);
PropertyAttributes attributes);
MUST_USE_RESULT static MaybeHandle<Object> SetOwnElementIgnoreAttributes(
Handle<JSObject> object, uint32_t index, Handle<Object> value,
PropertyAttributes attributes,
AccessorInfoHandling handling = DEFAULT_HANDLING);
PropertyAttributes attributes);
// Equivalent to one of the above depending on whether |name| can be converted
// to an array index.
MUST_USE_RESULT static MaybeHandle<Object>
DefinePropertyOrElementIgnoreAttributes(
Handle<JSObject> object, Handle<Name> name, Handle<Object> value,
PropertyAttributes attributes = NONE,
AccessorInfoHandling handling = DEFAULT_HANDLING);
DefinePropertyOrElementIgnoreAttributes(Handle<JSObject> object,
Handle<Name> name,
Handle<Object> value,
PropertyAttributes attributes = NONE);
// Adds or reconfigures a property to attributes NONE. It will fail when it
// cannot.
......
......@@ -78,8 +78,8 @@ static Object* DeclareGlobals(Isolate* isolate, Handle<JSGlobalObject> global,
}
// Define or redefine own property.
RETURN_FAILURE_ON_EXCEPTION(isolate, JSObject::SetOwnPropertyIgnoreAttributes(
global, name, value, attr));
RETURN_FAILURE_ON_EXCEPTION(
isolate, JSObject::DefineOwnPropertyIgnoreAttributes(&it, value, attr));
return isolate->heap()->undefined_value();
}
......@@ -196,8 +196,8 @@ RUNTIME_FUNCTION(Runtime_InitializeConstGlobal) {
}
}
RETURN_FAILURE_ON_EXCEPTION(isolate, JSObject::SetOwnPropertyIgnoreAttributes(
global, name, value, attr));
RETURN_FAILURE_ON_EXCEPTION(
isolate, JSObject::DefineOwnPropertyIgnoreAttributes(&it, value, attr));
return *value;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment