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

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

Issue 1178893002: Introduce LookupIterator::PropertyOrElement which converts name to index if possible. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 6 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') | src/runtime/runtime-classes.cc » ('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 6565 matching lines...) Expand 10 before | Expand all | Expand 10 after
6576 String* canonical = String::cast(READ_FIELD(this, kHashFieldSlot)); 6576 String* canonical = String::cast(READ_FIELD(this, kHashFieldSlot));
6577 DCHECK(canonical->IsInternalizedString()); 6577 DCHECK(canonical->IsInternalizedString());
6578 DCHECK(SlowEquals(canonical)); 6578 DCHECK(SlowEquals(canonical));
6579 DCHECK(canonical->HasHashCode()); 6579 DCHECK(canonical->HasHashCode());
6580 return canonical; 6580 return canonical;
6581 } 6581 }
6582 6582
6583 6583
6584 MaybeHandle<Object> Object::GetPropertyOrElement(Handle<Object> object, 6584 MaybeHandle<Object> Object::GetPropertyOrElement(Handle<Object> object,
6585 Handle<Name> name) { 6585 Handle<Name> name) {
6586 uint32_t index; 6586 LookupIterator it =
6587 LookupIterator it = name->AsArrayIndex(&index) 6587 LookupIterator::PropertyOrElement(name->GetIsolate(), object, name);
6588 ? LookupIterator(name->GetIsolate(), object, index)
6589 : LookupIterator(object, name);
6590 return GetProperty(&it); 6588 return GetProperty(&it);
6591 } 6589 }
6592 6590
6593 6591
6594 Maybe<bool> JSReceiver::HasProperty(Handle<JSReceiver> object, 6592 Maybe<bool> JSReceiver::HasProperty(Handle<JSReceiver> object,
6595 Handle<Name> name) { 6593 Handle<Name> name) {
6596 // Call the "has" trap on proxies. 6594 // Call the "has" trap on proxies.
6597 if (object->IsJSProxy()) { 6595 if (object->IsJSProxy()) {
6598 Handle<JSProxy> proxy = Handle<JSProxy>::cast(object); 6596 Handle<JSProxy> proxy = Handle<JSProxy>::cast(object);
6599 return JSProxy::HasPropertyWithHandler(proxy, name); 6597 return JSProxy::HasPropertyWithHandler(proxy, name);
(...skipping 12 matching lines...) Expand all
6612 return JSProxy::HasPropertyWithHandler(proxy, name); 6610 return JSProxy::HasPropertyWithHandler(proxy, name);
6613 } 6611 }
6614 6612
6615 Maybe<PropertyAttributes> result = GetOwnPropertyAttributes(object, name); 6613 Maybe<PropertyAttributes> result = GetOwnPropertyAttributes(object, name);
6616 return result.IsJust() ? Just(result.FromJust() != ABSENT) : Nothing<bool>(); 6614 return result.IsJust() ? Just(result.FromJust() != ABSENT) : Nothing<bool>();
6617 } 6615 }
6618 6616
6619 6617
6620 Maybe<PropertyAttributes> JSReceiver::GetPropertyAttributes( 6618 Maybe<PropertyAttributes> JSReceiver::GetPropertyAttributes(
6621 Handle<JSReceiver> object, Handle<Name> name) { 6619 Handle<JSReceiver> object, Handle<Name> name) {
6622 uint32_t index = 0; 6620 LookupIterator it =
6623 LookupIterator it = name->AsArrayIndex(&index) 6621 LookupIterator::PropertyOrElement(name->GetIsolate(), object, name);
6624 ? LookupIterator(name->GetIsolate(), object, index)
6625 : LookupIterator(object, name);
6626 return GetPropertyAttributes(&it); 6622 return GetPropertyAttributes(&it);
6627 } 6623 }
6628 6624
6629 6625
6630 Maybe<PropertyAttributes> JSReceiver::GetOwnPropertyAttributes( 6626 Maybe<PropertyAttributes> JSReceiver::GetOwnPropertyAttributes(
6631 Handle<JSReceiver> object, Handle<Name> name) { 6627 Handle<JSReceiver> object, Handle<Name> name) {
6632 uint32_t index = 0; 6628 LookupIterator it = LookupIterator::PropertyOrElement(
6633 LookupIterator::Configuration c = LookupIterator::HIDDEN; 6629 name->GetIsolate(), object, name, LookupIterator::HIDDEN);
6634 LookupIterator it = name->AsArrayIndex(&index)
6635 ? LookupIterator(name->GetIsolate(), object, index, c)
6636 : LookupIterator(object, name, c);
6637 return GetPropertyAttributes(&it); 6630 return GetPropertyAttributes(&it);
6638 } 6631 }
6639 6632
6640 6633
6641 Maybe<bool> JSReceiver::HasElement(Handle<JSReceiver> object, uint32_t index) { 6634 Maybe<bool> JSReceiver::HasElement(Handle<JSReceiver> object, uint32_t index) {
6642 // Call the "has" trap on proxies. 6635 // Call the "has" trap on proxies.
6643 if (object->IsJSProxy()) { 6636 if (object->IsJSProxy()) {
6644 Isolate* isolate = object->GetIsolate(); 6637 Isolate* isolate = object->GetIsolate();
6645 Handle<Name> name = isolate->factory()->Uint32ToString(index); 6638 Handle<Name> name = isolate->factory()->Uint32ToString(index);
6646 Handle<JSProxy> proxy = Handle<JSProxy>::cast(object); 6639 Handle<JSProxy> proxy = Handle<JSProxy>::cast(object);
(...skipping 700 matching lines...) Expand 10 before | Expand all | Expand 10 after
7347 #undef READ_SHORT_FIELD 7340 #undef READ_SHORT_FIELD
7348 #undef WRITE_SHORT_FIELD 7341 #undef WRITE_SHORT_FIELD
7349 #undef READ_BYTE_FIELD 7342 #undef READ_BYTE_FIELD
7350 #undef WRITE_BYTE_FIELD 7343 #undef WRITE_BYTE_FIELD
7351 #undef NOBARRIER_READ_BYTE_FIELD 7344 #undef NOBARRIER_READ_BYTE_FIELD
7352 #undef NOBARRIER_WRITE_BYTE_FIELD 7345 #undef NOBARRIER_WRITE_BYTE_FIELD
7353 7346
7354 } } // namespace v8::internal 7347 } } // namespace v8::internal
7355 7348
7356 #endif // V8_OBJECTS_INL_H_ 7349 #endif // V8_OBJECTS_INL_H_
OLDNEW
« no previous file with comments | « src/objects.cc ('k') | src/runtime/runtime-classes.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698