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

Unified Diff: src/objects-inl.h

Issue 1310953002: Use DescriptorArray when checking if an object has a property (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix Created 5 years, 4 months 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.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects-inl.h
diff --git a/src/objects-inl.h b/src/objects-inl.h
index f1309ece199a5d5d2556506cf96d7bddb03cb135..e6c49f34175e4d5a35937401528152fa209058b7 100644
--- a/src/objects-inl.h
+++ b/src/objects-inl.h
@@ -7006,6 +7006,22 @@ Maybe<bool> JSReceiver::HasProperty(Handle<JSReceiver> object,
return JSProxy::HasPropertyWithHandler(proxy, name);
}
+ DescriptorArray* desc;
+ PrototypeIterator iter(object->GetIsolate(), *object,
+ PrototypeIterator::START_AT_RECEIVER);
+ while (!iter.IsAtEnd()) {
+ if (iter.GetCurrent()->IsJSObject()) {
+ JSReceiver* prototype_object = JSReceiver::cast(iter.GetCurrent());
+ desc = prototype_object->map()->instance_descriptors();
+ if (!desc->IsEmpty()) {
+ int there = desc->SearchWithCache(*name, prototype_object->map());
+ if (there != desc->kNotFound)
+ return Just(true);
+ }
+ }
+ iter.Advance();
+ }
+
Maybe<PropertyAttributes> result = GetPropertyAttributes(object, name);
return result.IsJust() ? Just(result.FromJust() != ABSENT) : Nothing<bool>();
}
« no previous file with comments | « src/objects.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698