Commit 12736611 authored by neis's avatar neis Committed by Commit bot

Refactor Object::SetSuperProperty and others.

This is in preparation of implementing Reflect.set.

Besides making SetSuperProperty and others return Maybe<bool>, this CL
also fixes some parts of my previous refactoring of SetProperty and
others: It doesn't make sense to take both a language_mode and a
should_throw argument.  A strict language_mode should imply
THROW_ON_ERROR.

R=rossberg, verwaest@chromium.org
BUG=

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

Cr-Commit-Position: refs/heads/master@{#31678}
parent 70a2f537
......@@ -102,8 +102,10 @@ MaybeHandle<Object> DefineDataProperty(Isolate* isolate,
}
#endif
return Object::AddDataProperty(&it, value, attributes, STRICT,
Object::CERTAINLY_NOT_STORE_FROM_KEYED);
MAYBE_RETURN_NULL(
Object::AddDataProperty(&it, value, attributes, Object::THROW_ON_ERROR,
Object::CERTAINLY_NOT_STORE_FROM_KEYED));
return value;
}
......
......@@ -1586,12 +1586,9 @@ MaybeHandle<Object> StoreIC::Store(Handle<Object> object, Handle<Name> name,
LookupIterator it(object, name);
if (FLAG_use_ic) UpdateCaches(&it, value, store_mode);
// Set the property.
Handle<Object> result;
ASSIGN_RETURN_ON_EXCEPTION(
isolate(), result,
Object::SetProperty(&it, value, language_mode(), store_mode), Object);
return result;
MAYBE_RETURN_NULL(
Object::SetProperty(&it, value, language_mode(), store_mode));
return value;
}
......
......@@ -1195,7 +1195,9 @@ MaybeHandle<Object> Object::SetElement(Isolate* isolate, Handle<Object> object,
uint32_t index, Handle<Object> value,
LanguageMode language_mode) {
LookupIterator it(isolate, object, index);
return SetProperty(&it, value, language_mode, MAY_BE_STORE_FROM_KEYED);
MAYBE_RETURN_NULL(
SetProperty(&it, value, language_mode, MAY_BE_STORE_FROM_KEYED));
return value;
}
......
This diff is collapsed.
......@@ -1248,17 +1248,13 @@ class Object {
MUST_USE_RESULT static Maybe<bool> SetProperty(LookupIterator* it,
Handle<Object> value,
LanguageMode language_mode,
ShouldThrow should_throw,
StoreFromKeyed store_mode);
MUST_USE_RESULT static MaybeHandle<Object> SetProperty(
Handle<Object> object, Handle<Name> name, Handle<Object> value,
LanguageMode language_mode,
StoreFromKeyed store_mode = MAY_BE_STORE_FROM_KEYED);
MUST_USE_RESULT static MaybeHandle<Object> SetProperty(
LookupIterator* it, Handle<Object> value, LanguageMode language_mode,
StoreFromKeyed store_mode);
MUST_USE_RESULT static MaybeHandle<Object> SetSuperProperty(
MUST_USE_RESULT static Maybe<bool> SetSuperProperty(
LookupIterator* it, Handle<Object> value, LanguageMode language_mode,
StoreFromKeyed store_mode);
......@@ -1269,28 +1265,21 @@ class Object {
LanguageMode language_mode);
MUST_USE_RESULT static Maybe<bool> CannotCreateProperty(
Isolate* isolate, Handle<Object> receiver, Handle<Object> name,
Handle<Object> value, LanguageMode language_mode,
ShouldThrow should_throw);
Handle<Object> value, ShouldThrow should_throw);
MUST_USE_RESULT static Maybe<bool> WriteToReadOnlyProperty(
LookupIterator* it, Handle<Object> value, LanguageMode language_mode,
ShouldThrow should_throw);
LookupIterator* it, Handle<Object> value, ShouldThrow should_throw);
MUST_USE_RESULT static Maybe<bool> WriteToReadOnlyProperty(
Isolate* isolate, Handle<Object> receiver, Handle<Object> name,
Handle<Object> value, LanguageMode language_mode,
ShouldThrow should_throw);
MUST_USE_RESULT static MaybeHandle<Object> RedefineNonconfigurableProperty(
Handle<Object> value, ShouldThrow should_throw);
MUST_USE_RESULT static Maybe<bool> RedefineNonconfigurableProperty(
Isolate* isolate, Handle<Object> name, Handle<Object> value,
LanguageMode language_mode);
ShouldThrow should_throw);
MUST_USE_RESULT static Maybe<bool> SetDataProperty(LookupIterator* it,
Handle<Object> value,
ShouldThrow should_throw);
MUST_USE_RESULT static MaybeHandle<Object> AddDataProperty(
LookupIterator* it, Handle<Object> value, PropertyAttributes attributes,
LanguageMode language_mode, StoreFromKeyed store_mode);
MUST_USE_RESULT static Maybe<bool> AddDataProperty(
LookupIterator* it, Handle<Object> value, PropertyAttributes attributes,
LanguageMode language_mode, ShouldThrow should_throw,
StoreFromKeyed store_mode);
ShouldThrow should_throw, StoreFromKeyed store_mode);
MUST_USE_RESULT static inline MaybeHandle<Object> GetPropertyOrElement(
Handle<Object> object, Handle<Name> name,
LanguageMode language_mode = SLOPPY);
......@@ -1307,8 +1296,7 @@ class Object {
MUST_USE_RESULT static MaybeHandle<Object> GetPropertyWithAccessor(
LookupIterator* it, LanguageMode language_mode);
MUST_USE_RESULT static Maybe<bool> SetPropertyWithAccessor(
LookupIterator* it, Handle<Object> value, LanguageMode language_mode,
ShouldThrow should_throw);
LookupIterator* it, Handle<Object> value, ShouldThrow should_throw);
MUST_USE_RESULT static MaybeHandle<Object> GetPropertyWithDefinedGetter(
Handle<Object> receiver,
......@@ -1412,7 +1400,7 @@ class Object {
// Return value is only meaningful if [found] is set to true on return.
MUST_USE_RESULT static Maybe<bool> SetPropertyInternal(
LookupIterator* it, Handle<Object> value, LanguageMode language_mode,
ShouldThrow should_throw, StoreFromKeyed store_mode, bool* found);
StoreFromKeyed store_mode, bool* found);
DISALLOW_IMPLICIT_CONSTRUCTORS(Object);
};
......@@ -2065,6 +2053,11 @@ class JSObject: public JSReceiver {
LookupIterator* it, Handle<Object> value, PropertyAttributes attributes,
ExecutableAccessorInfoHandling handling = DEFAULT_HANDLING);
MUST_USE_RESULT static Maybe<bool> DefineOwnPropertyIgnoreAttributes(
LookupIterator* it, Handle<Object> value, PropertyAttributes attributes,
ShouldThrow should_throw,
ExecutableAccessorInfoHandling handling = DEFAULT_HANDLING);
MUST_USE_RESULT static MaybeHandle<Object> SetOwnPropertyIgnoreAttributes(
Handle<JSObject> object, Handle<Name> name, Handle<Object> value,
PropertyAttributes attributes,
......@@ -9569,8 +9562,7 @@ class JSProxy: public JSReceiver {
MUST_USE_RESULT
static Maybe<bool> SetPropertyViaPrototypesWithHandler(
Handle<JSProxy> proxy, Handle<Object> receiver, Handle<Name> name,
Handle<Object> value, LanguageMode language_mode,
ShouldThrow should_throw, bool* done);
Handle<Object> value, ShouldThrow should_throw, bool* done);
MUST_USE_RESULT static Maybe<PropertyAttributes>
GetPropertyAttributesWithHandler(Handle<JSProxy> proxy,
......@@ -9578,8 +9570,7 @@ class JSProxy: public JSReceiver {
Handle<Name> name);
MUST_USE_RESULT static Maybe<bool> SetPropertyWithHandler(
Handle<JSProxy> proxy, Handle<Object> receiver, Handle<Name> name,
Handle<Object> value, LanguageMode language_mode,
ShouldThrow should_throw);
Handle<Object> value, ShouldThrow should_throw);
// Turn the proxy into an (empty) JSObject.
static void Fix(Handle<JSProxy> proxy);
......
......@@ -381,12 +381,10 @@ static Object* StoreToSuper(Isolate* isolate, Handle<JSObject> home_object,
if (!proto->IsJSReceiver()) return isolate->heap()->undefined_value();
LookupIterator it(receiver, name, Handle<JSReceiver>::cast(proto));
Handle<Object> result;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, result,
Object::SetSuperProperty(&it, value, language_mode,
Object::CERTAINLY_NOT_STORE_FROM_KEYED));
return *result;
MAYBE_RETURN(Object::SetSuperProperty(&it, value, language_mode,
Object::CERTAINLY_NOT_STORE_FROM_KEYED),
isolate->heap()->exception());
return *value;
}
......@@ -406,12 +404,10 @@ static Object* StoreElementToSuper(Isolate* isolate,
if (!proto->IsJSReceiver()) return isolate->heap()->undefined_value();
LookupIterator it(isolate, receiver, index, Handle<JSReceiver>::cast(proto));
Handle<Object> result;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, result,
Object::SetSuperProperty(&it, value, language_mode,
Object::MAY_BE_STORE_FROM_KEYED));
return *result;
MAYBE_RETURN(Object::SetSuperProperty(&it, value, language_mode,
Object::MAY_BE_STORE_FROM_KEYED),
isolate->heap()->exception());
return *value;
}
......
......@@ -148,8 +148,9 @@ MaybeHandle<Object> Runtime::SetObjectProperty(Isolate* isolate,
LookupIterator::PropertyOrElement(isolate, object, key, &success);
if (!success) return MaybeHandle<Object>();
return Object::SetProperty(&it, value, language_mode,
Object::MAY_BE_STORE_FROM_KEYED);
MAYBE_RETURN_NULL(Object::SetProperty(&it, value, language_mode,
Object::MAY_BE_STORE_FROM_KEYED));
return value;
}
......@@ -387,12 +388,10 @@ Object* StoreGlobalViaContext(Isolate* isolate, int slot, Handle<Object> value,
script_context->set(slot, isolate->heap()->empty_property_cell());
}
Handle<Object> result;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, result,
Object::SetProperty(&it, value, language_mode,
Object::CERTAINLY_NOT_STORE_FROM_KEYED));
return *result;
MAYBE_RETURN(Object::SetProperty(&it, value, language_mode,
Object::CERTAINLY_NOT_STORE_FROM_KEYED),
isolate->heap()->exception());
return *value;
}
} // namespace
......
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