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

Side by Side Diff: src/lookup.h

Issue 1702623002: [runtime] Don't cache the holder_map_ in the LookupIterator, it's faster. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase Created 4 years, 10 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 | « no previous file | 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 : configuration_(ComputeConfiguration(configuration, name)), 49 : configuration_(ComputeConfiguration(configuration, name)),
50 state_(NOT_FOUND), 50 state_(NOT_FOUND),
51 interceptor_state_(InterceptorState::kUninitialized), 51 interceptor_state_(InterceptorState::kUninitialized),
52 property_details_(PropertyDetails::Empty()), 52 property_details_(PropertyDetails::Empty()),
53 isolate_(name->GetIsolate()), 53 isolate_(name->GetIsolate()),
54 name_(Name::Flatten(name)), 54 name_(Name::Flatten(name)),
55 // kMaxUInt32 isn't a valid index. 55 // kMaxUInt32 isn't a valid index.
56 index_(kMaxUInt32), 56 index_(kMaxUInt32),
57 receiver_(receiver), 57 receiver_(receiver),
58 holder_(GetRoot(isolate_, receiver)), 58 holder_(GetRoot(isolate_, receiver)),
59 holder_map_(holder_->map(), isolate_),
60 initial_holder_(holder_), 59 initial_holder_(holder_),
61 number_(DescriptorArray::kNotFound) { 60 number_(DescriptorArray::kNotFound) {
62 #ifdef DEBUG 61 #ifdef DEBUG
63 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.
64 DCHECK(!name->AsArrayIndex(&index)); 63 DCHECK(!name->AsArrayIndex(&index));
65 #endif // DEBUG 64 #endif // DEBUG
66 Next(); 65 Next();
67 } 66 }
68 67
69 LookupIterator(Handle<Object> receiver, Handle<Name> name, 68 LookupIterator(Handle<Object> receiver, Handle<Name> name,
70 Handle<JSReceiver> holder, 69 Handle<JSReceiver> holder,
71 Configuration configuration = DEFAULT) 70 Configuration configuration = DEFAULT)
72 : configuration_(ComputeConfiguration(configuration, name)), 71 : configuration_(ComputeConfiguration(configuration, name)),
73 state_(NOT_FOUND), 72 state_(NOT_FOUND),
74 interceptor_state_(InterceptorState::kUninitialized), 73 interceptor_state_(InterceptorState::kUninitialized),
75 property_details_(PropertyDetails::Empty()), 74 property_details_(PropertyDetails::Empty()),
76 isolate_(name->GetIsolate()), 75 isolate_(name->GetIsolate()),
77 name_(Name::Flatten(name)), 76 name_(Name::Flatten(name)),
78 // kMaxUInt32 isn't a valid index. 77 // kMaxUInt32 isn't a valid index.
79 index_(kMaxUInt32), 78 index_(kMaxUInt32),
80 receiver_(receiver), 79 receiver_(receiver),
81 holder_(holder), 80 holder_(holder),
82 holder_map_(holder_->map(), isolate_),
83 initial_holder_(holder_), 81 initial_holder_(holder_),
84 number_(DescriptorArray::kNotFound) { 82 number_(DescriptorArray::kNotFound) {
85 #ifdef DEBUG 83 #ifdef DEBUG
86 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.
87 DCHECK(!name->AsArrayIndex(&index)); 85 DCHECK(!name->AsArrayIndex(&index));
88 #endif // DEBUG 86 #endif // DEBUG
89 Next(); 87 Next();
90 } 88 }
91 89
92 LookupIterator(Isolate* isolate, Handle<Object> receiver, uint32_t index, 90 LookupIterator(Isolate* isolate, Handle<Object> receiver, uint32_t index,
93 Configuration configuration = DEFAULT) 91 Configuration configuration = DEFAULT)
94 : configuration_(configuration), 92 : configuration_(configuration),
95 state_(NOT_FOUND), 93 state_(NOT_FOUND),
96 interceptor_state_(InterceptorState::kUninitialized), 94 interceptor_state_(InterceptorState::kUninitialized),
97 property_details_(PropertyDetails::Empty()), 95 property_details_(PropertyDetails::Empty()),
98 isolate_(isolate), 96 isolate_(isolate),
99 name_(), 97 name_(),
100 index_(index), 98 index_(index),
101 receiver_(receiver), 99 receiver_(receiver),
102 holder_(GetRoot(isolate, receiver, index)), 100 holder_(GetRoot(isolate, receiver, index)),
103 holder_map_(holder_->map(), isolate_),
104 initial_holder_(holder_), 101 initial_holder_(holder_),
105 number_(DescriptorArray::kNotFound) { 102 number_(DescriptorArray::kNotFound) {
106 // kMaxUInt32 isn't a valid index. 103 // kMaxUInt32 isn't a valid index.
107 DCHECK_NE(kMaxUInt32, index_); 104 DCHECK_NE(kMaxUInt32, index_);
108 Next(); 105 Next();
109 } 106 }
110 107
111 LookupIterator(Isolate* isolate, Handle<Object> receiver, uint32_t index, 108 LookupIterator(Isolate* isolate, Handle<Object> receiver, uint32_t index,
112 Handle<JSReceiver> holder, 109 Handle<JSReceiver> holder,
113 Configuration configuration = DEFAULT) 110 Configuration configuration = DEFAULT)
114 : configuration_(configuration), 111 : configuration_(configuration),
115 state_(NOT_FOUND), 112 state_(NOT_FOUND),
116 interceptor_state_(InterceptorState::kUninitialized), 113 interceptor_state_(InterceptorState::kUninitialized),
117 property_details_(PropertyDetails::Empty()), 114 property_details_(PropertyDetails::Empty()),
118 isolate_(isolate), 115 isolate_(isolate),
119 name_(), 116 name_(),
120 index_(index), 117 index_(index),
121 receiver_(receiver), 118 receiver_(receiver),
122 holder_(holder), 119 holder_(holder),
123 holder_map_(holder_->map(), isolate_),
124 initial_holder_(holder_), 120 initial_holder_(holder_),
125 number_(DescriptorArray::kNotFound) { 121 number_(DescriptorArray::kNotFound) {
126 // kMaxUInt32 isn't a valid index. 122 // kMaxUInt32 isn't a valid index.
127 DCHECK_NE(kMaxUInt32, index_); 123 DCHECK_NE(kMaxUInt32, index_);
128 Next(); 124 Next();
129 } 125 }
130 126
131 static LookupIterator PropertyOrElement( 127 static LookupIterator PropertyOrElement(
132 Isolate* isolate, Handle<Object> receiver, Handle<Name> name, 128 Isolate* isolate, Handle<Object> receiver, Handle<Name> name,
133 Configuration configuration = DEFAULT) { 129 Configuration configuration = DEFAULT) {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 void Next(); 178 void Next();
183 void NotFound() { 179 void NotFound() {
184 has_property_ = false; 180 has_property_ = false;
185 state_ = NOT_FOUND; 181 state_ = NOT_FOUND;
186 } 182 }
187 183
188 Heap* heap() const { return isolate_->heap(); } 184 Heap* heap() const { return isolate_->heap(); }
189 Factory* factory() const { return isolate_->factory(); } 185 Factory* factory() const { return isolate_->factory(); }
190 Handle<Object> GetReceiver() const { return receiver_; } 186 Handle<Object> GetReceiver() const { return receiver_; }
191 Handle<JSObject> GetStoreTarget() const; 187 Handle<JSObject> GetStoreTarget() const;
192 bool is_dictionary_holder() const { return holder_map_->is_dictionary_map(); } 188 bool is_dictionary_holder() const { return !holder_->HasFastProperties(); }
193 Handle<Map> transition_map() const { 189 Handle<Map> transition_map() const {
194 DCHECK_EQ(TRANSITION, state_); 190 DCHECK_EQ(TRANSITION, state_);
195 return Handle<Map>::cast(transition_); 191 return Handle<Map>::cast(transition_);
196 } 192 }
197 template <class T> 193 template <class T>
198 Handle<T> GetHolder() const { 194 Handle<T> GetHolder() const {
199 DCHECK(IsFound()); 195 DCHECK(IsFound());
200 return Handle<T>::cast(holder_); 196 return Handle<T>::cast(holder_);
201 } 197 }
202 198
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 int GetConstantIndex() const; 250 int GetConstantIndex() const;
255 Handle<PropertyCell> GetPropertyCell() const; 251 Handle<PropertyCell> GetPropertyCell() const;
256 Handle<Object> GetAccessors() const; 252 Handle<Object> GetAccessors() const;
257 inline Handle<InterceptorInfo> GetInterceptor() const { 253 inline Handle<InterceptorInfo> GetInterceptor() const {
258 DCHECK_EQ(INTERCEPTOR, state_); 254 DCHECK_EQ(INTERCEPTOR, state_);
259 return handle(GetInterceptor(JSObject::cast(*holder_)), isolate_); 255 return handle(GetInterceptor(JSObject::cast(*holder_)), isolate_);
260 } 256 }
261 Handle<Object> GetDataValue() const; 257 Handle<Object> GetDataValue() const;
262 void WriteDataValue(Handle<Object> value); 258 void WriteDataValue(Handle<Object> value);
263 void InternalizeName(); 259 void InternalizeName();
264 void ReloadHolderMap();
265 260
266 private: 261 private:
267 enum class InterceptorState { 262 enum class InterceptorState {
268 kUninitialized, 263 kUninitialized,
269 kSkipNonMasking, 264 kSkipNonMasking,
270 kProcessNonMasking 265 kProcessNonMasking
271 }; 266 };
272 267
273 Handle<Map> GetReceiverMap() const; 268 Handle<Map> GetReceiverMap() const;
274 269
(...skipping 13 matching lines...) Expand all
288 return holder->GetNamedInterceptor(); 283 return holder->GetNamedInterceptor();
289 } 284 }
290 285
291 bool check_hidden() const { return (configuration_ & kHidden) != 0; } 286 bool check_hidden() const { return (configuration_ & kHidden) != 0; }
292 bool check_interceptor() const { 287 bool check_interceptor() const {
293 return (configuration_ & kInterceptor) != 0; 288 return (configuration_ & kInterceptor) != 0;
294 } 289 }
295 int descriptor_number() const { 290 int descriptor_number() const {
296 DCHECK(!IsElement()); 291 DCHECK(!IsElement());
297 DCHECK(has_property_); 292 DCHECK(has_property_);
298 DCHECK(!holder_map_->is_dictionary_map()); 293 DCHECK(holder_->HasFastProperties());
299 return number_; 294 return number_;
300 } 295 }
301 int dictionary_entry() const { 296 int dictionary_entry() const {
302 DCHECK(!IsElement()); 297 DCHECK(!IsElement());
303 DCHECK(has_property_); 298 DCHECK(has_property_);
304 DCHECK(holder_map_->is_dictionary_map()); 299 DCHECK(!holder_->HasFastProperties());
305 return number_; 300 return number_;
306 } 301 }
307 302
308 static Configuration ComputeConfiguration( 303 static Configuration ComputeConfiguration(
309 Configuration configuration, Handle<Name> name) { 304 Configuration configuration, Handle<Name> name) {
310 if (name->IsPrivate()) { 305 if (name->IsPrivate()) {
311 return static_cast<Configuration>(configuration & 306 return static_cast<Configuration>(configuration &
312 HIDDEN_SKIP_INTERCEPTOR); 307 HIDDEN_SKIP_INTERCEPTOR);
313 } else { 308 } else {
314 return configuration; 309 return configuration;
(...skipping 17 matching lines...) Expand all
332 State state_; 327 State state_;
333 bool has_property_; 328 bool has_property_;
334 InterceptorState interceptor_state_; 329 InterceptorState interceptor_state_;
335 PropertyDetails property_details_; 330 PropertyDetails property_details_;
336 Isolate* const isolate_; 331 Isolate* const isolate_;
337 Handle<Name> name_; 332 Handle<Name> name_;
338 uint32_t index_; 333 uint32_t index_;
339 Handle<Object> transition_; 334 Handle<Object> transition_;
340 const Handle<Object> receiver_; 335 const Handle<Object> receiver_;
341 Handle<JSReceiver> holder_; 336 Handle<JSReceiver> holder_;
342 Handle<Map> holder_map_;
343 const Handle<JSReceiver> initial_holder_; 337 const Handle<JSReceiver> initial_holder_;
344 uint32_t number_; 338 uint32_t number_;
345 }; 339 };
346 340
347 341
348 } // namespace internal 342 } // namespace internal
349 } // namespace v8 343 } // namespace v8
350 344
351 #endif // V8_LOOKUP_H_ 345 #endif // V8_LOOKUP_H_
OLDNEW
« no previous file with comments | « no previous file | src/lookup.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698