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

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

Issue 1775973002: Add GetProperty/GetElement to JSReceiver and use it where possible (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 9 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/property-descriptor.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 1035 matching lines...) Expand 10 before | Expand all | Expand 10 after
1046 return this->IsJSObject() && (JSObject::cast(this)->class_name() == name); 1046 return this->IsJSObject() && (JSObject::cast(this)->class_name() == name);
1047 } 1047 }
1048 1048
1049 MaybeHandle<Object> Object::GetProperty(Handle<Object> object, 1049 MaybeHandle<Object> Object::GetProperty(Handle<Object> object,
1050 Handle<Name> name) { 1050 Handle<Name> name) {
1051 LookupIterator it(object, name); 1051 LookupIterator it(object, name);
1052 if (!it.IsFound()) return it.factory()->undefined_value(); 1052 if (!it.IsFound()) return it.factory()->undefined_value();
1053 return GetProperty(&it); 1053 return GetProperty(&it);
1054 } 1054 }
1055 1055
1056 MaybeHandle<Object> JSReceiver::GetProperty(Handle<JSReceiver> receiver,
1057 Handle<Name> name) {
1058 LookupIterator it(receiver, name, receiver);
1059 if (!it.IsFound()) return it.factory()->undefined_value();
1060 return Object::GetProperty(&it);
1061 }
1062
1056 MaybeHandle<Object> Object::GetElement(Isolate* isolate, Handle<Object> object, 1063 MaybeHandle<Object> Object::GetElement(Isolate* isolate, Handle<Object> object,
1057 uint32_t index) { 1064 uint32_t index) {
1058 LookupIterator it(isolate, object, index); 1065 LookupIterator it(isolate, object, index);
1059 if (!it.IsFound()) return it.factory()->undefined_value(); 1066 if (!it.IsFound()) return it.factory()->undefined_value();
1060 return GetProperty(&it); 1067 return GetProperty(&it);
1061 } 1068 }
1062 1069
1070 MaybeHandle<Object> JSReceiver::GetElement(Isolate* isolate,
1071 Handle<JSReceiver> receiver,
1072 uint32_t index) {
1073 LookupIterator it(isolate, receiver, index, receiver);
1074 if (!it.IsFound()) return it.factory()->undefined_value();
1075 return Object::GetProperty(&it);
1076 }
1077
1063 Handle<Object> JSReceiver::GetDataProperty(Handle<JSReceiver> object, 1078 Handle<Object> JSReceiver::GetDataProperty(Handle<JSReceiver> object,
1064 Handle<Name> name) { 1079 Handle<Name> name) {
1065 LookupIterator it(object, name, object, 1080 LookupIterator it(object, name, object,
1066 LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR); 1081 LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR);
1067 if (!it.IsFound()) return it.factory()->undefined_value(); 1082 if (!it.IsFound()) return it.factory()->undefined_value();
1068 return GetDataProperty(&it); 1083 return GetDataProperty(&it);
1069 } 1084 }
1070 1085
1071 MaybeHandle<Object> Object::SetElement(Isolate* isolate, Handle<Object> object, 1086 MaybeHandle<Object> Object::SetElement(Isolate* isolate, Handle<Object> object,
1072 uint32_t index, Handle<Object> value, 1087 uint32_t index, Handle<Object> value,
(...skipping 10 matching lines...) Expand all
1083 DCHECK(!receiver->IsAccessCheckNeeded() || receiver->IsJSObject()); 1098 DCHECK(!receiver->IsAccessCheckNeeded() || receiver->IsJSObject());
1084 PrototypeIterator iter(isolate, receiver, 1099 PrototypeIterator iter(isolate, receiver,
1085 PrototypeIterator::START_AT_RECEIVER, 1100 PrototypeIterator::START_AT_RECEIVER,
1086 PrototypeIterator::END_AT_NON_HIDDEN); 1101 PrototypeIterator::END_AT_NON_HIDDEN);
1087 do { 1102 do {
1088 if (!iter.AdvanceFollowingProxies()) return MaybeHandle<Object>(); 1103 if (!iter.AdvanceFollowingProxies()) return MaybeHandle<Object>();
1089 } while (!iter.IsAtEnd()); 1104 } while (!iter.IsAtEnd());
1090 return PrototypeIterator::GetCurrent(iter); 1105 return PrototypeIterator::GetCurrent(iter);
1091 } 1106 }
1092 1107
1093 MaybeHandle<Object> Object::GetProperty(Isolate* isolate, Handle<Object> object, 1108 MaybeHandle<Object> JSReceiver::GetProperty(Isolate* isolate,
1094 const char* name) { 1109 Handle<JSReceiver> receiver,
1110 const char* name) {
1095 Handle<String> str = isolate->factory()->InternalizeUtf8String(name); 1111 Handle<String> str = isolate->factory()->InternalizeUtf8String(name);
1096 return GetProperty(object, str); 1112 return GetProperty(receiver, str);
1097 } 1113 }
1098 1114
1099 1115
1100 #define FIELD_ADDR(p, offset) \ 1116 #define FIELD_ADDR(p, offset) \
1101 (reinterpret_cast<byte*>(p) + offset - kHeapObjectTag) 1117 (reinterpret_cast<byte*>(p) + offset - kHeapObjectTag)
1102 1118
1103 #define FIELD_ADDR_CONST(p, offset) \ 1119 #define FIELD_ADDR_CONST(p, offset) \
1104 (reinterpret_cast<const byte*>(p) + offset - kHeapObjectTag) 1120 (reinterpret_cast<const byte*>(p) + offset - kHeapObjectTag)
1105 1121
1106 #define READ_FIELD(p, offset) \ 1122 #define READ_FIELD(p, offset) \
(...skipping 6650 matching lines...) Expand 10 before | Expand all | Expand 10 after
7757 #undef WRITE_INT64_FIELD 7773 #undef WRITE_INT64_FIELD
7758 #undef READ_BYTE_FIELD 7774 #undef READ_BYTE_FIELD
7759 #undef WRITE_BYTE_FIELD 7775 #undef WRITE_BYTE_FIELD
7760 #undef NOBARRIER_READ_BYTE_FIELD 7776 #undef NOBARRIER_READ_BYTE_FIELD
7761 #undef NOBARRIER_WRITE_BYTE_FIELD 7777 #undef NOBARRIER_WRITE_BYTE_FIELD
7762 7778
7763 } // namespace internal 7779 } // namespace internal
7764 } // namespace v8 7780 } // namespace v8
7765 7781
7766 #endif // V8_OBJECTS_INL_H_ 7782 #endif // V8_OBJECTS_INL_H_
OLDNEW
« no previous file with comments | « src/objects.cc ('k') | src/property-descriptor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698