Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(749)

Unified Diff: src/objects.cc

Issue 1414403003: Fix HasProperty/HasElement for Proxies on the prototype chain (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
}
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698