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

Side by Side Diff: src/lookup.h

Issue 1651913005: [runtime] Fix integer indexed property handling (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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 | « src/builtins.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 30 matching lines...) Expand all
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 state_(NOT_FOUND),
51 exotic_index_state_(ExoticIndexState::kUninitialized),
52 interceptor_state_(InterceptorState::kUninitialized), 51 interceptor_state_(InterceptorState::kUninitialized),
53 property_details_(PropertyDetails::Empty()), 52 property_details_(PropertyDetails::Empty()),
54 isolate_(name->GetIsolate()), 53 isolate_(name->GetIsolate()),
55 name_(Name::Flatten(name)), 54 name_(Name::Flatten(name)),
56 // kMaxUInt32 isn't a valid index. 55 // kMaxUInt32 isn't a valid index.
57 index_(kMaxUInt32), 56 index_(kMaxUInt32),
58 receiver_(receiver), 57 receiver_(receiver),
59 holder_(GetRoot(isolate_, receiver)), 58 holder_(GetRoot(isolate_, receiver)),
60 holder_map_(holder_->map(), isolate_), 59 holder_map_(holder_->map(), isolate_),
61 initial_holder_(holder_), 60 initial_holder_(holder_),
62 number_(DescriptorArray::kNotFound) { 61 number_(DescriptorArray::kNotFound) {
63 #ifdef DEBUG 62 #ifdef DEBUG
64 uint32_t index; // Assert that the name is not an array index. 63 uint32_t index; // Assert that the name is not an array index.
65 DCHECK(!name->AsArrayIndex(&index)); 64 DCHECK(!name->AsArrayIndex(&index));
66 #endif // DEBUG 65 #endif // DEBUG
67 Next(); 66 Next();
68 } 67 }
69 68
70 LookupIterator(Handle<Object> receiver, Handle<Name> name, 69 LookupIterator(Handle<Object> receiver, Handle<Name> name,
71 Handle<JSReceiver> holder, 70 Handle<JSReceiver> holder,
72 Configuration configuration = DEFAULT) 71 Configuration configuration = DEFAULT)
73 : configuration_(ComputeConfiguration(configuration, name)), 72 : configuration_(ComputeConfiguration(configuration, name)),
74 state_(NOT_FOUND), 73 state_(NOT_FOUND),
75 exotic_index_state_(ExoticIndexState::kUninitialized),
76 interceptor_state_(InterceptorState::kUninitialized), 74 interceptor_state_(InterceptorState::kUninitialized),
77 property_details_(PropertyDetails::Empty()), 75 property_details_(PropertyDetails::Empty()),
78 isolate_(name->GetIsolate()), 76 isolate_(name->GetIsolate()),
79 name_(Name::Flatten(name)), 77 name_(Name::Flatten(name)),
80 // kMaxUInt32 isn't a valid index. 78 // kMaxUInt32 isn't a valid index.
81 index_(kMaxUInt32), 79 index_(kMaxUInt32),
82 receiver_(receiver), 80 receiver_(receiver),
83 holder_(holder), 81 holder_(holder),
84 holder_map_(holder_->map(), isolate_), 82 holder_map_(holder_->map(), isolate_),
85 initial_holder_(holder_), 83 initial_holder_(holder_),
86 number_(DescriptorArray::kNotFound) { 84 number_(DescriptorArray::kNotFound) {
87 #ifdef DEBUG 85 #ifdef DEBUG
88 uint32_t index; // Assert that the name is not an array index. 86 uint32_t index; // Assert that the name is not an array index.
89 DCHECK(!name->AsArrayIndex(&index)); 87 DCHECK(!name->AsArrayIndex(&index));
90 #endif // DEBUG 88 #endif // DEBUG
91 Next(); 89 Next();
92 } 90 }
93 91
94 LookupIterator(Isolate* isolate, Handle<Object> receiver, uint32_t index, 92 LookupIterator(Isolate* isolate, Handle<Object> receiver, uint32_t index,
95 Configuration configuration = DEFAULT) 93 Configuration configuration = DEFAULT)
96 : configuration_(configuration), 94 : configuration_(configuration),
97 state_(NOT_FOUND), 95 state_(NOT_FOUND),
98 exotic_index_state_(ExoticIndexState::kUninitialized),
99 interceptor_state_(InterceptorState::kUninitialized), 96 interceptor_state_(InterceptorState::kUninitialized),
100 property_details_(PropertyDetails::Empty()), 97 property_details_(PropertyDetails::Empty()),
101 isolate_(isolate), 98 isolate_(isolate),
102 name_(), 99 name_(),
103 index_(index), 100 index_(index),
104 receiver_(receiver), 101 receiver_(receiver),
105 holder_(GetRoot(isolate, receiver, index)), 102 holder_(GetRoot(isolate, receiver, index)),
106 holder_map_(holder_->map(), isolate_), 103 holder_map_(holder_->map(), isolate_),
107 initial_holder_(holder_), 104 initial_holder_(holder_),
108 number_(DescriptorArray::kNotFound) { 105 number_(DescriptorArray::kNotFound) {
109 // kMaxUInt32 isn't a valid index. 106 // kMaxUInt32 isn't a valid index.
110 DCHECK_NE(kMaxUInt32, index_); 107 DCHECK_NE(kMaxUInt32, index_);
111 Next(); 108 Next();
112 } 109 }
113 110
114 LookupIterator(Isolate* isolate, Handle<Object> receiver, uint32_t index, 111 LookupIterator(Isolate* isolate, Handle<Object> receiver, uint32_t index,
115 Handle<JSReceiver> holder, 112 Handle<JSReceiver> holder,
116 Configuration configuration = DEFAULT) 113 Configuration configuration = DEFAULT)
117 : configuration_(configuration), 114 : configuration_(configuration),
118 state_(NOT_FOUND), 115 state_(NOT_FOUND),
119 exotic_index_state_(ExoticIndexState::kUninitialized),
120 interceptor_state_(InterceptorState::kUninitialized), 116 interceptor_state_(InterceptorState::kUninitialized),
121 property_details_(PropertyDetails::Empty()), 117 property_details_(PropertyDetails::Empty()),
122 isolate_(isolate), 118 isolate_(isolate),
123 name_(), 119 name_(),
124 index_(index), 120 index_(index),
125 receiver_(receiver), 121 receiver_(receiver),
126 holder_(holder), 122 holder_(holder),
127 holder_map_(holder_->map(), isolate_), 123 holder_map_(holder_->map(), isolate_),
128 initial_holder_(holder_), 124 initial_holder_(holder_),
129 number_(DescriptorArray::kNotFound) { 125 number_(DescriptorArray::kNotFound) {
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 inline State LookupInHolder(Map* map, JSReceiver* holder); 269 inline State LookupInHolder(Map* map, JSReceiver* holder);
274 void RestartLookupForNonMaskingInterceptors() { 270 void RestartLookupForNonMaskingInterceptors() {
275 RestartInternal(InterceptorState::kProcessNonMasking); 271 RestartInternal(InterceptorState::kProcessNonMasking);
276 } 272 }
277 void RestartInternal(InterceptorState interceptor_state); 273 void RestartInternal(InterceptorState interceptor_state);
278 State LookupNonMaskingInterceptorInHolder(Map* map, JSReceiver* holder); 274 State LookupNonMaskingInterceptorInHolder(Map* map, JSReceiver* holder);
279 Handle<Object> FetchValue() const; 275 Handle<Object> FetchValue() const;
280 void ReloadPropertyInformation(); 276 void ReloadPropertyInformation();
281 inline bool SkipInterceptor(JSObject* holder); 277 inline bool SkipInterceptor(JSObject* holder);
282 bool HasInterceptor(Map* map) const; 278 bool HasInterceptor(Map* map) const;
283 bool InternalHolderIsReceiverOrHiddenPrototype() const;
284 inline InterceptorInfo* GetInterceptor(JSObject* holder) const { 279 inline InterceptorInfo* GetInterceptor(JSObject* holder) const {
285 if (IsElement()) return holder->GetIndexedInterceptor(); 280 if (IsElement()) return holder->GetIndexedInterceptor();
286 return holder->GetNamedInterceptor(); 281 return holder->GetNamedInterceptor();
287 } 282 }
288 283
289 bool check_hidden() const { return (configuration_ & kHidden) != 0; } 284 bool check_hidden() const { return (configuration_ & kHidden) != 0; }
290 bool check_interceptor() const { 285 bool check_interceptor() const {
291 return (configuration_ & kInterceptor) != 0; 286 return (configuration_ & kInterceptor) != 0;
292 } 287 }
293 int descriptor_number() const { 288 int descriptor_number() const {
(...skipping 19 matching lines...) Expand all
313 308
314 static Handle<JSReceiver> GetRootForNonJSReceiver( 309 static Handle<JSReceiver> GetRootForNonJSReceiver(
315 Isolate* isolate, Handle<Object> receiver, uint32_t index = kMaxUInt32); 310 Isolate* isolate, Handle<Object> receiver, uint32_t index = kMaxUInt32);
316 inline static Handle<JSReceiver> GetRoot(Isolate* isolate, 311 inline static Handle<JSReceiver> GetRoot(Isolate* isolate,
317 Handle<Object> receiver, 312 Handle<Object> receiver,
318 uint32_t index = kMaxUInt32) { 313 uint32_t index = kMaxUInt32) {
319 if (receiver->IsJSReceiver()) return Handle<JSReceiver>::cast(receiver); 314 if (receiver->IsJSReceiver()) return Handle<JSReceiver>::cast(receiver);
320 return GetRootForNonJSReceiver(isolate, receiver, index); 315 return GetRootForNonJSReceiver(isolate, receiver, index);
321 } 316 }
322 317
323 enum class ExoticIndexState { kUninitialized, kNotExotic, kExotic };
324 inline bool IsIntegerIndexedExotic(JSReceiver* holder); 318 inline bool IsIntegerIndexedExotic(JSReceiver* holder);
325 319
326 // If configuration_ becomes mutable, update 320 // If configuration_ becomes mutable, update
327 // HolderIsReceiverOrHiddenPrototype. 321 // HolderIsReceiverOrHiddenPrototype.
328 const Configuration configuration_; 322 const Configuration configuration_;
329 State state_; 323 State state_;
330 bool has_property_; 324 bool has_property_;
331 ExoticIndexState exotic_index_state_;
332 InterceptorState interceptor_state_; 325 InterceptorState interceptor_state_;
333 PropertyDetails property_details_; 326 PropertyDetails property_details_;
334 Isolate* const isolate_; 327 Isolate* const isolate_;
335 Handle<Name> name_; 328 Handle<Name> name_;
336 uint32_t index_; 329 uint32_t index_;
337 Handle<Object> transition_; 330 Handle<Object> transition_;
338 const Handle<Object> receiver_; 331 const Handle<Object> receiver_;
339 Handle<JSReceiver> holder_; 332 Handle<JSReceiver> holder_;
340 Handle<Map> holder_map_; 333 Handle<Map> holder_map_;
341 const Handle<JSReceiver> initial_holder_; 334 const Handle<JSReceiver> initial_holder_;
342 uint32_t number_; 335 uint32_t number_;
343 }; 336 };
344 337
345 338
346 } // namespace internal 339 } // namespace internal
347 } // namespace v8 340 } // namespace v8
348 341
349 #endif // V8_LOOKUP_H_ 342 #endif // V8_LOOKUP_H_
OLDNEW
« no previous file with comments | « src/builtins.cc ('k') | src/lookup.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698