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

Side by Side Diff: src/lookup.h

Issue 1761593003: Revert "Speed up the LookupIterator" (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/heap/objects-visiting.cc ('k') | src/lookup.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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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 #ifndef V8_LOOKUP_H_ 5 #ifndef V8_LOOKUP_H_
6 #define V8_LOOKUP_H_ 6 #define V8_LOOKUP_H_
7 7
8 #include "src/factory.h" 8 #include "src/factory.h"
9 #include "src/isolate.h" 9 #include "src/isolate.h"
10 #include "src/objects.h" 10 #include "src/objects.h"
(...skipping 29 matching lines...) Expand all
40 DATA, 40 DATA,
41 TRANSITION, 41 TRANSITION,
42 // Set state_ to BEFORE_PROPERTY to ensure that the next lookup will be a 42 // Set state_ to BEFORE_PROPERTY to ensure that the next lookup will be a
43 // PROPERTY lookup. 43 // PROPERTY lookup.
44 BEFORE_PROPERTY = INTERCEPTOR 44 BEFORE_PROPERTY = INTERCEPTOR
45 }; 45 };
46 46
47 LookupIterator(Handle<Object> receiver, Handle<Name> name, 47 LookupIterator(Handle<Object> receiver, Handle<Name> name,
48 Configuration configuration = DEFAULT) 48 Configuration configuration = DEFAULT)
49 : configuration_(ComputeConfiguration(configuration, name)), 49 : configuration_(ComputeConfiguration(configuration, name)),
50 state_(NOT_FOUND),
50 interceptor_state_(InterceptorState::kUninitialized), 51 interceptor_state_(InterceptorState::kUninitialized),
51 property_details_(PropertyDetails::Empty()), 52 property_details_(PropertyDetails::Empty()),
52 isolate_(name->GetIsolate()), 53 isolate_(name->GetIsolate()),
53 name_(isolate_->factory()->InternalizeName(name)), 54 name_(isolate_->factory()->InternalizeName(name)),
54 // kMaxUInt32 isn't a valid index. 55 // kMaxUInt32 isn't a valid index.
55 index_(kMaxUInt32), 56 index_(kMaxUInt32),
56 receiver_(receiver), 57 receiver_(receiver),
57 initial_holder_(GetRoot(isolate_, receiver)) { 58 holder_(GetRoot(isolate_, receiver)),
59 initial_holder_(holder_),
60 number_(DescriptorArray::kNotFound) {
58 #ifdef DEBUG 61 #ifdef DEBUG
59 uint32_t index; // Assert that the name is not an array index. 62 uint32_t index; // Assert that the name is not an array index.
60 DCHECK(!name->AsArrayIndex(&index)); 63 DCHECK(!name->AsArrayIndex(&index));
61 #endif // DEBUG 64 #endif // DEBUG
62 Start<false>(); 65 Next();
63 } 66 }
64 67
65 LookupIterator(Handle<Object> receiver, Handle<Name> name, 68 LookupIterator(Handle<Object> receiver, Handle<Name> name,
66 Handle<JSReceiver> holder, 69 Handle<JSReceiver> holder,
67 Configuration configuration = DEFAULT) 70 Configuration configuration = DEFAULT)
68 : configuration_(ComputeConfiguration(configuration, name)), 71 : configuration_(ComputeConfiguration(configuration, name)),
72 state_(NOT_FOUND),
69 interceptor_state_(InterceptorState::kUninitialized), 73 interceptor_state_(InterceptorState::kUninitialized),
70 property_details_(PropertyDetails::Empty()), 74 property_details_(PropertyDetails::Empty()),
71 isolate_(name->GetIsolate()), 75 isolate_(name->GetIsolate()),
72 name_(isolate_->factory()->InternalizeName(name)), 76 name_(isolate_->factory()->InternalizeName(name)),
73 // kMaxUInt32 isn't a valid index. 77 // kMaxUInt32 isn't a valid index.
74 index_(kMaxUInt32), 78 index_(kMaxUInt32),
75 receiver_(receiver), 79 receiver_(receiver),
76 initial_holder_(holder) { 80 holder_(holder),
81 initial_holder_(holder_),
82 number_(DescriptorArray::kNotFound) {
77 #ifdef DEBUG 83 #ifdef DEBUG
78 uint32_t index; // Assert that the name is not an array index. 84 uint32_t index; // Assert that the name is not an array index.
79 DCHECK(!name->AsArrayIndex(&index)); 85 DCHECK(!name->AsArrayIndex(&index));
80 #endif // DEBUG 86 #endif // DEBUG
81 Start<false>(); 87 Next();
82 } 88 }
83 89
84 LookupIterator(Isolate* isolate, Handle<Object> receiver, uint32_t index, 90 LookupIterator(Isolate* isolate, Handle<Object> receiver, uint32_t index,
85 Configuration configuration = DEFAULT) 91 Configuration configuration = DEFAULT)
86 : configuration_(configuration), 92 : configuration_(configuration),
93 state_(NOT_FOUND),
87 interceptor_state_(InterceptorState::kUninitialized), 94 interceptor_state_(InterceptorState::kUninitialized),
88 property_details_(PropertyDetails::Empty()), 95 property_details_(PropertyDetails::Empty()),
89 isolate_(isolate), 96 isolate_(isolate),
90 name_(), 97 name_(),
91 index_(index), 98 index_(index),
92 receiver_(receiver), 99 receiver_(receiver),
93 initial_holder_(GetRoot(isolate, receiver, index)) { 100 holder_(GetRoot(isolate, receiver, index)),
101 initial_holder_(holder_),
102 number_(DescriptorArray::kNotFound) {
94 // kMaxUInt32 isn't a valid index. 103 // kMaxUInt32 isn't a valid index.
95 DCHECK_NE(kMaxUInt32, index_); 104 DCHECK_NE(kMaxUInt32, index_);
96 Start<true>(); 105 Next();
97 } 106 }
98 107
99 LookupIterator(Isolate* isolate, Handle<Object> receiver, uint32_t index, 108 LookupIterator(Isolate* isolate, Handle<Object> receiver, uint32_t index,
100 Handle<JSReceiver> holder, 109 Handle<JSReceiver> holder,
101 Configuration configuration = DEFAULT) 110 Configuration configuration = DEFAULT)
102 : configuration_(configuration), 111 : configuration_(configuration),
112 state_(NOT_FOUND),
103 interceptor_state_(InterceptorState::kUninitialized), 113 interceptor_state_(InterceptorState::kUninitialized),
104 property_details_(PropertyDetails::Empty()), 114 property_details_(PropertyDetails::Empty()),
105 isolate_(isolate), 115 isolate_(isolate),
106 name_(), 116 name_(),
107 index_(index), 117 index_(index),
108 receiver_(receiver), 118 receiver_(receiver),
109 initial_holder_(holder) { 119 holder_(holder),
120 initial_holder_(holder_),
121 number_(DescriptorArray::kNotFound) {
110 // kMaxUInt32 isn't a valid index. 122 // kMaxUInt32 isn't a valid index.
111 DCHECK_NE(kMaxUInt32, index_); 123 DCHECK_NE(kMaxUInt32, index_);
112 Start<true>(); 124 Next();
113 } 125 }
114 126
115 static LookupIterator PropertyOrElement( 127 static LookupIterator PropertyOrElement(
116 Isolate* isolate, Handle<Object> receiver, Handle<Name> name, 128 Isolate* isolate, Handle<Object> receiver, Handle<Name> name,
117 Configuration configuration = DEFAULT) { 129 Configuration configuration = DEFAULT) {
118 uint32_t index; 130 uint32_t index;
119 if (name->AsArrayIndex(&index)) { 131 if (name->AsArrayIndex(&index)) {
120 LookupIterator it = 132 LookupIterator it =
121 LookupIterator(isolate, receiver, index, configuration); 133 LookupIterator(isolate, receiver, index, configuration);
122 it.name_ = name; 134 it.name_ = name;
(...skipping 12 matching lines...) Expand all
135 it.name_ = name; 147 it.name_ = name;
136 return it; 148 return it;
137 } 149 }
138 return LookupIterator(receiver, name, holder, configuration); 150 return LookupIterator(receiver, name, holder, configuration);
139 } 151 }
140 152
141 static LookupIterator PropertyOrElement( 153 static LookupIterator PropertyOrElement(
142 Isolate* isolate, Handle<Object> receiver, Handle<Object> key, 154 Isolate* isolate, Handle<Object> receiver, Handle<Object> key,
143 bool* success, Configuration configuration = DEFAULT); 155 bool* success, Configuration configuration = DEFAULT);
144 156
145 void Restart() { 157 void Restart() { RestartInternal(InterceptorState::kUninitialized); }
146 InterceptorState state = InterceptorState::kUninitialized;
147 IsElement() ? RestartInternal<true>(state) : RestartInternal<false>(state);
148 }
149 158
150 Isolate* isolate() const { return isolate_; } 159 Isolate* isolate() const { return isolate_; }
151 State state() const { return state_; } 160 State state() const { return state_; }
152 161
153 Handle<Name> name() const { 162 Handle<Name> name() const {
154 DCHECK(!IsElement()); 163 DCHECK(!IsElement());
155 return name_; 164 return name_;
156 } 165 }
157 Handle<Name> GetName() { 166 Handle<Name> GetName() {
158 if (name_.is_null()) { 167 if (name_.is_null()) {
159 DCHECK(IsElement()); 168 DCHECK(IsElement());
160 name_ = factory()->Uint32ToString(index_); 169 name_ = factory()->Uint32ToString(index_);
161 } 170 }
162 return name_; 171 return name_;
163 } 172 }
164 uint32_t index() const { return index_; } 173 uint32_t index() const { return index_; }
165 174
166 bool IsElement() const { return index_ != kMaxUInt32; } 175 bool IsElement() const { return index_ != kMaxUInt32; }
167 176
168 bool IsFound() const { return state_ != NOT_FOUND; } 177 bool IsFound() const { return state_ != NOT_FOUND; }
169 void Next(); 178 void Next();
170 void NotFound() { 179 void NotFound() {
171 has_property_ = false; 180 has_property_ = false;
172 state_ = NOT_FOUND; 181 state_ = NOT_FOUND;
173 } 182 }
174 183
175 Heap* heap() const { return isolate_->heap(); } 184 Heap* heap() const { return isolate_->heap(); }
176 Factory* factory() const { return isolate_->factory(); } 185 Factory* factory() const { return isolate_->factory(); }
177 Handle<Object> GetReceiver() const { return receiver_; } 186 Handle<Object> GetReceiver() const { return receiver_; }
178 187 Handle<JSObject> GetStoreTarget() const;
179 Handle<JSObject> GetStoreTarget() const {
180 if (receiver_->IsJSGlobalProxy()) {
181 Map* map = JSGlobalProxy::cast(*receiver_)->map();
182 if (map->has_hidden_prototype()) {
183 return handle(JSGlobalObject::cast(map->prototype()), isolate_);
184 }
185 }
186 return Handle<JSObject>::cast(receiver_);
187 }
188
189 bool is_dictionary_holder() const { return !holder_->HasFastProperties(); } 188 bool is_dictionary_holder() const { return !holder_->HasFastProperties(); }
190 Handle<Map> transition_map() const { 189 Handle<Map> transition_map() const {
191 DCHECK_EQ(TRANSITION, state_); 190 DCHECK_EQ(TRANSITION, state_);
192 return Handle<Map>::cast(transition_); 191 return Handle<Map>::cast(transition_);
193 } 192 }
194 template <class T> 193 template <class T>
195 Handle<T> GetHolder() const { 194 Handle<T> GetHolder() const {
196 DCHECK(IsFound()); 195 DCHECK(IsFound());
197 return Handle<T>::cast(holder_); 196 return Handle<T>::cast(holder_);
198 } 197 }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 int GetAccessorIndex() const; 249 int GetAccessorIndex() const;
251 int GetConstantIndex() const; 250 int GetConstantIndex() const;
252 Handle<PropertyCell> GetPropertyCell() const; 251 Handle<PropertyCell> GetPropertyCell() const;
253 Handle<Object> GetAccessors() const; 252 Handle<Object> GetAccessors() const;
254 inline Handle<InterceptorInfo> GetInterceptor() const { 253 inline Handle<InterceptorInfo> GetInterceptor() const {
255 DCHECK_EQ(INTERCEPTOR, state_); 254 DCHECK_EQ(INTERCEPTOR, state_);
256 return handle(GetInterceptor(JSObject::cast(*holder_)), isolate_); 255 return handle(GetInterceptor(JSObject::cast(*holder_)), isolate_);
257 } 256 }
258 Handle<Object> GetDataValue() const; 257 Handle<Object> GetDataValue() const;
259 void WriteDataValue(Handle<Object> value); 258 void WriteDataValue(Handle<Object> value);
260 inline void UpdateProtector() { 259 void UpdateProtector();
261 if (FLAG_harmony_species && !IsElement() &&
262 (*name_ == heap()->constructor_string() ||
263 *name_ == heap()->species_symbol())) {
264 InternalUpdateProtector();
265 }
266 }
267 260
268 private: 261 private:
269 void InternalUpdateProtector();
270
271 enum class InterceptorState { 262 enum class InterceptorState {
272 kUninitialized, 263 kUninitialized,
273 kSkipNonMasking, 264 kSkipNonMasking,
274 kProcessNonMasking 265 kProcessNonMasking
275 }; 266 };
276 267
277 Handle<Map> GetReceiverMap() const; 268 Handle<Map> GetReceiverMap() const;
278 269
279 MUST_USE_RESULT inline JSReceiver* NextHolder(Map* map); 270 MUST_USE_RESULT inline JSReceiver* NextHolder(Map* map);
280 271 inline State LookupInHolder(Map* map, JSReceiver* holder);
281 template <bool is_element> 272 void RestartLookupForNonMaskingInterceptors() {
282 void Start(); 273 RestartInternal(InterceptorState::kProcessNonMasking);
283 template <bool is_element>
284 void NextInternal(Map* map, JSReceiver* holder);
285 template <bool is_element>
286 inline State LookupInHolder(Map* map, JSReceiver* holder) {
287 return map->instance_type() <= LAST_SPECIAL_RECEIVER_TYPE
288 ? LookupInSpecialHolder<is_element>(map, holder)
289 : LookupInRegularHolder<is_element>(map, holder);
290 } 274 }
291 template <bool is_element>
292 State LookupInRegularHolder(Map* map, JSReceiver* holder);
293 template <bool is_element>
294 State LookupInSpecialHolder(Map* map, JSReceiver* holder);
295 template <bool is_element>
296 void RestartLookupForNonMaskingInterceptors() {
297 RestartInternal<is_element>(InterceptorState::kProcessNonMasking);
298 }
299 template <bool is_element>
300 void RestartInternal(InterceptorState interceptor_state); 275 void RestartInternal(InterceptorState interceptor_state);
276 State LookupNonMaskingInterceptorInHolder(Map* map, JSReceiver* holder);
301 Handle<Object> FetchValue() const; 277 Handle<Object> FetchValue() const;
302 template <bool is_element>
303 void ReloadPropertyInformation(); 278 void ReloadPropertyInformation();
304
305 inline bool SkipInterceptor(JSObject* holder); 279 inline bool SkipInterceptor(JSObject* holder);
280 bool HasInterceptor(Map* map) const;
306 inline InterceptorInfo* GetInterceptor(JSObject* holder) const { 281 inline InterceptorInfo* GetInterceptor(JSObject* holder) const {
307 if (IsElement()) return holder->GetIndexedInterceptor(); 282 if (IsElement()) return holder->GetIndexedInterceptor();
308 return holder->GetNamedInterceptor(); 283 return holder->GetNamedInterceptor();
309 } 284 }
310 285
311 bool check_hidden() const { return (configuration_ & kHidden) != 0; } 286 bool check_hidden() const { return (configuration_ & kHidden) != 0; }
312 bool check_interceptor() const { 287 bool check_interceptor() const {
313 return (configuration_ & kInterceptor) != 0; 288 return (configuration_ & kInterceptor) != 0;
314 } 289 }
315 int descriptor_number() const { 290 int descriptor_number() const {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 Handle<JSReceiver> holder_; 338 Handle<JSReceiver> holder_;
364 const Handle<JSReceiver> initial_holder_; 339 const Handle<JSReceiver> initial_holder_;
365 uint32_t number_; 340 uint32_t number_;
366 }; 341 };
367 342
368 343
369 } // namespace internal 344 } // namespace internal
370 } // namespace v8 345 } // namespace v8
371 346
372 #endif // V8_LOOKUP_H_ 347 #endif // V8_LOOKUP_H_
OLDNEW
« no previous file with comments | « src/heap/objects-visiting.cc ('k') | src/lookup.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698