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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « src/objects.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 // 4 //
5 // Review notes: 5 // Review notes:
6 // 6 //
7 // - The use of macros in these inline functions may seem superfluous 7 // - The use of macros in these inline functions may seem superfluous
8 // but it is absolutely needed to make sure gcc generates optimal 8 // but it is absolutely needed to make sure gcc generates optimal
9 // code. gcc is not happy when attempting to inline too deep. 9 // code. gcc is not happy when attempting to inline too deep.
10 // 10 //
(...skipping 6988 matching lines...) Expand 10 before | Expand all | Expand 10 after
6999 6999
7000 7000
7001 Maybe<bool> JSReceiver::HasProperty(Handle<JSReceiver> object, 7001 Maybe<bool> JSReceiver::HasProperty(Handle<JSReceiver> object,
7002 Handle<Name> name) { 7002 Handle<Name> name) {
7003 // Call the "has" trap on proxies. 7003 // Call the "has" trap on proxies.
7004 if (object->IsJSProxy()) { 7004 if (object->IsJSProxy()) {
7005 Handle<JSProxy> proxy = Handle<JSProxy>::cast(object); 7005 Handle<JSProxy> proxy = Handle<JSProxy>::cast(object);
7006 return JSProxy::HasPropertyWithHandler(proxy, name); 7006 return JSProxy::HasPropertyWithHandler(proxy, name);
7007 } 7007 }
7008 7008
7009 DescriptorArray* desc;
7010 PrototypeIterator iter(object->GetIsolate(), *object,
7011 PrototypeIterator::START_AT_RECEIVER);
7012 while (!iter.IsAtEnd()) {
7013 if (iter.GetCurrent()->IsJSObject()) {
7014 JSReceiver* prototype_object = JSReceiver::cast(iter.GetCurrent());
7015 desc = prototype_object->map()->instance_descriptors();
7016 if (!desc->IsEmpty()) {
7017 int there = desc->SearchWithCache(*name, prototype_object->map());
7018 if (there != desc->kNotFound)
7019 return Just(true);
7020 }
7021 }
7022 iter.Advance();
7023 }
7024
7009 Maybe<PropertyAttributes> result = GetPropertyAttributes(object, name); 7025 Maybe<PropertyAttributes> result = GetPropertyAttributes(object, name);
7010 return result.IsJust() ? Just(result.FromJust() != ABSENT) : Nothing<bool>(); 7026 return result.IsJust() ? Just(result.FromJust() != ABSENT) : Nothing<bool>();
7011 } 7027 }
7012 7028
7013 7029
7014 Maybe<bool> JSReceiver::HasOwnProperty(Handle<JSReceiver> object, 7030 Maybe<bool> JSReceiver::HasOwnProperty(Handle<JSReceiver> object,
7015 Handle<Name> name) { 7031 Handle<Name> name) {
7016 // Call the "has" trap on proxies. 7032 // Call the "has" trap on proxies.
7017 if (object->IsJSProxy()) { 7033 if (object->IsJSProxy()) {
7018 Handle<JSProxy> proxy = Handle<JSProxy>::cast(object); 7034 Handle<JSProxy> proxy = Handle<JSProxy>::cast(object);
(...skipping 833 matching lines...) Expand 10 before | Expand all | Expand 10 after
7852 #undef READ_INT64_FIELD 7868 #undef READ_INT64_FIELD
7853 #undef WRITE_INT64_FIELD 7869 #undef WRITE_INT64_FIELD
7854 #undef READ_BYTE_FIELD 7870 #undef READ_BYTE_FIELD
7855 #undef WRITE_BYTE_FIELD 7871 #undef WRITE_BYTE_FIELD
7856 #undef NOBARRIER_READ_BYTE_FIELD 7872 #undef NOBARRIER_READ_BYTE_FIELD
7857 #undef NOBARRIER_WRITE_BYTE_FIELD 7873 #undef NOBARRIER_WRITE_BYTE_FIELD
7858 7874
7859 } } // namespace v8::internal 7875 } } // namespace v8::internal
7860 7876
7861 #endif // V8_OBJECTS_INL_H_ 7877 #endif // V8_OBJECTS_INL_H_
OLDNEW
« 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