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

Side by Side Diff: src/lookup.h

Issue 1770833002: Speed up indexed interceptor handling in 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/ic/ic.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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 interceptor_state_(InterceptorState::kUninitialized), 50 interceptor_state_(InterceptorState::kUninitialized),
51 property_details_(PropertyDetails::Empty()), 51 property_details_(PropertyDetails::Empty()),
52 isolate_(name->GetIsolate()), 52 isolate_(name->GetIsolate()),
53 name_(isolate_->factory()->InternalizeName(name)), 53 name_(isolate_->factory()->InternalizeName(name)),
54 receiver_(receiver),
55 initial_holder_(GetRoot(isolate_, receiver)),
54 // kMaxUInt32 isn't a valid index. 56 // kMaxUInt32 isn't a valid index.
55 index_(kMaxUInt32), 57 index_(kMaxUInt32),
56 receiver_(receiver), 58 number_(DescriptorArray::kNotFound) {
57 initial_holder_(GetRoot(isolate_, receiver)) {
58 #ifdef DEBUG 59 #ifdef DEBUG
59 uint32_t index; // Assert that the name is not an array index. 60 uint32_t index; // Assert that the name is not an array index.
60 DCHECK(!name->AsArrayIndex(&index)); 61 DCHECK(!name->AsArrayIndex(&index));
61 #endif // DEBUG 62 #endif // DEBUG
62 Start<false>(); 63 Start<false>();
63 } 64 }
64 65
65 LookupIterator(Handle<Object> receiver, Handle<Name> name, 66 LookupIterator(Handle<Object> receiver, Handle<Name> name,
66 Handle<JSReceiver> holder, 67 Handle<JSReceiver> holder,
67 Configuration configuration = DEFAULT) 68 Configuration configuration = DEFAULT)
68 : configuration_(ComputeConfiguration(configuration, name)), 69 : configuration_(ComputeConfiguration(configuration, name)),
69 interceptor_state_(InterceptorState::kUninitialized), 70 interceptor_state_(InterceptorState::kUninitialized),
70 property_details_(PropertyDetails::Empty()), 71 property_details_(PropertyDetails::Empty()),
71 isolate_(name->GetIsolate()), 72 isolate_(name->GetIsolate()),
72 name_(isolate_->factory()->InternalizeName(name)), 73 name_(isolate_->factory()->InternalizeName(name)),
74 receiver_(receiver),
75 initial_holder_(holder),
73 // kMaxUInt32 isn't a valid index. 76 // kMaxUInt32 isn't a valid index.
74 index_(kMaxUInt32), 77 index_(kMaxUInt32),
75 receiver_(receiver), 78 number_(DescriptorArray::kNotFound) {
76 initial_holder_(holder) {
77 #ifdef DEBUG 79 #ifdef DEBUG
78 uint32_t index; // Assert that the name is not an array index. 80 uint32_t index; // Assert that the name is not an array index.
79 DCHECK(!name->AsArrayIndex(&index)); 81 DCHECK(!name->AsArrayIndex(&index));
80 #endif // DEBUG 82 #endif // DEBUG
81 Start<false>(); 83 Start<false>();
82 } 84 }
83 85
84 LookupIterator(Isolate* isolate, Handle<Object> receiver, uint32_t index, 86 LookupIterator(Isolate* isolate, Handle<Object> receiver, uint32_t index,
85 Configuration configuration = DEFAULT) 87 Configuration configuration = DEFAULT)
86 : configuration_(configuration), 88 : configuration_(configuration),
87 interceptor_state_(InterceptorState::kUninitialized), 89 interceptor_state_(InterceptorState::kUninitialized),
88 property_details_(PropertyDetails::Empty()), 90 property_details_(PropertyDetails::Empty()),
89 isolate_(isolate), 91 isolate_(isolate),
90 name_(), 92 receiver_(receiver),
93 initial_holder_(GetRoot(isolate, receiver, index)),
91 index_(index), 94 index_(index),
92 receiver_(receiver), 95 number_(DescriptorArray::kNotFound) {
93 initial_holder_(GetRoot(isolate, receiver, index)) {
94 // kMaxUInt32 isn't a valid index. 96 // kMaxUInt32 isn't a valid index.
95 DCHECK_NE(kMaxUInt32, index_); 97 DCHECK_NE(kMaxUInt32, index_);
96 Start<true>(); 98 Start<true>();
97 } 99 }
98 100
99 LookupIterator(Isolate* isolate, Handle<Object> receiver, uint32_t index, 101 LookupIterator(Isolate* isolate, Handle<Object> receiver, uint32_t index,
100 Handle<JSReceiver> holder, 102 Handle<JSReceiver> holder,
101 Configuration configuration = DEFAULT) 103 Configuration configuration = DEFAULT)
102 : configuration_(configuration), 104 : configuration_(configuration),
103 interceptor_state_(InterceptorState::kUninitialized), 105 interceptor_state_(InterceptorState::kUninitialized),
104 property_details_(PropertyDetails::Empty()), 106 property_details_(PropertyDetails::Empty()),
105 isolate_(isolate), 107 isolate_(isolate),
106 name_(), 108 receiver_(receiver),
109 initial_holder_(holder),
107 index_(index), 110 index_(index),
108 receiver_(receiver), 111 number_(DescriptorArray::kNotFound) {
109 initial_holder_(holder) {
110 // kMaxUInt32 isn't a valid index. 112 // kMaxUInt32 isn't a valid index.
111 DCHECK_NE(kMaxUInt32, index_); 113 DCHECK_NE(kMaxUInt32, index_);
112 Start<true>(); 114 Start<true>();
113 } 115 }
114 116
115 static LookupIterator PropertyOrElement( 117 static LookupIterator PropertyOrElement(
116 Isolate* isolate, Handle<Object> receiver, Handle<Name> name, 118 Isolate* isolate, Handle<Object> receiver, Handle<Name> name,
117 Configuration configuration = DEFAULT) { 119 Configuration configuration = DEFAULT) {
118 uint32_t index; 120 uint32_t index;
119 if (name->AsArrayIndex(&index)) { 121 if (name->AsArrayIndex(&index)) {
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 return property_details().representation(); 248 return property_details().representation();
247 } 249 }
248 FieldIndex GetFieldIndex() const; 250 FieldIndex GetFieldIndex() const;
249 Handle<FieldType> GetFieldType() const; 251 Handle<FieldType> GetFieldType() const;
250 int GetAccessorIndex() const; 252 int GetAccessorIndex() const;
251 int GetConstantIndex() const; 253 int GetConstantIndex() const;
252 Handle<PropertyCell> GetPropertyCell() const; 254 Handle<PropertyCell> GetPropertyCell() const;
253 Handle<Object> GetAccessors() const; 255 Handle<Object> GetAccessors() const;
254 inline Handle<InterceptorInfo> GetInterceptor() const { 256 inline Handle<InterceptorInfo> GetInterceptor() const {
255 DCHECK_EQ(INTERCEPTOR, state_); 257 DCHECK_EQ(INTERCEPTOR, state_);
256 return handle(GetInterceptor(JSObject::cast(*holder_)), isolate_); 258 InterceptorInfo* result =
259 IsElement() ? GetInterceptor<true>(JSObject::cast(*holder_))
260 : GetInterceptor<false>(JSObject::cast(*holder_));
261 return handle(result, isolate_);
257 } 262 }
258 Handle<Object> GetDataValue() const; 263 Handle<Object> GetDataValue() const;
259 void WriteDataValue(Handle<Object> value); 264 void WriteDataValue(Handle<Object> value);
260 inline void UpdateProtector() { 265 inline void UpdateProtector() {
261 if (FLAG_harmony_species && !IsElement() && 266 if (FLAG_harmony_species && !IsElement() &&
262 (*name_ == heap()->constructor_string() || 267 (*name_ == heap()->constructor_string() ||
263 *name_ == heap()->species_symbol())) { 268 *name_ == heap()->species_symbol())) {
264 InternalUpdateProtector(); 269 InternalUpdateProtector();
265 } 270 }
266 } 271 }
(...skipping 28 matching lines...) Expand all
295 template <bool is_element> 300 template <bool is_element>
296 void RestartLookupForNonMaskingInterceptors() { 301 void RestartLookupForNonMaskingInterceptors() {
297 RestartInternal<is_element>(InterceptorState::kProcessNonMasking); 302 RestartInternal<is_element>(InterceptorState::kProcessNonMasking);
298 } 303 }
299 template <bool is_element> 304 template <bool is_element>
300 void RestartInternal(InterceptorState interceptor_state); 305 void RestartInternal(InterceptorState interceptor_state);
301 Handle<Object> FetchValue() const; 306 Handle<Object> FetchValue() const;
302 template <bool is_element> 307 template <bool is_element>
303 void ReloadPropertyInformation(); 308 void ReloadPropertyInformation();
304 309
305 inline bool SkipInterceptor(JSObject* holder); 310 template <bool is_element>
311 bool SkipInterceptor(JSObject* holder);
312 template <bool is_element>
306 inline InterceptorInfo* GetInterceptor(JSObject* holder) const { 313 inline InterceptorInfo* GetInterceptor(JSObject* holder) const {
307 if (IsElement()) return holder->GetIndexedInterceptor(); 314 return is_element ? holder->GetIndexedInterceptor()
308 return holder->GetNamedInterceptor(); 315 : holder->GetNamedInterceptor();
309 } 316 }
310 317
311 bool check_hidden() const { return (configuration_ & kHidden) != 0; } 318 bool check_hidden() const { return (configuration_ & kHidden) != 0; }
312 bool check_interceptor() const { 319 bool check_interceptor() const {
313 return (configuration_ & kInterceptor) != 0; 320 return (configuration_ & kInterceptor) != 0;
314 } 321 }
315 int descriptor_number() const { 322 int descriptor_number() const {
316 DCHECK(!IsElement()); 323 DCHECK(!IsElement());
317 DCHECK(has_property_); 324 DCHECK(has_property_);
318 DCHECK(holder_->HasFastProperties()); 325 DCHECK(holder_->HasFastProperties());
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 357
351 // If configuration_ becomes mutable, update 358 // If configuration_ becomes mutable, update
352 // HolderIsReceiverOrHiddenPrototype. 359 // HolderIsReceiverOrHiddenPrototype.
353 const Configuration configuration_; 360 const Configuration configuration_;
354 State state_; 361 State state_;
355 bool has_property_; 362 bool has_property_;
356 InterceptorState interceptor_state_; 363 InterceptorState interceptor_state_;
357 PropertyDetails property_details_; 364 PropertyDetails property_details_;
358 Isolate* const isolate_; 365 Isolate* const isolate_;
359 Handle<Name> name_; 366 Handle<Name> name_;
360 uint32_t index_;
361 Handle<Object> transition_; 367 Handle<Object> transition_;
362 const Handle<Object> receiver_; 368 const Handle<Object> receiver_;
363 Handle<JSReceiver> holder_; 369 Handle<JSReceiver> holder_;
364 const Handle<JSReceiver> initial_holder_; 370 const Handle<JSReceiver> initial_holder_;
371 uint32_t index_;
365 uint32_t number_; 372 uint32_t number_;
366 }; 373 };
367 374
368 375
369 } // namespace internal 376 } // namespace internal
370 } // namespace v8 377 } // namespace v8
371 378
372 #endif // V8_LOOKUP_H_ 379 #endif // V8_LOOKUP_H_
OLDNEW
« no previous file with comments | « src/ic/ic.cc ('k') | src/lookup.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698