Index: src/objects.cc |
diff --git a/src/objects.cc b/src/objects.cc |
index ecd31f7f5b531a6cc05d041d247704a0429dcf22..33c3e6a80bc9b94fefdbe8fe92f0f9d7aa0b20c5 100644 |
--- a/src/objects.cc |
+++ b/src/objects.cc |
@@ -641,6 +641,44 @@ MaybeHandle<Object> Object::GetMethod(Handle<JSReceiver> receiver, |
} |
+// static |
+Maybe<bool> JSReceiver::HasProperty(LookupIterator* it) { |
+ for (; it->IsFound(); it->Next()) { |
+ switch (it->state()) { |
+ case LookupIterator::NOT_FOUND: |
+ case LookupIterator::TRANSITION: |
+ UNREACHABLE(); |
+ case LookupIterator::JSPROXY: |
+ // Call the "has" trap on proxies. |
+ return JSProxy::HasPropertyWithHandler(it->GetHolder<JSProxy>(), |
+ it->GetName()); |
+ case LookupIterator::INTERCEPTOR: { |
+ Maybe<PropertyAttributes> result = |
+ JSObject::GetPropertyAttributesWithInterceptor(it); |
+ if (!result.IsJust()) return Nothing<bool>(); |
+ if (result.FromJust() != ABSENT) return Just(true); |
+ break; |
+ } |
+ case LookupIterator::ACCESS_CHECK: { |
+ if (it->HasAccess()) break; |
+ Maybe<PropertyAttributes> result = |
+ JSObject::GetPropertyAttributesWithFailedAccessCheck(it); |
+ if (!result.IsJust()) return Nothing<bool>(); |
+ return Just(result.FromJust() != ABSENT); |
+ } |
+ case LookupIterator::INTEGER_INDEXED_EXOTIC: |
+ // TypedArray out-of-bounds access. |
+ return Just(false); |
+ case LookupIterator::ACCESSOR: |
+ case LookupIterator::DATA: |
+ return Just(true); |
+ } |
+ } |
+ return Just(false); |
+} |
+ |
+ |
+// static |
MaybeHandle<Object> Object::GetProperty(LookupIterator* it, |
LanguageMode language_mode) { |
for (; it->IsFound(); it->Next()) { |
@@ -14858,9 +14896,7 @@ Maybe<bool> JSObject::HasRealNamedProperty(Handle<JSObject> object, |
Handle<Name> name) { |
LookupIterator it = LookupIterator::PropertyOrElement( |
name->GetIsolate(), object, name, LookupIterator::OWN_SKIP_INTERCEPTOR); |
- Maybe<PropertyAttributes> maybe_result = GetPropertyAttributes(&it); |
- if (!maybe_result.IsJust()) return Nothing<bool>(); |
- return Just(it.IsFound()); |
+ return HasProperty(&it); |
} |
@@ -14869,9 +14905,7 @@ Maybe<bool> JSObject::HasRealElementProperty(Handle<JSObject> object, |
Isolate* isolate = object->GetIsolate(); |
LookupIterator it(isolate, object, index, |
LookupIterator::OWN_SKIP_INTERCEPTOR); |
- Maybe<PropertyAttributes> maybe_result = GetPropertyAttributes(&it); |
- if (!maybe_result.IsJust()) return Nothing<bool>(); |
- return Just(it.IsFound()); |
+ return HasProperty(&it); |
} |