| Index: src/objects.cc
|
| diff --git a/src/objects.cc b/src/objects.cc
|
| index ac92d8daf86181c43e6a67a73df8ec66eab14e0f..bef6dba7932e0297f3471f22b7829395c6379a24 100644
|
| --- a/src/objects.cc
|
| +++ b/src/objects.cc
|
| @@ -786,11 +786,11 @@ MaybeHandle<Object> JSProxy::GetProperty(Isolate* isolate,
|
| Execution::Call(isolate, trap, handler, arraysize(args), args), Object);
|
| // 9. Let targetDesc be ? target.[[GetOwnProperty]](P).
|
| PropertyDescriptor target_desc;
|
| - bool target_found =
|
| + Maybe<bool> target_found =
|
| JSReceiver::GetOwnPropertyDescriptor(isolate, target, name, &target_desc);
|
| - if (isolate->has_pending_exception()) return MaybeHandle<Object>();
|
| + MAYBE_RETURN_NULL(target_found);
|
| // 10. If targetDesc is not undefined, then
|
| - if (target_found) {
|
| + if (target_found.FromJust()) {
|
| // 10.a. If IsDataDescriptor(targetDesc) and targetDesc.[[Configurable]] is
|
| // false and targetDesc.[[Writable]] is false, then
|
| // 10.a.i. If SameValue(trapResult, targetDesc.[[Value]]) is false,
|
| @@ -992,7 +992,7 @@ MaybeHandle<Object> JSProxy::GetPrototype(Handle<JSProxy> proxy) {
|
| }
|
| // 9. Let extensibleTarget be ? IsExtensible(target).
|
| Maybe<bool> is_extensible = JSReceiver::IsExtensible(target);
|
| - if (is_extensible.IsNothing()) return MaybeHandle<Object>();
|
| + MAYBE_RETURN_NULL(is_extensible);
|
| // 10. If extensibleTarget is true, return handlerProto.
|
| if (is_extensible.FromJust()) return handler_proto;
|
| // 11. Let targetProto be ? target.[[GetPrototypeOf]]().
|
| @@ -4001,9 +4001,10 @@ Maybe<bool> Object::SetSuperProperty(LookupIterator* it, Handle<Object> value,
|
| case LookupIterator::INTERCEPTOR:
|
| case LookupIterator::JSPROXY: {
|
| PropertyDescriptor desc;
|
| - bool owned = JSReceiver::GetOwnPropertyDescriptor(&own_lookup, &desc);
|
| - if (isolate->has_pending_exception()) return Nothing<bool>();
|
| - if (!owned) {
|
| + Maybe<bool> owned =
|
| + JSReceiver::GetOwnPropertyDescriptor(&own_lookup, &desc);
|
| + MAYBE_RETURN(owned, Nothing<bool>());
|
| + if (!owned.FromJust()) {
|
| return JSReceiver::CreateDataProperty(&own_lookup, value,
|
| should_throw);
|
| }
|
| @@ -4015,10 +4016,8 @@ Maybe<bool> Object::SetSuperProperty(LookupIterator* it, Handle<Object> value,
|
|
|
| PropertyDescriptor value_desc;
|
| value_desc.set_value(value);
|
| - bool result = JSReceiver::DefineOwnProperty(
|
| - isolate, receiver, it->GetName(), &value_desc, should_throw);
|
| - if (isolate->has_pending_exception()) return Nothing<bool>();
|
| - return Just(result);
|
| + return JSReceiver::DefineOwnProperty(isolate, receiver, it->GetName(),
|
| + &value_desc, should_throw);
|
| }
|
|
|
| case LookupIterator::NOT_FOUND:
|
| @@ -4662,10 +4661,11 @@ Maybe<bool> JSProxy::HasProperty(Isolate* isolate, Handle<JSProxy> proxy,
|
| if (!boolean_trap_result) {
|
| // 9a. Let targetDesc be ? target.[[GetOwnProperty]](P).
|
| PropertyDescriptor target_desc;
|
| - bool target_found = JSReceiver::GetOwnPropertyDescriptor(
|
| + Maybe<bool> target_found = JSReceiver::GetOwnPropertyDescriptor(
|
| isolate, target, name, &target_desc);
|
| + MAYBE_RETURN(target_found, Nothing<bool>());
|
| // 9b. If targetDesc is not undefined, then:
|
| - if (target_found) {
|
| + if (target_found.FromJust()) {
|
| // 9b i. If targetDesc.[[Configurable]] is false, throw a TypeError
|
| // exception.
|
| if (!target_desc.configurable()) {
|
| @@ -4674,11 +4674,10 @@ Maybe<bool> JSProxy::HasProperty(Isolate* isolate, Handle<JSProxy> proxy,
|
| return Nothing<bool>();
|
| }
|
| // 9b ii. Let extensibleTarget be ? IsExtensible(target).
|
| - Maybe<bool> maybe_extensible = JSReceiver::IsExtensible(target);
|
| - if (maybe_extensible.IsNothing()) return maybe_extensible;
|
| - bool extensible_target = maybe_extensible.FromJust();
|
| + Maybe<bool> extensible_target = JSReceiver::IsExtensible(target);
|
| + MAYBE_RETURN(extensible_target, Nothing<bool>());
|
| // 9b iii. If extensibleTarget is false, throw a TypeError exception.
|
| - if (!extensible_target) {
|
| + if (!extensible_target.FromJust()) {
|
| isolate->Throw(*isolate->factory()->NewTypeError(
|
| MessageTemplate::kProxyTargetNotExtensible));
|
| return Nothing<bool>();
|
| @@ -4708,8 +4707,8 @@ Maybe<bool> JSProxy::SetProperty(Handle<JSProxy> proxy, Handle<Name> name,
|
| Handle<JSReceiver> handler(JSReceiver::cast(proxy->handler()), isolate);
|
|
|
| Handle<Object> trap;
|
| - ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, trap, GetTrap(proxy, trap_name),
|
| - Nothing<bool>());
|
| + ASSIGN_RETURN_ON_EXCEPTION_VALUE(
|
| + isolate, trap, Object::GetMethod(handler, trap_name), Nothing<bool>());
|
| if (trap->IsUndefined()) {
|
| LookupIterator it =
|
| LookupIterator::PropertyOrElement(isolate, receiver, name, target);
|
| @@ -4731,10 +4730,10 @@ Maybe<bool> JSProxy::SetProperty(Handle<JSProxy> proxy, Handle<Name> name,
|
|
|
| // Enforce the invariant.
|
| PropertyDescriptor target_desc;
|
| - bool owned =
|
| + Maybe<bool> owned =
|
| JSReceiver::GetOwnPropertyDescriptor(isolate, target, name, &target_desc);
|
| - if (isolate->has_pending_exception()) return Nothing<bool>();
|
| - if (owned) {
|
| + MAYBE_RETURN(owned, Nothing<bool>());
|
| + if (owned.FromJust()) {
|
| bool inconsistent =
|
| (PropertyDescriptor::IsDataDescriptor(&target_desc) &&
|
| !target_desc.configurable() && !target_desc.writable() &&
|
| @@ -4769,8 +4768,8 @@ Maybe<bool> JSProxy::DeletePropertyOrElement(Handle<JSProxy> proxy,
|
| Handle<JSReceiver> handler(JSReceiver::cast(proxy->handler()), isolate);
|
|
|
| Handle<Object> trap;
|
| - ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, trap, GetTrap(proxy, trap_name),
|
| - Nothing<bool>());
|
| + ASSIGN_RETURN_ON_EXCEPTION_VALUE(
|
| + isolate, trap, Object::GetMethod(handler, trap_name), Nothing<bool>());
|
| if (trap->IsUndefined()) {
|
| return JSReceiver::DeletePropertyOrElement(target, name, language_mode);
|
| }
|
| @@ -4789,10 +4788,10 @@ Maybe<bool> JSProxy::DeletePropertyOrElement(Handle<JSProxy> proxy,
|
|
|
| // Enforce the invariant.
|
| PropertyDescriptor target_desc;
|
| - bool owned =
|
| + Maybe<bool> owned =
|
| JSReceiver::GetOwnPropertyDescriptor(isolate, target, name, &target_desc);
|
| - if (isolate->has_pending_exception()) return Nothing<bool>();
|
| - if (owned && !target_desc.configurable()) {
|
| + MAYBE_RETURN(owned, Nothing<bool>());
|
| + if (owned.FromJust() && !target_desc.configurable()) {
|
| isolate->Throw(*factory->NewTypeError(
|
| MessageTemplate::kProxyDeletePropertyViolatesInvariant, name));
|
| return Nothing<bool>();
|
| @@ -4846,23 +4845,14 @@ Maybe<PropertyAttributes> JSProxy::GetPropertyAttributes(LookupIterator* it) {
|
| Isolate* isolate = it->isolate();
|
| HandleScope scope(isolate);
|
| PropertyDescriptor desc;
|
| - bool found = JSProxy::GetOwnPropertyDescriptor(
|
| + Maybe<bool> found = JSProxy::GetOwnPropertyDescriptor(
|
| isolate, it->GetHolder<JSProxy>(), it->GetName(), &desc);
|
| - if (isolate->has_pending_exception()) return Nothing<PropertyAttributes>();
|
| - if (!found) return Just(ABSENT);
|
| + MAYBE_RETURN(found, Nothing<PropertyAttributes>());
|
| + if (!found.FromJust()) return Just(ABSENT);
|
| return Just(desc.ToAttributes());
|
| }
|
|
|
|
|
| -MaybeHandle<Object> JSProxy::GetTrap(Handle<JSProxy> proxy,
|
| - Handle<String> trap_name) {
|
| - DCHECK(!proxy->IsRevoked());
|
| - Isolate* isolate = proxy->GetIsolate();
|
| - Handle<JSReceiver> handler(JSReceiver::cast(proxy->handler()), isolate);
|
| - return Object::GetMethod(handler, trap_name);
|
| -}
|
| -
|
| -
|
| void JSObject::AllocateStorageForMap(Handle<JSObject> object, Handle<Map> map) {
|
| DCHECK(object->map()->GetInObjectProperties() ==
|
| map->GetInObjectProperties());
|
| @@ -6106,11 +6096,11 @@ Object* JSReceiver::DefineProperty(Isolate* isolate, Handle<Object> object,
|
| return isolate->heap()->exception();
|
| }
|
| // 6. Let success be DefinePropertyOrThrow(O,key, desc).
|
| - bool success = DefineOwnProperty(isolate, Handle<JSReceiver>::cast(object),
|
| - key, &desc, THROW_ON_ERROR);
|
| + Maybe<bool> success = DefineOwnProperty(
|
| + isolate, Handle<JSReceiver>::cast(object), key, &desc, THROW_ON_ERROR);
|
| // 7. ReturnIfAbrupt(success).
|
| - if (isolate->has_pending_exception()) return isolate->heap()->exception();
|
| - CHECK(success == true);
|
| + MAYBE_RETURN(success, isolate->heap()->exception());
|
| + CHECK(success.FromJust());
|
| // 8. Return O.
|
| return *object;
|
| }
|
| @@ -6180,11 +6170,12 @@ Object* JSReceiver::DefineProperties(Isolate* isolate, Handle<Object> object,
|
| // 8a. Let P be the first element of pair.
|
| // 8b. Let desc be the second element of pair.
|
| // 8c. Let status be DefinePropertyOrThrow(O, P, desc).
|
| - bool status = DefineOwnProperty(isolate, Handle<JSReceiver>::cast(object),
|
| - desc->name(), desc, THROW_ON_ERROR);
|
| + Maybe<bool> status =
|
| + DefineOwnProperty(isolate, Handle<JSReceiver>::cast(object),
|
| + desc->name(), desc, THROW_ON_ERROR);
|
| // 8d. ReturnIfAbrupt(status).
|
| - if (isolate->has_pending_exception()) return isolate->heap()->exception();
|
| - CHECK(status == true);
|
| + MAYBE_RETURN(status, isolate->heap()->exception());
|
| + CHECK(status.FromJust());
|
| }
|
| // 9. Return o.
|
| return *object;
|
| @@ -6192,9 +6183,11 @@ Object* JSReceiver::DefineProperties(Isolate* isolate, Handle<Object> object,
|
|
|
|
|
| // static
|
| -bool JSReceiver::DefineOwnProperty(Isolate* isolate, Handle<JSReceiver> object,
|
| - Handle<Object> key, PropertyDescriptor* desc,
|
| - ShouldThrow should_throw) {
|
| +Maybe<bool> JSReceiver::DefineOwnProperty(Isolate* isolate,
|
| + Handle<JSReceiver> object,
|
| + Handle<Object> key,
|
| + PropertyDescriptor* desc,
|
| + ShouldThrow should_throw) {
|
| if (object->IsJSArray()) {
|
| return JSArray::DefineOwnProperty(isolate, Handle<JSArray>::cast(object),
|
| key, desc, should_throw);
|
| @@ -6215,11 +6208,11 @@ bool JSReceiver::DefineOwnProperty(Isolate* isolate, Handle<JSReceiver> object,
|
|
|
|
|
| // static
|
| -bool JSReceiver::OrdinaryDefineOwnProperty(Isolate* isolate,
|
| - Handle<JSObject> object,
|
| - Handle<Object> key,
|
| - PropertyDescriptor* desc,
|
| - ShouldThrow should_throw) {
|
| +Maybe<bool> JSReceiver::OrdinaryDefineOwnProperty(Isolate* isolate,
|
| + Handle<JSObject> object,
|
| + Handle<Object> key,
|
| + PropertyDescriptor* desc,
|
| + ShouldThrow should_throw) {
|
| bool success = false;
|
| DCHECK(key->IsName() || key->IsNumber()); // |key| is a PropertyKey...
|
| LookupIterator it = LookupIterator::PropertyOrElement(
|
| @@ -6230,8 +6223,8 @@ bool JSReceiver::OrdinaryDefineOwnProperty(Isolate* isolate,
|
| if (it.state() == LookupIterator::ACCESS_CHECK) {
|
| if (!it.HasAccess()) {
|
| isolate->ReportFailedAccessCheck(it.GetHolder<JSObject>());
|
| - RETURN_VALUE_IF_SCHEDULED_EXCEPTION(isolate, false);
|
| - return false;
|
| + RETURN_VALUE_IF_SCHEDULED_EXCEPTION(isolate, Nothing<bool>());
|
| + return Just(false);
|
| }
|
| it.Next();
|
| }
|
| @@ -6242,17 +6235,15 @@ bool JSReceiver::OrdinaryDefineOwnProperty(Isolate* isolate,
|
|
|
| // ES6 9.1.6.1
|
| // static
|
| -bool JSReceiver::OrdinaryDefineOwnProperty(LookupIterator* it,
|
| - PropertyDescriptor* desc,
|
| - ShouldThrow should_throw) {
|
| +Maybe<bool> JSReceiver::OrdinaryDefineOwnProperty(LookupIterator* it,
|
| + PropertyDescriptor* desc,
|
| + ShouldThrow should_throw) {
|
| Isolate* isolate = it->isolate();
|
| // 1. Let current be O.[[GetOwnProperty]](P).
|
| // 2. ReturnIfAbrupt(current).
|
| PropertyDescriptor current;
|
| - if (!GetOwnPropertyDescriptor(it, ¤t) &&
|
| - isolate->has_pending_exception()) {
|
| - return false;
|
| - }
|
| + MAYBE_RETURN(GetOwnPropertyDescriptor(it, ¤t), Nothing<bool>());
|
| +
|
| // TODO(jkummerow/verwaest): It would be nice if we didn't have to reset
|
| // the iterator every time. Currently, the reasons why we need it are:
|
| // - handle interceptors correctly
|
| @@ -6269,11 +6260,9 @@ bool JSReceiver::OrdinaryDefineOwnProperty(LookupIterator* it,
|
|
|
| // ES6 9.1.6.2
|
| // static
|
| -bool JSReceiver::IsCompatiblePropertyDescriptor(Isolate* isolate,
|
| - bool extensible,
|
| - PropertyDescriptor* desc,
|
| - PropertyDescriptor* current,
|
| - Handle<Name> property_name) {
|
| +Maybe<bool> JSReceiver::IsCompatiblePropertyDescriptor(
|
| + Isolate* isolate, bool extensible, PropertyDescriptor* desc,
|
| + PropertyDescriptor* current, Handle<Name> property_name) {
|
| // 1. Return ValidateAndApplyPropertyDescriptor(undefined, undefined,
|
| // Extensible, Desc, Current).
|
| return ValidateAndApplyPropertyDescriptor(
|
| @@ -6283,7 +6272,7 @@ bool JSReceiver::IsCompatiblePropertyDescriptor(Isolate* isolate,
|
|
|
| // ES6 9.1.6.3
|
| // static
|
| -bool JSReceiver::ValidateAndApplyPropertyDescriptor(
|
| +Maybe<bool> JSReceiver::ValidateAndApplyPropertyDescriptor(
|
| Isolate* isolate, LookupIterator* it, bool extensible,
|
| PropertyDescriptor* desc, PropertyDescriptor* current,
|
| ShouldThrow should_throw, Handle<Name> property_name) {
|
| @@ -6301,12 +6290,9 @@ bool JSReceiver::ValidateAndApplyPropertyDescriptor(
|
| if (current->is_empty()) {
|
| // 2a. If extensible is false, return false.
|
| if (!extensible) {
|
| - if (should_throw == THROW_ON_ERROR) {
|
| - isolate->Throw(*isolate->factory()->NewTypeError(
|
| - MessageTemplate::kDefineDisallowed,
|
| - it != NULL ? it->GetName() : property_name));
|
| - }
|
| - return false;
|
| + RETURN_FAILURE(isolate, should_throw,
|
| + NewTypeError(MessageTemplate::kDefineDisallowed,
|
| + it != NULL ? it->GetName() : property_name));
|
| }
|
| // 2c. If IsGenericDescriptor(Desc) or IsDataDescriptor(Desc) is true, then:
|
| // (This is equivalent to !IsAccessorDescriptor(desc).)
|
| @@ -6329,7 +6315,7 @@ bool JSReceiver::ValidateAndApplyPropertyDescriptor(
|
| MaybeHandle<Object> result =
|
| JSObject::DefineOwnPropertyIgnoreAttributes(
|
| it, value, desc->ToAttributes(), JSObject::DONT_FORCE_FIELD);
|
| - if (result.is_null()) return false;
|
| + if (result.is_null()) return Nothing<bool>();
|
| }
|
| } else {
|
| // 2d. Else Desc must be an accessor Property Descriptor,
|
| @@ -6352,11 +6338,11 @@ bool JSReceiver::ValidateAndApplyPropertyDescriptor(
|
| : Handle<Object>::cast(isolate->factory()->null_value()));
|
| MaybeHandle<Object> result =
|
| JSObject::DefineAccessor(it, getter, setter, desc->ToAttributes());
|
| - if (result.is_null()) return false;
|
| + if (result.is_null()) return Nothing<bool>();
|
| }
|
| }
|
| // 2e. Return true.
|
| - return true;
|
| + return Just(true);
|
| }
|
| // 3. Return true, if every field in Desc is absent.
|
| // 4. Return true, if every field in Desc also occurs in current and the
|
| @@ -6374,29 +6360,23 @@ bool JSReceiver::ValidateAndApplyPropertyDescriptor(
|
| (current->has_get() && current->get()->SameValue(*desc->get()))) &&
|
| (!desc->has_set() ||
|
| (current->has_set() && current->set()->SameValue(*desc->set())))) {
|
| - return true;
|
| + return Just(true);
|
| }
|
| // 5. If the [[Configurable]] field of current is false, then
|
| if (!current->configurable()) {
|
| // 5a. Return false, if the [[Configurable]] field of Desc is true.
|
| if (desc->has_configurable() && desc->configurable()) {
|
| - if (should_throw == THROW_ON_ERROR) {
|
| - isolate->Throw(*isolate->factory()->NewTypeError(
|
| - MessageTemplate::kRedefineDisallowed,
|
| - it != NULL ? it->GetName() : property_name));
|
| - }
|
| - return false;
|
| + RETURN_FAILURE(isolate, should_throw,
|
| + NewTypeError(MessageTemplate::kRedefineDisallowed,
|
| + it != NULL ? it->GetName() : property_name));
|
| }
|
| // 5b. Return false, if the [[Enumerable]] field of Desc is present and the
|
| // [[Enumerable]] fields of current and Desc are the Boolean negation of
|
| // each other.
|
| if (desc->has_enumerable() && desc->enumerable() != current->enumerable()) {
|
| - if (should_throw == THROW_ON_ERROR) {
|
| - isolate->Throw(*isolate->factory()->NewTypeError(
|
| - MessageTemplate::kRedefineDisallowed,
|
| - it != NULL ? it->GetName() : property_name));
|
| - }
|
| - return false;
|
| + RETURN_FAILURE(isolate, should_throw,
|
| + NewTypeError(MessageTemplate::kRedefineDisallowed,
|
| + it != NULL ? it->GetName() : property_name));
|
| }
|
| }
|
|
|
| @@ -6411,12 +6391,9 @@ bool JSReceiver::ValidateAndApplyPropertyDescriptor(
|
| } else if (current_is_data_descriptor != desc_is_data_descriptor) {
|
| // 7a. Return false, if the [[Configurable]] field of current is false.
|
| if (!current->configurable()) {
|
| - if (should_throw == THROW_ON_ERROR) {
|
| - isolate->Throw(*isolate->factory()->NewTypeError(
|
| - MessageTemplate::kRedefineDisallowed,
|
| - it != NULL ? it->GetName() : property_name));
|
| - }
|
| - return false;
|
| + RETURN_FAILURE(isolate, should_throw,
|
| + NewTypeError(MessageTemplate::kRedefineDisallowed,
|
| + it != NULL ? it->GetName() : property_name));
|
| }
|
| // 7b. If IsDataDescriptor(current) is true, then:
|
| if (current_is_data_descriptor) {
|
| @@ -6444,34 +6421,27 @@ bool JSReceiver::ValidateAndApplyPropertyDescriptor(
|
| // non-configurable properties.
|
| if (it != NULL && current->writable() && desc->has_writable() &&
|
| !desc->writable() && object->map()->is_strong()) {
|
| - if (should_throw == THROW_ON_ERROR) {
|
| - isolate->Throw(*isolate->factory()->NewTypeError(
|
| - MessageTemplate::kStrongRedefineDisallowed, object,
|
| - it->GetName()));
|
| - }
|
| - return false;
|
| + RETURN_FAILURE(isolate, should_throw,
|
| + NewTypeError(MessageTemplate::kStrongRedefineDisallowed,
|
| + object, it->GetName()));
|
| }
|
| // 8a i. Return false, if the [[Writable]] field of current is false and
|
| // the [[Writable]] field of Desc is true.
|
| if (!current->writable() && desc->has_writable() && desc->writable()) {
|
| - if (should_throw == THROW_ON_ERROR) {
|
| - isolate->Throw(*isolate->factory()->NewTypeError(
|
| - MessageTemplate::kRedefineDisallowed,
|
| - it != NULL ? it->GetName() : property_name));
|
| - }
|
| - return false;
|
| + RETURN_FAILURE(
|
| + isolate, should_throw,
|
| + NewTypeError(MessageTemplate::kRedefineDisallowed,
|
| + it != NULL ? it->GetName() : property_name));
|
| }
|
| // 8a ii. If the [[Writable]] field of current is false, then:
|
| if (!current->writable()) {
|
| // 8a ii 1. Return false, if the [[Value]] field of Desc is present and
|
| // SameValue(Desc.[[Value]], current.[[Value]]) is false.
|
| if (desc->has_value() && !desc->value()->SameValue(*current->value())) {
|
| - if (should_throw == THROW_ON_ERROR) {
|
| - isolate->Throw(*isolate->factory()->NewTypeError(
|
| - MessageTemplate::kRedefineDisallowed,
|
| - it != NULL ? it->GetName() : property_name));
|
| - }
|
| - return false;
|
| + RETURN_FAILURE(
|
| + isolate, should_throw,
|
| + NewTypeError(MessageTemplate::kRedefineDisallowed,
|
| + it != NULL ? it->GetName() : property_name));
|
| }
|
| }
|
| }
|
| @@ -6485,22 +6455,18 @@ bool JSReceiver::ValidateAndApplyPropertyDescriptor(
|
| // 9a i. Return false, if the [[Set]] field of Desc is present and
|
| // SameValue(Desc.[[Set]], current.[[Set]]) is false.
|
| if (desc->has_set() && !desc->set()->SameValue(*current->set())) {
|
| - if (should_throw == THROW_ON_ERROR) {
|
| - isolate->Throw(*isolate->factory()->NewTypeError(
|
| - MessageTemplate::kRedefineDisallowed,
|
| - it != NULL ? it->GetName() : property_name));
|
| - }
|
| - return false;
|
| + RETURN_FAILURE(
|
| + isolate, should_throw,
|
| + NewTypeError(MessageTemplate::kRedefineDisallowed,
|
| + it != NULL ? it->GetName() : property_name));
|
| }
|
| // 9a ii. Return false, if the [[Get]] field of Desc is present and
|
| // SameValue(Desc.[[Get]], current.[[Get]]) is false.
|
| if (desc->has_get() && !desc->get()->SameValue(*current->get())) {
|
| - if (should_throw == THROW_ON_ERROR) {
|
| - isolate->Throw(*isolate->factory()->NewTypeError(
|
| - MessageTemplate::kRedefineDisallowed,
|
| - it != NULL ? it->GetName() : property_name));
|
| - }
|
| - return false;
|
| + RETURN_FAILURE(
|
| + isolate, should_throw,
|
| + NewTypeError(MessageTemplate::kRedefineDisallowed,
|
| + it != NULL ? it->GetName() : property_name));
|
| }
|
| }
|
| }
|
| @@ -6542,7 +6508,7 @@ bool JSReceiver::ValidateAndApplyPropertyDescriptor(
|
| isolate->factory()->undefined_value()));
|
| MaybeHandle<Object> result = JSObject::DefineOwnPropertyIgnoreAttributes(
|
| it, value, attrs, JSObject::DONT_FORCE_FIELD);
|
| - if (result.is_null()) return false;
|
| + if (result.is_null()) return Nothing<bool>();
|
| } else {
|
| DCHECK(desc_is_accessor_descriptor ||
|
| (desc_is_generic_descriptor &&
|
| @@ -6561,12 +6527,12 @@ bool JSReceiver::ValidateAndApplyPropertyDescriptor(
|
| : Handle<Object>::cast(isolate->factory()->null_value()));
|
| MaybeHandle<Object> result =
|
| JSObject::DefineAccessor(it, getter, setter, attrs);
|
| - if (result.is_null()) return false;
|
| + if (result.is_null()) return Nothing<bool>();
|
| }
|
| }
|
|
|
| // 11. Return true.
|
| - return true;
|
| + return Just(true);
|
| }
|
|
|
|
|
| @@ -6588,18 +6554,15 @@ Maybe<bool> JSReceiver::CreateDataProperty(LookupIterator* it,
|
| new_desc.set_enumerable(true);
|
| new_desc.set_configurable(true);
|
|
|
| - bool result = JSReceiver::DefineOwnProperty(isolate, receiver, it->GetName(),
|
| - &new_desc, should_throw);
|
| - if (isolate->has_pending_exception()) return Nothing<bool>();
|
| - return Just(result);
|
| + return JSReceiver::DefineOwnProperty(isolate, receiver, it->GetName(),
|
| + &new_desc, should_throw);
|
| }
|
|
|
|
|
| Maybe<bool> JSObject::CreateDataProperty(LookupIterator* it,
|
| Handle<Object> value) {
|
| DCHECK(it->GetReceiver()->IsJSObject());
|
| - Maybe<PropertyAttributes> maybe = JSReceiver::GetPropertyAttributes(it);
|
| - if (maybe.IsNothing()) return Nothing<bool>();
|
| + MAYBE_RETURN(JSReceiver::GetPropertyAttributes(it), Nothing<bool>());
|
|
|
| if (it->IsFound()) {
|
| if (!it->IsConfigurable()) return Just(false);
|
| @@ -6634,9 +6597,10 @@ bool PropertyKeyToArrayIndex(Handle<Object> index_obj, uint32_t* output) {
|
|
|
| // ES6 9.4.2.1
|
| // static
|
| -bool JSArray::DefineOwnProperty(Isolate* isolate, Handle<JSArray> o,
|
| - Handle<Object> name, PropertyDescriptor* desc,
|
| - ShouldThrow should_throw) {
|
| +Maybe<bool> JSArray::DefineOwnProperty(Isolate* isolate, Handle<JSArray> o,
|
| + Handle<Object> name,
|
| + PropertyDescriptor* desc,
|
| + ShouldThrow should_throw) {
|
| // 1. Assert: IsPropertyKey(P) is true. ("P" is |name|.)
|
| // 2. If P is "length", then:
|
| // TODO(jkummerow): Check if we need slow string comparison.
|
| @@ -6649,10 +6613,10 @@ bool JSArray::DefineOwnProperty(Isolate* isolate, Handle<JSArray> o,
|
| if (PropertyKeyToArrayIndex(name, &index)) {
|
| // 3a. Let oldLenDesc be OrdinaryGetOwnProperty(A, "length").
|
| PropertyDescriptor old_len_desc;
|
| - bool success = GetOwnPropertyDescriptor(
|
| + Maybe<bool> success = GetOwnPropertyDescriptor(
|
| isolate, o, isolate->factory()->length_string(), &old_len_desc);
|
| // 3b. (Assert)
|
| - DCHECK(success);
|
| + DCHECK(success.FromJust());
|
| USE(success);
|
| // 3c. Let oldLen be oldLenDesc.[[Value]].
|
| uint32_t old_len = 0;
|
| @@ -6664,30 +6628,31 @@ bool JSArray::DefineOwnProperty(Isolate* isolate, Handle<JSArray> o,
|
| // return false.
|
| if (index >= old_len && old_len_desc.has_writable() &&
|
| !old_len_desc.writable()) {
|
| - if (should_throw == THROW_ON_ERROR) {
|
| - isolate->Throw(*isolate->factory()->NewTypeError(
|
| - MessageTemplate::kDefineDisallowed, name));
|
| - }
|
| - return false;
|
| + RETURN_FAILURE(isolate, should_throw,
|
| + NewTypeError(MessageTemplate::kDefineDisallowed, name));
|
| }
|
| // 3g. Let succeeded be OrdinaryDefineOwnProperty(A, P, Desc).
|
| - bool succeeded =
|
| + Maybe<bool> succeeded =
|
| OrdinaryDefineOwnProperty(isolate, o, name, desc, should_throw);
|
| - // 3h. (Assert)
|
| + // 3h. Assert: succeeded is not an abrupt completion.
|
| + // In our case, if should_throw == THROW_ON_ERROR, it can be!
|
| // 3i. If succeeded is false, return false.
|
| - if (!succeeded) return false;
|
| + if (succeeded.IsNothing() || !succeeded.FromJust()) return succeeded;
|
| // 3j. If index >= oldLen, then:
|
| if (index >= old_len) {
|
| // 3j i. Set oldLenDesc.[[Value]] to index + 1.
|
| old_len_desc.set_value(isolate->factory()->NewNumberFromUint(index + 1));
|
| // 3j ii. Let succeeded be
|
| // OrdinaryDefineOwnProperty(A, "length", oldLenDesc).
|
| - OrdinaryDefineOwnProperty(isolate, o, isolate->factory()->length_string(),
|
| - &old_len_desc, should_throw);
|
| - // 3j iii. (Assert)
|
| + succeeded = OrdinaryDefineOwnProperty(isolate, o,
|
| + isolate->factory()->length_string(),
|
| + &old_len_desc, should_throw);
|
| + // 3j iii. Assert: succeeded is true.
|
| + DCHECK(succeeded.FromJust());
|
| + USE(succeeded);
|
| }
|
| // 3k. Return true.
|
| - return true;
|
| + return Just(true);
|
| }
|
|
|
| // 4. Return OrdinaryDefineOwnProperty(A, P, Desc).
|
| @@ -6734,9 +6699,9 @@ bool JSArray::AnythingToArrayLength(Isolate* isolate,
|
|
|
| // ES6 9.4.2.4
|
| // static
|
| -bool JSArray::ArraySetLength(Isolate* isolate, Handle<JSArray> a,
|
| - PropertyDescriptor* desc,
|
| - ShouldThrow should_throw) {
|
| +Maybe<bool> JSArray::ArraySetLength(Isolate* isolate, Handle<JSArray> a,
|
| + PropertyDescriptor* desc,
|
| + ShouldThrow should_throw) {
|
| // 1. If the [[Value]] field of Desc is absent, then
|
| if (!desc->has_value()) {
|
| // 1a. Return OrdinaryDefineOwnProperty(A, "length", Desc).
|
| @@ -6749,20 +6714,17 @@ bool JSArray::ArraySetLength(Isolate* isolate, Handle<JSArray> a,
|
| // 3. - 7. Convert Desc.[[Value]] to newLen.
|
| uint32_t new_len = 0;
|
| if (!AnythingToArrayLength(isolate, desc->value(), &new_len)) {
|
| - if (should_throw == THROW_ON_ERROR && !isolate->has_pending_exception()) {
|
| - isolate->Throw(*isolate->factory()->NewTypeError(
|
| - MessageTemplate::kCannotConvertToPrimitive));
|
| - }
|
| - return false;
|
| + DCHECK(isolate->has_pending_exception());
|
| + return Nothing<bool>();
|
| }
|
| // 8. Set newLenDesc.[[Value]] to newLen.
|
| // (Done below, if needed.)
|
| // 9. Let oldLenDesc be OrdinaryGetOwnProperty(A, "length").
|
| PropertyDescriptor old_len_desc;
|
| - bool success = GetOwnPropertyDescriptor(
|
| + Maybe<bool> success = GetOwnPropertyDescriptor(
|
| isolate, a, isolate->factory()->length_string(), &old_len_desc);
|
| // 10. (Assert)
|
| - DCHECK(success);
|
| + DCHECK(success.FromJust());
|
| USE(success);
|
| // 11. Let oldLen be oldLenDesc.[[Value]].
|
| uint32_t old_len = 0;
|
| @@ -6778,11 +6740,9 @@ bool JSArray::ArraySetLength(Isolate* isolate, Handle<JSArray> a,
|
| }
|
| // 13. If oldLenDesc.[[Writable]] is false, return false.
|
| if (!old_len_desc.writable()) {
|
| - if (should_throw == THROW_ON_ERROR)
|
| - isolate->Throw(*isolate->factory()->NewTypeError(
|
| - MessageTemplate::kRedefineDisallowed,
|
| - isolate->factory()->length_string()));
|
| - return false;
|
| + RETURN_FAILURE(isolate, should_throw,
|
| + NewTypeError(MessageTemplate::kRedefineDisallowed,
|
| + isolate->factory()->length_string()));
|
| }
|
| // 14. If newLenDesc.[[Writable]] is absent or has the value true,
|
| // let newWritable be true.
|
| @@ -6800,33 +6760,39 @@ bool JSArray::ArraySetLength(Isolate* isolate, Handle<JSArray> a,
|
| // Most of steps 16 through 19 is implemented by JSArray::SetLength.
|
| if (JSArray::ObservableSetLength(a, new_len).is_null()) {
|
| DCHECK(isolate->has_pending_exception());
|
| - return false;
|
| + return Nothing<bool>();
|
| }
|
| // Steps 19d-ii, 20.
|
| if (!new_writable) {
|
| PropertyDescriptor readonly;
|
| readonly.set_writable(false);
|
| - OrdinaryDefineOwnProperty(isolate, a, isolate->factory()->length_string(),
|
| - &readonly, should_throw);
|
| + Maybe<bool> success = OrdinaryDefineOwnProperty(
|
| + isolate, a, isolate->factory()->length_string(), &readonly,
|
| + should_throw);
|
| + DCHECK(success.FromJust());
|
| + USE(success);
|
| }
|
| uint32_t actual_new_len = 0;
|
| CHECK(a->length()->ToArrayLength(&actual_new_len));
|
| // Steps 19d-v, 21. Return false if there were non-deletable elements.
|
| - success = actual_new_len == new_len;
|
| - if (!success && should_throw == THROW_ON_ERROR) {
|
| - isolate->Throw(*isolate->factory()->NewTypeError(
|
| - MessageTemplate::kStrictDeleteProperty,
|
| - isolate->factory()->NewNumberFromUint(actual_new_len - 1), a));
|
| + bool result = actual_new_len == new_len;
|
| + if (!result) {
|
| + RETURN_FAILURE(
|
| + isolate, should_throw,
|
| + NewTypeError(MessageTemplate::kStrictDeleteProperty,
|
| + isolate->factory()->NewNumberFromUint(actual_new_len - 1),
|
| + a));
|
| }
|
| - return success;
|
| + return Just(result);
|
| }
|
|
|
|
|
| // ES6 9.5.6
|
| // static
|
| -bool JSProxy::DefineOwnProperty(Isolate* isolate, Handle<JSProxy> proxy,
|
| - Handle<Object> key, PropertyDescriptor* desc,
|
| - ShouldThrow should_throw) {
|
| +Maybe<bool> JSProxy::DefineOwnProperty(Isolate* isolate, Handle<JSProxy> proxy,
|
| + Handle<Object> key,
|
| + PropertyDescriptor* desc,
|
| + ShouldThrow should_throw) {
|
| Handle<String> trap_name = isolate->factory()->defineProperty_string();
|
| // 1. Assert: IsPropertyKey(P) is true.
|
| DCHECK(key->IsName() || key->IsNumber());
|
| @@ -6837,7 +6803,7 @@ bool JSProxy::DefineOwnProperty(Isolate* isolate, Handle<JSProxy> proxy,
|
| if (proxy->IsRevoked()) {
|
| isolate->Throw(*isolate->factory()->NewTypeError(
|
| MessageTemplate::kProxyRevoked, trap_name));
|
| - return false;
|
| + return Nothing<bool>();
|
| }
|
| // 5. Let target be the value of the [[ProxyTarget]] internal slot of O.
|
| Handle<JSReceiver> target(proxy->target(), isolate);
|
| @@ -6845,7 +6811,8 @@ bool JSProxy::DefineOwnProperty(Isolate* isolate, Handle<JSProxy> proxy,
|
| Handle<Object> trap;
|
| ASSIGN_RETURN_ON_EXCEPTION_VALUE(
|
| isolate, trap,
|
| - Object::GetMethod(Handle<JSReceiver>::cast(handler), trap_name), false);
|
| + Object::GetMethod(Handle<JSReceiver>::cast(handler), trap_name),
|
| + Nothing<bool>());
|
| // 7. If trap is undefined, then:
|
| if (trap->IsUndefined()) {
|
| // 7a. Return target.[[DefineOwnProperty]](P, Desc).
|
| @@ -6864,25 +6831,23 @@ bool JSProxy::DefineOwnProperty(Isolate* isolate, Handle<JSProxy> proxy,
|
| Handle<Object> args[] = {target, property_name, desc_obj};
|
| ASSIGN_RETURN_ON_EXCEPTION_VALUE(
|
| isolate, trap_result_obj,
|
| - Execution::Call(isolate, trap, handler, arraysize(args), args), false);
|
| + Execution::Call(isolate, trap, handler, arraysize(args), args),
|
| + Nothing<bool>());
|
| // 10. If booleanTrapResult is false, return false.
|
| if (!trap_result_obj->BooleanValue()) {
|
| - if (should_throw == THROW_ON_ERROR) {
|
| - // TODO(jkummerow): Better error message?
|
| - isolate->Throw(*isolate->factory()->NewTypeError(
|
| - MessageTemplate::kProxyHandlerReturned, handler, trap_result_obj,
|
| - trap_name));
|
| - }
|
| - return false;
|
| + // TODO(jkummerow): Better error message?
|
| + RETURN_FAILURE(isolate, should_throw,
|
| + NewTypeError(MessageTemplate::kProxyHandlerReturned, handler,
|
| + trap_result_obj, trap_name));
|
| }
|
| // 11. Let targetDesc be ? target.[[GetOwnProperty]](P).
|
| PropertyDescriptor target_desc;
|
| - bool target_found =
|
| + Maybe<bool> target_found =
|
| JSReceiver::GetOwnPropertyDescriptor(isolate, target, key, &target_desc);
|
| - if (isolate->has_pending_exception()) return false;
|
| + MAYBE_RETURN(target_found, Nothing<bool>());
|
| // 12. Let extensibleTarget be ? IsExtensible(target).
|
| Maybe<bool> maybe_extensible = JSReceiver::IsExtensible(target);
|
| - if (maybe_extensible.IsNothing()) return false;
|
| + MAYBE_RETURN(maybe_extensible, Nothing<bool>());
|
| bool extensible_target = maybe_extensible.FromJust();
|
| // 13. If Desc has a [[Configurable]] field and if Desc.[[Configurable]]
|
| // is false, then:
|
| @@ -6890,49 +6855,47 @@ bool JSProxy::DefineOwnProperty(Isolate* isolate, Handle<JSProxy> proxy,
|
| // 14. Else let settingConfigFalse be false.
|
| bool setting_config_false = desc->has_configurable() && !desc->configurable();
|
| // 15. If targetDesc is undefined, then
|
| - if (!target_found) {
|
| + if (!target_found.FromJust()) {
|
| // 15a. If extensibleTarget is false, throw a TypeError exception.
|
| if (!extensible_target) {
|
| isolate->Throw(*isolate->factory()->NewTypeError(
|
| MessageTemplate::kProxyTargetNotExtensible));
|
| - return false;
|
| + return Nothing<bool>();
|
| }
|
| // 15b. If settingConfigFalse is true, throw a TypeError exception.
|
| if (setting_config_false) {
|
| // TODO(jkummerow): Better error message?
|
| isolate->Throw(*isolate->factory()->NewTypeError(
|
| MessageTemplate::kRedefineDisallowed, key));
|
| - return false;
|
| + return Nothing<bool>();
|
| }
|
| } else {
|
| // 16. Else targetDesc is not undefined,
|
| // 16a. If IsCompatiblePropertyDescriptor(extensibleTarget, Desc,
|
| // targetDesc) is false, throw a TypeError exception.
|
| - bool valid = IsCompatiblePropertyDescriptor(
|
| + Maybe<bool> valid = IsCompatiblePropertyDescriptor(
|
| isolate, extensible_target, desc, &target_desc, property_name);
|
| - if (!valid) {
|
| - DCHECK(isolate->has_pending_exception());
|
| - return false;
|
| - }
|
| + MAYBE_RETURN(valid, Nothing<bool>());
|
| + DCHECK(valid.FromJust());
|
| // 16b. If settingConfigFalse is true and targetDesc.[[Configurable]] is
|
| // true, throw a TypeError exception.
|
| if (setting_config_false && target_desc.configurable()) {
|
| // TODO(jkummerow): Better error message?
|
| isolate->Throw(*isolate->factory()->NewTypeError(
|
| MessageTemplate::kRedefineDisallowed, key));
|
| - return false;
|
| + return Nothing<bool>();
|
| }
|
| }
|
| // 17. Return true.
|
| - return true;
|
| + return Just(true);
|
| }
|
|
|
|
|
| // static
|
| -bool JSReceiver::GetOwnPropertyDescriptor(Isolate* isolate,
|
| - Handle<JSReceiver> object,
|
| - Handle<Object> key,
|
| - PropertyDescriptor* desc) {
|
| +Maybe<bool> JSReceiver::GetOwnPropertyDescriptor(Isolate* isolate,
|
| + Handle<JSReceiver> object,
|
| + Handle<Object> key,
|
| + PropertyDescriptor* desc) {
|
| bool success = false;
|
| DCHECK(key->IsName() || key->IsNumber()); // |key| is a PropertyKey...
|
| LookupIterator it = LookupIterator::PropertyOrElement(
|
| @@ -6942,14 +6905,12 @@ bool JSReceiver::GetOwnPropertyDescriptor(Isolate* isolate,
|
| }
|
|
|
|
|
| -// TODO(jkummerow): Any chance to unify this with
|
| -// "MaybeHandle<Object> GetOwnProperty()" in runtime-object.cc?
|
| -
|
| // ES6 9.1.5.1
|
| -// Returns true on success; false if there was an exception or no property.
|
| +// Returns true on success, false if the property didn't exist, nothing if
|
| +// an exception was thrown.
|
| // static
|
| -bool JSReceiver::GetOwnPropertyDescriptor(LookupIterator* it,
|
| - PropertyDescriptor* desc) {
|
| +Maybe<bool> JSReceiver::GetOwnPropertyDescriptor(LookupIterator* it,
|
| + PropertyDescriptor* desc) {
|
| Isolate* isolate = it->isolate();
|
| // "Virtual" dispatch.
|
| if (it->IsFound() && it->GetHolder<JSReceiver>()->IsJSProxy()) {
|
| @@ -6960,10 +6921,9 @@ bool JSReceiver::GetOwnPropertyDescriptor(LookupIterator* it,
|
| // 1. (Assert)
|
| // 2. If O does not have an own property with key P, return undefined.
|
| Maybe<PropertyAttributes> maybe = JSObject::GetPropertyAttributes(it);
|
| -
|
| - if (!maybe.IsJust()) return false;
|
| + MAYBE_RETURN(maybe, Nothing<bool>());
|
| PropertyAttributes attrs = maybe.FromJust();
|
| - if (attrs == ABSENT) return false;
|
| + if (attrs == ABSENT) return Just(false);
|
| DCHECK(!isolate->has_pending_exception());
|
|
|
| // 3. Let D be a newly created Property Descriptor with no fields.
|
| @@ -6977,7 +6937,7 @@ bool JSReceiver::GetOwnPropertyDescriptor(LookupIterator* it,
|
| Handle<Object> value;
|
| if (!JSObject::GetProperty(it).ToHandle(&value)) {
|
| DCHECK(isolate->has_pending_exception());
|
| - return false;
|
| + return Nothing<bool>();
|
| }
|
| desc->set_value(value);
|
| // 5b. Set D.[[Writable]] to the value of X's [[Writable]] attribute
|
| @@ -6999,15 +6959,16 @@ bool JSReceiver::GetOwnPropertyDescriptor(LookupIterator* it,
|
| // 9. Return D.
|
| DCHECK(PropertyDescriptor::IsAccessorDescriptor(desc) !=
|
| PropertyDescriptor::IsDataDescriptor(desc));
|
| - return true;
|
| + return Just(true);
|
| }
|
|
|
|
|
| // ES6 9.5.5
|
| // static
|
| -bool JSProxy::GetOwnPropertyDescriptor(Isolate* isolate, Handle<JSProxy> proxy,
|
| - Handle<Name> name,
|
| - PropertyDescriptor* desc) {
|
| +Maybe<bool> JSProxy::GetOwnPropertyDescriptor(Isolate* isolate,
|
| + Handle<JSProxy> proxy,
|
| + Handle<Name> name,
|
| + PropertyDescriptor* desc) {
|
| Handle<String> trap_name =
|
| isolate->factory()->getOwnPropertyDescriptor_string();
|
| // 1. (Assert)
|
| @@ -7018,7 +6979,7 @@ bool JSProxy::GetOwnPropertyDescriptor(Isolate* isolate, Handle<JSProxy> proxy,
|
| if (proxy->IsRevoked()) {
|
| isolate->Throw(*isolate->factory()->NewTypeError(
|
| MessageTemplate::kProxyRevoked, trap_name));
|
| - return false;
|
| + return Nothing<bool>();
|
| }
|
| // 5. Let target be the value of the [[ProxyTarget]] internal slot of O.
|
| Handle<JSReceiver> target(proxy->target(), isolate);
|
| @@ -7026,7 +6987,8 @@ bool JSProxy::GetOwnPropertyDescriptor(Isolate* isolate, Handle<JSProxy> proxy,
|
| Handle<Object> trap;
|
| ASSIGN_RETURN_ON_EXCEPTION_VALUE(
|
| isolate, trap,
|
| - Object::GetMethod(Handle<JSReceiver>::cast(handler), trap_name), false);
|
| + Object::GetMethod(Handle<JSReceiver>::cast(handler), trap_name),
|
| + Nothing<bool>());
|
| // 7. If trap is undefined, then
|
| if (trap->IsUndefined()) {
|
| // 7a. Return target.[[GetOwnProperty]](P).
|
| @@ -7037,65 +6999,63 @@ bool JSProxy::GetOwnPropertyDescriptor(Isolate* isolate, Handle<JSProxy> proxy,
|
| Handle<Object> args[] = {target, name};
|
| ASSIGN_RETURN_ON_EXCEPTION_VALUE(
|
| isolate, trap_result_obj,
|
| - Execution::Call(isolate, trap, handler, arraysize(args), args), false);
|
| + Execution::Call(isolate, trap, handler, arraysize(args), args),
|
| + Nothing<bool>());
|
| // 9. If Type(trapResultObj) is neither Object nor Undefined, throw a
|
| // TypeError exception.
|
| if (!trap_result_obj->IsJSReceiver() && !trap_result_obj->IsUndefined()) {
|
| isolate->Throw(*isolate->factory()->NewTypeError(
|
| MessageTemplate::kProxyHandlerReturned, handler, trap_result_obj,
|
| name));
|
| - return false;
|
| + return Nothing<bool>();
|
| }
|
| // 10. Let targetDesc be ? target.[[GetOwnProperty]](P).
|
| PropertyDescriptor target_desc;
|
| - JSReceiver::GetOwnPropertyDescriptor(isolate, target, name, &target_desc);
|
| - if (isolate->has_pending_exception()) return false;
|
| + Maybe<bool> found =
|
| + JSReceiver::GetOwnPropertyDescriptor(isolate, target, name, &target_desc);
|
| + MAYBE_RETURN(found, Nothing<bool>());
|
| // 11. If trapResultObj is undefined, then
|
| if (trap_result_obj->IsUndefined()) {
|
| // 11a. If targetDesc is undefined, return undefined.
|
| - if (target_desc.is_empty()) return false;
|
| + if (!found.FromJust()) return Just(false);
|
| // 11b. If targetDesc.[[Configurable]] is false, throw a TypeError
|
| // exception.
|
| if (!target_desc.configurable()) {
|
| isolate->Throw(*isolate->factory()->NewTypeError(
|
| MessageTemplate::kProxyTargetPropNotConfigurable, name));
|
| - return false;
|
| + return Nothing<bool>();
|
| }
|
| // 11c. Let extensibleTarget be ? IsExtensible(target).
|
| - Maybe<bool> maybe_extensible = JSReceiver::IsExtensible(target);
|
| - if (maybe_extensible.IsNothing()) return false;
|
| - bool extensible_target = maybe_extensible.FromJust();
|
| + Maybe<bool> extensible_target = JSReceiver::IsExtensible(target);
|
| + MAYBE_RETURN(extensible_target, Nothing<bool>());
|
| // 11d. (Assert)
|
| // 11e. If extensibleTarget is false, throw a TypeError exception.
|
| - if (!extensible_target) {
|
| + if (!extensible_target.FromJust()) {
|
| isolate->Throw(*isolate->factory()->NewTypeError(
|
| MessageTemplate::kProxyTargetNotExtensible));
|
| - return false;
|
| + return Nothing<bool>();
|
| }
|
| // 11f. Return undefined.
|
| - return false; // |desc->is_empty()| is what JavaScript calls "undefined".
|
| + return Just(false);
|
| }
|
| // 12. Let extensibleTarget be ? IsExtensible(target).
|
| - Maybe<bool> maybe_extensible = JSReceiver::IsExtensible(target);
|
| - if (maybe_extensible.IsNothing()) return false;
|
| - bool extensible_target = maybe_extensible.FromJust();
|
| + Maybe<bool> extensible_target = JSReceiver::IsExtensible(target);
|
| + MAYBE_RETURN(extensible_target, Nothing<bool>());
|
| // 13. Let resultDesc be ? ToPropertyDescriptor(trapResultObj).
|
| if (!PropertyDescriptor::ToPropertyDescriptor(isolate, trap_result_obj,
|
| desc)) {
|
| DCHECK(isolate->has_pending_exception());
|
| - return false;
|
| + return Nothing<bool>();
|
| }
|
| // 14. Call CompletePropertyDescriptor(resultDesc).
|
| PropertyDescriptor::CompletePropertyDescriptor(isolate, desc);
|
| // 15. Let valid be IsCompatiblePropertyDescriptor (extensibleTarget,
|
| // resultDesc, targetDesc).
|
| - bool valid = IsCompatiblePropertyDescriptor(isolate, extensible_target, desc,
|
| - &target_desc, name);
|
| + Maybe<bool> valid = IsCompatiblePropertyDescriptor(
|
| + isolate, extensible_target.FromJust(), desc, &target_desc, name);
|
| // 16. If valid is false, throw a TypeError exception.
|
| - if (!valid) {
|
| - DCHECK(isolate->has_pending_exception());
|
| - return false;
|
| - }
|
| + MAYBE_RETURN(valid, Nothing<bool>());
|
| + DCHECK(valid.FromJust());
|
| // 17. If resultDesc.[[Configurable]] is false, then
|
| if (!desc->configurable()) {
|
| // 17a. If targetDesc is undefined or targetDesc.[[Configurable]] is true:
|
| @@ -7103,11 +7063,11 @@ bool JSProxy::GetOwnPropertyDescriptor(Isolate* isolate, Handle<JSProxy> proxy,
|
| // 17a i. Throw a TypeError exception.
|
| isolate->Throw(*isolate->factory()->NewTypeError(
|
| MessageTemplate::kRedefineDisallowed, name));
|
| - return false;
|
| + return Nothing<bool>();
|
| }
|
| }
|
| // 18. Return resultDesc.
|
| - return true;
|
| + return Just(true);
|
| }
|
|
|
|
|
| @@ -7285,8 +7245,9 @@ Maybe<bool> JSReceiver::SetIntegrityLevel(Handle<JSReceiver> receiver,
|
| if (level == SEALED) {
|
| for (int i = 0; i < keys->length(); ++i) {
|
| Handle<Object> key(keys->get(i), isolate);
|
| - DefineOwnProperty(isolate, receiver, key, &no_conf, THROW_ON_ERROR);
|
| - if (isolate->has_pending_exception()) return Nothing<bool>();
|
| + MAYBE_RETURN(
|
| + DefineOwnProperty(isolate, receiver, key, &no_conf, THROW_ON_ERROR),
|
| + Nothing<bool>());
|
| }
|
| return Just(true);
|
| }
|
| @@ -7294,16 +7255,17 @@ Maybe<bool> JSReceiver::SetIntegrityLevel(Handle<JSReceiver> receiver,
|
| for (int i = 0; i < keys->length(); ++i) {
|
| Handle<Object> key(keys->get(i), isolate);
|
| PropertyDescriptor current_desc;
|
| - bool owned = JSReceiver::GetOwnPropertyDescriptor(isolate, receiver, key,
|
| - ¤t_desc);
|
| - if (isolate->has_pending_exception()) return Nothing<bool>();
|
| - if (owned) {
|
| + Maybe<bool> owned = JSReceiver::GetOwnPropertyDescriptor(
|
| + isolate, receiver, key, ¤t_desc);
|
| + MAYBE_RETURN(owned, Nothing<bool>());
|
| + if (owned.FromJust()) {
|
| PropertyDescriptor desc =
|
| PropertyDescriptor::IsAccessorDescriptor(¤t_desc)
|
| ? no_conf
|
| : no_conf_no_write;
|
| - DefineOwnProperty(isolate, receiver, key, &desc, THROW_ON_ERROR);
|
| - if (isolate->has_pending_exception()) return Nothing<bool>();
|
| + MAYBE_RETURN(
|
| + DefineOwnProperty(isolate, receiver, key, &desc, THROW_ON_ERROR),
|
| + Nothing<bool>());
|
| }
|
| }
|
| return Just(true);
|
| @@ -7326,10 +7288,10 @@ Maybe<bool> JSReceiver::TestIntegrityLevel(Handle<JSReceiver> object,
|
| for (int i = 0; i < keys->length(); ++i) {
|
| Handle<Object> key(keys->get(i), isolate);
|
| PropertyDescriptor current_desc;
|
| - bool owned = JSReceiver::GetOwnPropertyDescriptor(isolate, object, key,
|
| - ¤t_desc);
|
| - if (isolate->has_pending_exception()) return Nothing<bool>();
|
| - if (owned) {
|
| + Maybe<bool> owned = JSReceiver::GetOwnPropertyDescriptor(
|
| + isolate, object, key, ¤t_desc);
|
| + MAYBE_RETURN(owned, Nothing<bool>());
|
| + if (owned.FromJust()) {
|
| if (current_desc.configurable()) return Just(false);
|
| if (level == FROZEN &&
|
| PropertyDescriptor::IsDataDescriptor(¤t_desc) &&
|
| @@ -7369,8 +7331,8 @@ Maybe<bool> JSProxy::PreventExtensions(Handle<JSProxy> proxy,
|
| Handle<JSReceiver> handler(JSReceiver::cast(proxy->handler()), isolate);
|
|
|
| Handle<Object> trap;
|
| - ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, trap, GetTrap(proxy, trap_name),
|
| - Nothing<bool>());
|
| + ASSIGN_RETURN_ON_EXCEPTION_VALUE(
|
| + isolate, trap, Object::GetMethod(handler, trap_name), Nothing<bool>());
|
| if (trap->IsUndefined()) {
|
| return JSReceiver::PreventExtensions(target, should_throw);
|
| }
|
| @@ -7478,8 +7440,8 @@ Maybe<bool> JSProxy::IsExtensible(Handle<JSProxy> proxy) {
|
| Handle<JSReceiver> handler(JSReceiver::cast(proxy->handler()), isolate);
|
|
|
| Handle<Object> trap;
|
| - ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, trap, GetTrap(proxy, trap_name),
|
| - Nothing<bool>());
|
| + ASSIGN_RETURN_ON_EXCEPTION_VALUE(
|
| + isolate, trap, Object::GetMethod(handler, trap_name), Nothing<bool>());
|
| if (trap->IsUndefined()) {
|
| return JSReceiver::IsExtensible(target);
|
| }
|
| @@ -8258,24 +8220,24 @@ Handle<FixedArray> JSObject::GetEnumPropertyKeys(Handle<JSObject> object,
|
| enum IndexedOrNamed { kIndexed, kNamed };
|
|
|
|
|
| -// Returns false iff there was an exception.
|
| +// Returns |true| on success, |nothing| on exception.
|
| template <class Callback, IndexedOrNamed type>
|
| -static bool GetKeysFromInterceptor(Isolate* isolate,
|
| - Handle<JSReceiver> receiver,
|
| - Handle<JSObject> object,
|
| - PropertyFilter filter,
|
| - KeyAccumulator* accumulator) {
|
| +static Maybe<bool> GetKeysFromInterceptor(Isolate* isolate,
|
| + Handle<JSReceiver> receiver,
|
| + Handle<JSObject> object,
|
| + PropertyFilter filter,
|
| + KeyAccumulator* accumulator) {
|
| if (type == kIndexed) {
|
| - if (!object->HasIndexedInterceptor()) return true;
|
| + if (!object->HasIndexedInterceptor()) return Just(true);
|
| } else {
|
| - if (!object->HasNamedInterceptor()) return true;
|
| + if (!object->HasNamedInterceptor()) return Just(true);
|
| }
|
| Handle<InterceptorInfo> interceptor(type == kIndexed
|
| ? object->GetIndexedInterceptor()
|
| : object->GetNamedInterceptor(),
|
| isolate);
|
| if ((filter & ONLY_ALL_CAN_READ) && !interceptor->all_can_read()) {
|
| - return true;
|
| + return Just(true);
|
| }
|
| PropertyCallbackArguments args(isolate, interceptor->data(), *receiver,
|
| *object);
|
| @@ -8287,8 +8249,8 @@ static bool GetKeysFromInterceptor(Isolate* isolate,
|
| LOG(isolate, ApiObjectAccess(log_tag, *object));
|
| result = args.Call(enum_fun);
|
| }
|
| - RETURN_VALUE_IF_SCHEDULED_EXCEPTION(isolate, false);
|
| - if (result.IsEmpty()) return true;
|
| + RETURN_VALUE_IF_SCHEDULED_EXCEPTION(isolate, Nothing<bool>());
|
| + if (result.IsEmpty()) return Just(true);
|
| DCHECK(v8::Utils::OpenHandle(*result)->IsJSArray() ||
|
| (v8::Utils::OpenHandle(*result)->IsJSObject() &&
|
| Handle<JSObject>::cast(v8::Utils::OpenHandle(*result))
|
| @@ -8301,14 +8263,18 @@ static bool GetKeysFromInterceptor(Isolate* isolate,
|
| accumulator->AddKeys(
|
| Handle<JSObject>::cast(v8::Utils::OpenHandle(*result)));
|
| }
|
| - return true;
|
| + return Just(true);
|
| }
|
|
|
|
|
| -static bool GetKeysFromJSObject(Isolate* isolate, Handle<JSReceiver> receiver,
|
| - Handle<JSObject> object, PropertyFilter* filter,
|
| - JSReceiver::KeyCollectionType type,
|
| - KeyAccumulator* accumulator) {
|
| +// Returns |true| on success, |false| if prototype walking should be stopped,
|
| +// |nothing| if an exception was thrown.
|
| +static Maybe<bool> GetKeysFromJSObject(Isolate* isolate,
|
| + Handle<JSReceiver> receiver,
|
| + Handle<JSObject> object,
|
| + PropertyFilter* filter,
|
| + JSReceiver::KeyCollectionType type,
|
| + KeyAccumulator* accumulator) {
|
| accumulator->NextPrototype();
|
| // Check access rights if required.
|
| if (object->IsAccessCheckNeeded() &&
|
| @@ -8316,7 +8282,7 @@ static bool GetKeysFromJSObject(Isolate* isolate, Handle<JSReceiver> receiver,
|
| // The cross-origin spec says that [[Enumerate]] shall return an empty
|
| // iterator when it doesn't have access...
|
| if (type == JSReceiver::INCLUDE_PROTOS) {
|
| - return false;
|
| + return Just(false);
|
| }
|
| // ...whereas [[OwnPropertyKeys]] shall return whitelisted properties.
|
| DCHECK(type == JSReceiver::OWN_ONLY);
|
| @@ -8326,11 +8292,10 @@ static bool GetKeysFromJSObject(Isolate* isolate, Handle<JSReceiver> receiver,
|
| JSObject::CollectOwnElementKeys(object, accumulator, *filter);
|
|
|
| // Add the element keys from the interceptor.
|
| - if (!GetKeysFromInterceptor<v8::IndexedPropertyEnumeratorCallback, kIndexed>(
|
| - isolate, receiver, object, *filter, accumulator)) {
|
| - DCHECK(isolate->has_pending_exception());
|
| - return false;
|
| - }
|
| + Maybe<bool> success =
|
| + GetKeysFromInterceptor<v8::IndexedPropertyEnumeratorCallback, kIndexed>(
|
| + isolate, receiver, object, *filter, accumulator);
|
| + MAYBE_RETURN(success, Nothing<bool>());
|
|
|
| if (*filter == ENUMERABLE_STRINGS) {
|
| // We can cache the computed property keys if access checks are
|
| @@ -8358,23 +8323,22 @@ static bool GetKeysFromJSObject(Isolate* isolate, Handle<JSReceiver> receiver,
|
| }
|
|
|
| // Add the property keys from the interceptor.
|
| - if (!GetKeysFromInterceptor<v8::GenericNamedPropertyEnumeratorCallback,
|
| - kNamed>(isolate, receiver, object, *filter,
|
| - accumulator)) {
|
| - DCHECK(isolate->has_pending_exception());
|
| - return false;
|
| - }
|
| - return true;
|
| + success = GetKeysFromInterceptor<v8::GenericNamedPropertyEnumeratorCallback,
|
| + kNamed>(isolate, receiver, object, *filter,
|
| + accumulator);
|
| + MAYBE_RETURN(success, Nothing<bool>());
|
| + return Just(true);
|
| }
|
|
|
|
|
| // Helper function for JSReceiver::GetKeys() below. Can be called recursively.
|
| -// Returns false iff an exception was thrown.
|
| -static bool GetKeys_Internal(Isolate* isolate, Handle<JSReceiver> receiver,
|
| - Handle<JSReceiver> object,
|
| - JSReceiver::KeyCollectionType type,
|
| - PropertyFilter filter,
|
| - KeyAccumulator* accumulator) {
|
| +// Returns |true| or |nothing|.
|
| +static Maybe<bool> GetKeys_Internal(Isolate* isolate,
|
| + Handle<JSReceiver> receiver,
|
| + Handle<JSReceiver> object,
|
| + JSReceiver::KeyCollectionType type,
|
| + PropertyFilter filter,
|
| + KeyAccumulator* accumulator) {
|
| PrototypeIterator::WhereToEnd end = type == JSReceiver::OWN_ONLY
|
| ? PrototypeIterator::END_AT_NON_HIDDEN
|
| : PrototypeIterator::END_AT_NULL;
|
| @@ -8383,7 +8347,7 @@ static bool GetKeys_Internal(Isolate* isolate, Handle<JSReceiver> receiver,
|
| !iter.IsAtEnd(end); iter.Advance()) {
|
| Handle<JSReceiver> current =
|
| PrototypeIterator::GetCurrent<JSReceiver>(iter);
|
| - bool result = false;
|
| + Maybe<bool> result = Just(false); // Dummy initialization.
|
| if (current->IsJSProxy()) {
|
| if (type == JSReceiver::OWN_ONLY) {
|
| result = JSProxy::OwnPropertyKeys(isolate, receiver,
|
| @@ -8400,23 +8364,19 @@ static bool GetKeys_Internal(Isolate* isolate, Handle<JSReceiver> receiver,
|
| Handle<JSObject>::cast(current), &filter,
|
| type, accumulator);
|
| }
|
| - if (!result) {
|
| - if (isolate->has_pending_exception()) {
|
| - return false;
|
| - }
|
| - // If there was no exception, then "false" means "stop iterating".
|
| - break;
|
| - }
|
| + MAYBE_RETURN(result, Nothing<bool>());
|
| + if (!result.FromJust()) break; // |false| means "stop iterating".
|
| }
|
| - return true;
|
| + return Just(true);
|
| }
|
|
|
|
|
| // ES6 9.5.11
|
| // Returns false in case of exception.
|
| // static
|
| -bool JSProxy::Enumerate(Isolate* isolate, Handle<JSReceiver> receiver,
|
| - Handle<JSProxy> proxy, KeyAccumulator* accumulator) {
|
| +Maybe<bool> JSProxy::Enumerate(Isolate* isolate, Handle<JSReceiver> receiver,
|
| + Handle<JSProxy> proxy,
|
| + KeyAccumulator* accumulator) {
|
| // 1. Let handler be the value of the [[ProxyHandler]] internal slot of O.
|
| Handle<Object> handler(proxy->handler(), isolate);
|
| // 2. If handler is null, throw a TypeError exception.
|
| @@ -8425,7 +8385,7 @@ bool JSProxy::Enumerate(Isolate* isolate, Handle<JSReceiver> receiver,
|
| isolate->Throw(*isolate->factory()->NewTypeError(
|
| MessageTemplate::kProxyRevoked,
|
| isolate->factory()->enumerate_string()));
|
| - return false;
|
| + return Nothing<bool>();
|
| }
|
| // 4. Let target be the value of the [[ProxyTarget]] internal slot of O.
|
| Handle<JSReceiver> target(proxy->target(), isolate);
|
| @@ -8434,7 +8394,7 @@ bool JSProxy::Enumerate(Isolate* isolate, Handle<JSReceiver> receiver,
|
| ASSIGN_RETURN_ON_EXCEPTION_VALUE(
|
| isolate, trap, Object::GetMethod(Handle<JSReceiver>::cast(handler),
|
| isolate->factory()->enumerate_string()),
|
| - false);
|
| + Nothing<bool>());
|
| // 6. If trap is undefined, then
|
| if (trap->IsUndefined()) {
|
| // 6a. Return target.[[Enumerate]]().
|
| @@ -8451,10 +8411,10 @@ bool JSProxy::Enumerate(Isolate* isolate, Handle<JSReceiver> receiver,
|
| Execution::Call(isolate, isolate->proxy_enumerate(),
|
| isolate->factory()->undefined_value(), arraysize(args),
|
| args),
|
| - false);
|
| + Nothing<bool>());
|
| accumulator->NextPrototype();
|
| accumulator->AddKeysFromProxy(Handle<JSObject>::cast(trap_result_array));
|
| - return true;
|
| + return Just(true);
|
| }
|
|
|
|
|
| @@ -8517,11 +8477,13 @@ static MaybeHandle<FixedArray> CreateListFromArrayLike_StringSymbol(
|
|
|
|
|
| // ES6 9.5.12
|
| -// Returns "false" in case of exception.
|
| +// Returns |true| on success, |nothing| in case of exception.
|
| // static
|
| -bool JSProxy::OwnPropertyKeys(Isolate* isolate, Handle<JSReceiver> receiver,
|
| - Handle<JSProxy> proxy, PropertyFilter filter,
|
| - KeyAccumulator* accumulator) {
|
| +Maybe<bool> JSProxy::OwnPropertyKeys(Isolate* isolate,
|
| + Handle<JSReceiver> receiver,
|
| + Handle<JSProxy> proxy,
|
| + PropertyFilter filter,
|
| + KeyAccumulator* accumulator) {
|
| // 1. Let handler be the value of the [[ProxyHandler]] internal slot of O.
|
| Handle<Object> handler(proxy->handler(), isolate);
|
| // 2. If handler is null, throw a TypeError exception.
|
| @@ -8529,7 +8491,7 @@ bool JSProxy::OwnPropertyKeys(Isolate* isolate, Handle<JSReceiver> receiver,
|
| if (proxy->IsRevoked()) {
|
| isolate->Throw(*isolate->factory()->NewTypeError(
|
| MessageTemplate::kProxyRevoked, isolate->factory()->ownKeys_string()));
|
| - return false;
|
| + return Nothing<bool>();
|
| }
|
| // 4. Let target be the value of the [[ProxyTarget]] internal slot of O.
|
| Handle<JSReceiver> target(proxy->target(), isolate);
|
| @@ -8538,7 +8500,7 @@ bool JSProxy::OwnPropertyKeys(Isolate* isolate, Handle<JSReceiver> receiver,
|
| ASSIGN_RETURN_ON_EXCEPTION_VALUE(
|
| isolate, trap, Object::GetMethod(Handle<JSReceiver>::cast(handler),
|
| isolate->factory()->ownKeys_string()),
|
| - false);
|
| + Nothing<bool>());
|
| // 6. If trap is undefined, then
|
| if (trap->IsUndefined()) {
|
| // 6a. Return target.[[OwnPropertyKeys]]().
|
| @@ -8550,21 +8512,24 @@ bool JSProxy::OwnPropertyKeys(Isolate* isolate, Handle<JSReceiver> receiver,
|
| Handle<Object> args[] = {target};
|
| ASSIGN_RETURN_ON_EXCEPTION_VALUE(
|
| isolate, trap_result_array,
|
| - Execution::Call(isolate, trap, handler, arraysize(args), args), false);
|
| + Execution::Call(isolate, trap, handler, arraysize(args), args),
|
| + Nothing<bool>());
|
| // 8. Let trapResult be ? CreateListFromArrayLike(trapResultArray,
|
| // «String, Symbol»).
|
| Handle<FixedArray> trap_result;
|
| ASSIGN_RETURN_ON_EXCEPTION_VALUE(
|
| isolate, trap_result,
|
| - CreateListFromArrayLike_StringSymbol(isolate, trap_result_array), false);
|
| + CreateListFromArrayLike_StringSymbol(isolate, trap_result_array),
|
| + Nothing<bool>());
|
| // 9. Let extensibleTarget be ? IsExtensible(target).
|
| Maybe<bool> maybe_extensible = JSReceiver::IsExtensible(target);
|
| - if (maybe_extensible.IsNothing()) return false;
|
| + MAYBE_RETURN(maybe_extensible, Nothing<bool>());
|
| bool extensible_target = maybe_extensible.FromJust();
|
| // 10. Let targetKeys be ? target.[[OwnPropertyKeys]]().
|
| Handle<FixedArray> target_keys;
|
| ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, target_keys,
|
| - JSReceiver::OwnPropertyKeys(target), false);
|
| + JSReceiver::OwnPropertyKeys(target),
|
| + Nothing<bool>());
|
| // 11. (Assert)
|
| // 12. Let targetConfigurableKeys be an empty List.
|
| // To save memory, we're re-using target_keys and will modify it in-place.
|
| @@ -8577,11 +8542,11 @@ bool JSProxy::OwnPropertyKeys(Isolate* isolate, Handle<JSReceiver> receiver,
|
| for (int i = 0; i < target_keys->length(); ++i) {
|
| // 14a. Let desc be ? target.[[GetOwnProperty]](key).
|
| PropertyDescriptor desc;
|
| - bool found = JSReceiver::GetOwnPropertyDescriptor(
|
| + Maybe<bool> found = JSReceiver::GetOwnPropertyDescriptor(
|
| isolate, target, handle(target_keys->get(i), isolate), &desc);
|
| - if (isolate->has_pending_exception()) return false;
|
| + MAYBE_RETURN(found, Nothing<bool>());
|
| // 14b. If desc is not undefined and desc.[[Configurable]] is false, then
|
| - if (found && !desc.configurable()) {
|
| + if (found.FromJust() && !desc.configurable()) {
|
| // 14b i. Append key as an element of targetNonconfigurableKeys.
|
| target_nonconfigurable_keys->set(nonconfigurable_keys_length,
|
| target_keys->get(i));
|
| @@ -8620,7 +8585,7 @@ bool JSProxy::OwnPropertyKeys(Isolate* isolate, Handle<JSReceiver> receiver,
|
| if (found == nullptr || *found == kGone) {
|
| isolate->Throw(*isolate->factory()->NewTypeError(
|
| MessageTemplate::kProxyTrapResultMustInclude, handle(key, isolate)));
|
| - return false;
|
| + return Nothing<bool>();
|
| }
|
| // 17b. Remove key from uncheckedResultKeys.
|
| *found = kGone;
|
| @@ -8640,7 +8605,7 @@ bool JSProxy::OwnPropertyKeys(Isolate* isolate, Handle<JSReceiver> receiver,
|
| if (found == nullptr || *found == kGone) {
|
| isolate->Throw(*isolate->factory()->NewTypeError(
|
| MessageTemplate::kProxyTrapResultMustInclude, handle(key, isolate)));
|
| - return false;
|
| + return Nothing<bool>();
|
| }
|
| // 19b. Remove key from uncheckedResultKeys.
|
| *found = kGone;
|
| @@ -8651,7 +8616,7 @@ bool JSProxy::OwnPropertyKeys(Isolate* isolate, Handle<JSReceiver> receiver,
|
| DCHECK_GT(unchecked_result_keys_size, 0);
|
| isolate->Throw(*isolate->factory()->NewTypeError(
|
| MessageTemplate::kProxyTargetNotExtensible));
|
| - return false;
|
| + return Nothing<bool>();
|
| }
|
| // 21. Return trapResult.
|
| return accumulator->AddKeysFromProxy(proxy, trap_result);
|
| @@ -8665,10 +8630,9 @@ MaybeHandle<FixedArray> JSReceiver::GetKeys(Handle<JSReceiver> object,
|
| USE(ContainsOnlyValidKeys);
|
| Isolate* isolate = object->GetIsolate();
|
| KeyAccumulator accumulator(isolate, filter);
|
| - if (!GetKeys_Internal(isolate, object, object, type, filter, &accumulator)) {
|
| - DCHECK(isolate->has_pending_exception());
|
| - return MaybeHandle<FixedArray>();
|
| - }
|
| + MAYBE_RETURN(
|
| + GetKeys_Internal(isolate, object, object, type, filter, &accumulator),
|
| + MaybeHandle<FixedArray>());
|
| Handle<FixedArray> keys = accumulator.GetKeys(keys_conversion);
|
| DCHECK(ContainsOnlyValidKeys(keys));
|
| return keys;
|
|
|