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

Side by Side Diff: src/objects-inl.h

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 unified diff | Download patch
« no previous file with comments | « src/objects.cc ('k') | test/mjsunit/harmony/proxies.js » ('j') | 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 7256 matching lines...) Expand 10 before | Expand all | Expand 10 after
7267 Handle<Object> receiver, 7267 Handle<Object> receiver,
7268 LanguageMode language_mode) { 7268 LanguageMode language_mode) {
7269 LookupIterator it = LookupIterator::PropertyOrElement( 7269 LookupIterator it = LookupIterator::PropertyOrElement(
7270 name->GetIsolate(), receiver, name, holder); 7270 name->GetIsolate(), receiver, name, holder);
7271 return GetProperty(&it, language_mode); 7271 return GetProperty(&it, language_mode);
7272 } 7272 }
7273 7273
7274 7274
7275 Maybe<bool> JSReceiver::HasProperty(Handle<JSReceiver> object, 7275 Maybe<bool> JSReceiver::HasProperty(Handle<JSReceiver> object,
7276 Handle<Name> name) { 7276 Handle<Name> name) {
7277 // Call the "has" trap on proxies. 7277 LookupIterator it =
7278 if (object->IsJSProxy()) { 7278 LookupIterator::PropertyOrElement(object->GetIsolate(), object, name);
7279 Handle<JSProxy> proxy = Handle<JSProxy>::cast(object); 7279 return HasProperty(&it);
7280 return JSProxy::HasPropertyWithHandler(proxy, name);
7281 }
7282
7283 Maybe<PropertyAttributes> result = GetPropertyAttributes(object, name);
7284 return result.IsJust() ? Just(result.FromJust() != ABSENT) : Nothing<bool>();
7285 } 7280 }
7286 7281
7287 7282
7288 Maybe<bool> JSReceiver::HasOwnProperty(Handle<JSReceiver> object, 7283 Maybe<bool> JSReceiver::HasOwnProperty(Handle<JSReceiver> object,
7289 Handle<Name> name) { 7284 Handle<Name> name) {
7290 // Call the "has" trap on proxies. 7285 LookupIterator it = LookupIterator::PropertyOrElement(
7291 if (object->IsJSProxy()) { 7286 object->GetIsolate(), object, name, LookupIterator::HIDDEN);
7292 Handle<JSProxy> proxy = Handle<JSProxy>::cast(object); 7287 return HasProperty(&it);
7293 return JSProxy::HasPropertyWithHandler(proxy, name);
7294 }
7295
7296 Maybe<PropertyAttributes> result = GetOwnPropertyAttributes(object, name);
7297 return result.IsJust() ? Just(result.FromJust() != ABSENT) : Nothing<bool>();
7298 } 7288 }
7299 7289
7300 7290
7301 Maybe<PropertyAttributes> JSReceiver::GetPropertyAttributes( 7291 Maybe<PropertyAttributes> JSReceiver::GetPropertyAttributes(
7302 Handle<JSReceiver> object, Handle<Name> name) { 7292 Handle<JSReceiver> object, Handle<Name> name) {
7303 LookupIterator it = 7293 LookupIterator it =
7304 LookupIterator::PropertyOrElement(name->GetIsolate(), object, name); 7294 LookupIterator::PropertyOrElement(name->GetIsolate(), object, name);
7305 return GetPropertyAttributes(&it); 7295 return GetPropertyAttributes(&it);
7306 } 7296 }
7307 7297
7308 7298
7309 Maybe<PropertyAttributes> JSReceiver::GetOwnPropertyAttributes( 7299 Maybe<PropertyAttributes> JSReceiver::GetOwnPropertyAttributes(
7310 Handle<JSReceiver> object, Handle<Name> name) { 7300 Handle<JSReceiver> object, Handle<Name> name) {
7311 LookupIterator it = LookupIterator::PropertyOrElement( 7301 LookupIterator it = LookupIterator::PropertyOrElement(
7312 name->GetIsolate(), object, name, LookupIterator::HIDDEN); 7302 name->GetIsolate(), object, name, LookupIterator::HIDDEN);
7313 return GetPropertyAttributes(&it); 7303 return GetPropertyAttributes(&it);
7314 } 7304 }
7315 7305
7316 7306
7317 Maybe<bool> JSReceiver::HasElement(Handle<JSReceiver> object, uint32_t index) { 7307 Maybe<bool> JSReceiver::HasElement(Handle<JSReceiver> object, uint32_t index) {
7318 // Call the "has" trap on proxies. 7308 LookupIterator it(object->GetIsolate(), object, index);
7319 if (object->IsJSProxy()) { 7309 return HasProperty(&it);
7320 Isolate* isolate = object->GetIsolate();
7321 Handle<Name> name = isolate->factory()->Uint32ToString(index);
7322 Handle<JSProxy> proxy = Handle<JSProxy>::cast(object);
7323 return JSProxy::HasPropertyWithHandler(proxy, name);
7324 }
7325
7326 Maybe<PropertyAttributes> result = GetElementAttributes(object, index);
7327 return result.IsJust() ? Just(result.FromJust() != ABSENT) : Nothing<bool>();
7328 } 7310 }
7329 7311
7330 7312
7331 Maybe<bool> JSReceiver::HasOwnElement(Handle<JSReceiver> object, 7313 Maybe<bool> JSReceiver::HasOwnElement(Handle<JSReceiver> object,
7332 uint32_t index) { 7314 uint32_t index) {
7333 // Call the "has" trap on proxies. 7315 LookupIterator it(object->GetIsolate(), object, index,
7334 if (object->IsJSProxy()) { 7316 LookupIterator::HIDDEN);
7335 Isolate* isolate = object->GetIsolate(); 7317 return HasProperty(&it);
7336 Handle<Name> name = isolate->factory()->Uint32ToString(index);
7337 Handle<JSProxy> proxy = Handle<JSProxy>::cast(object);
7338 return JSProxy::HasPropertyWithHandler(proxy, name);
7339 }
7340
7341 Maybe<PropertyAttributes> result = GetOwnElementAttributes(object, index);
7342 return result.IsJust() ? Just(result.FromJust() != ABSENT) : Nothing<bool>();
7343 } 7318 }
7344 7319
7345 7320
7346 Maybe<PropertyAttributes> JSReceiver::GetElementAttributes( 7321 Maybe<PropertyAttributes> JSReceiver::GetElementAttributes(
7347 Handle<JSReceiver> object, uint32_t index) { 7322 Handle<JSReceiver> object, uint32_t index) {
7348 Isolate* isolate = object->GetIsolate(); 7323 Isolate* isolate = object->GetIsolate();
7349 LookupIterator it(isolate, object, index); 7324 LookupIterator it(isolate, object, index);
7350 return GetPropertyAttributes(&it); 7325 return GetPropertyAttributes(&it);
7351 } 7326 }
7352 7327
(...skipping 777 matching lines...) Expand 10 before | Expand all | Expand 10 after
8130 #undef WRITE_INT64_FIELD 8105 #undef WRITE_INT64_FIELD
8131 #undef READ_BYTE_FIELD 8106 #undef READ_BYTE_FIELD
8132 #undef WRITE_BYTE_FIELD 8107 #undef WRITE_BYTE_FIELD
8133 #undef NOBARRIER_READ_BYTE_FIELD 8108 #undef NOBARRIER_READ_BYTE_FIELD
8134 #undef NOBARRIER_WRITE_BYTE_FIELD 8109 #undef NOBARRIER_WRITE_BYTE_FIELD
8135 8110
8136 } // namespace internal 8111 } // namespace internal
8137 } // namespace v8 8112 } // namespace v8
8138 8113
8139 #endif // V8_OBJECTS_INL_H_ 8114 #endif // V8_OBJECTS_INL_H_
OLDNEW
« no previous file with comments | « src/objects.cc ('k') | test/mjsunit/harmony/proxies.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698