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