OLD | NEW |
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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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), | 51 exotic_index_state_(ExoticIndexState::kUninitialized), |
52 interceptor_state_(InterceptorState::kUninitialized), | 52 interceptor_state_(InterceptorState::kUninitialized), |
53 property_details_(PropertyDetails::Empty()), | 53 property_details_(PropertyDetails::Empty()), |
54 isolate_(name->GetIsolate()), | 54 isolate_(name->GetIsolate()), |
55 name_(name), | 55 name_(Name::Flatten(name)), |
56 // kMaxUInt32 isn't a valid index. | 56 // kMaxUInt32 isn't a valid index. |
57 index_(kMaxUInt32), | 57 index_(kMaxUInt32), |
58 receiver_(receiver), | 58 receiver_(receiver), |
59 holder_(GetRoot(receiver_, isolate_)), | 59 holder_(GetRoot(receiver_, isolate_)), |
60 holder_map_(holder_->map(), isolate_), | 60 holder_map_(holder_->map(), isolate_), |
61 initial_holder_(holder_), | 61 initial_holder_(holder_), |
62 number_(DescriptorArray::kNotFound) { | 62 number_(DescriptorArray::kNotFound) { |
63 #ifdef DEBUG | 63 #ifdef DEBUG |
64 uint32_t index; // Assert that the name is not an array index. | 64 uint32_t index; // Assert that the name is not an array index. |
65 DCHECK(!name->AsArrayIndex(&index)); | 65 DCHECK(!name->AsArrayIndex(&index)); |
66 #endif // DEBUG | 66 #endif // DEBUG |
67 Next(); | 67 Next(); |
68 } | 68 } |
69 | 69 |
70 LookupIterator(Handle<Object> receiver, Handle<Name> name, | 70 LookupIterator(Handle<Object> receiver, Handle<Name> name, |
71 Handle<JSReceiver> holder, | 71 Handle<JSReceiver> holder, |
72 Configuration configuration = DEFAULT) | 72 Configuration configuration = DEFAULT) |
73 : configuration_(ComputeConfiguration(configuration, name)), | 73 : configuration_(ComputeConfiguration(configuration, name)), |
74 state_(NOT_FOUND), | 74 state_(NOT_FOUND), |
75 exotic_index_state_(ExoticIndexState::kUninitialized), | 75 exotic_index_state_(ExoticIndexState::kUninitialized), |
76 interceptor_state_(InterceptorState::kUninitialized), | 76 interceptor_state_(InterceptorState::kUninitialized), |
77 property_details_(PropertyDetails::Empty()), | 77 property_details_(PropertyDetails::Empty()), |
78 isolate_(name->GetIsolate()), | 78 isolate_(name->GetIsolate()), |
79 name_(name), | 79 name_(Name::Flatten(name)), |
80 // kMaxUInt32 isn't a valid index. | 80 // kMaxUInt32 isn't a valid index. |
81 index_(kMaxUInt32), | 81 index_(kMaxUInt32), |
82 receiver_(receiver), | 82 receiver_(receiver), |
83 holder_(holder), | 83 holder_(holder), |
84 holder_map_(holder_->map(), isolate_), | 84 holder_map_(holder_->map(), isolate_), |
85 initial_holder_(holder_), | 85 initial_holder_(holder_), |
86 number_(DescriptorArray::kNotFound) { | 86 number_(DescriptorArray::kNotFound) { |
87 #ifdef DEBUG | 87 #ifdef DEBUG |
88 uint32_t index; // Assert that the name is not an array index. | 88 uint32_t index; // Assert that the name is not an array index. |
89 DCHECK(!name->AsArrayIndex(&index)); | 89 DCHECK(!name->AsArrayIndex(&index)); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 initial_holder_(holder_), | 128 initial_holder_(holder_), |
129 number_(DescriptorArray::kNotFound) { | 129 number_(DescriptorArray::kNotFound) { |
130 // kMaxUInt32 isn't a valid index. | 130 // kMaxUInt32 isn't a valid index. |
131 DCHECK_NE(kMaxUInt32, index_); | 131 DCHECK_NE(kMaxUInt32, index_); |
132 Next(); | 132 Next(); |
133 } | 133 } |
134 | 134 |
135 static LookupIterator PropertyOrElement( | 135 static LookupIterator PropertyOrElement( |
136 Isolate* isolate, Handle<Object> receiver, Handle<Name> name, | 136 Isolate* isolate, Handle<Object> receiver, Handle<Name> name, |
137 Configuration configuration = DEFAULT) { | 137 Configuration configuration = DEFAULT) { |
| 138 name = Name::Flatten(name); |
138 uint32_t index; | 139 uint32_t index; |
139 LookupIterator it = | 140 LookupIterator it = |
140 name->AsArrayIndex(&index) | 141 name->AsArrayIndex(&index) |
141 ? LookupIterator(isolate, receiver, index, configuration) | 142 ? LookupIterator(isolate, receiver, index, configuration) |
142 : LookupIterator(receiver, name, configuration); | 143 : LookupIterator(receiver, name, configuration); |
143 it.name_ = name; | 144 it.name_ = name; |
144 return it; | 145 return it; |
145 } | 146 } |
146 | 147 |
147 static LookupIterator PropertyOrElement( | 148 static LookupIterator PropertyOrElement( |
148 Isolate* isolate, Handle<Object> receiver, Handle<Name> name, | 149 Isolate* isolate, Handle<Object> receiver, Handle<Name> name, |
149 Handle<JSReceiver> holder, Configuration configuration = DEFAULT) { | 150 Handle<JSReceiver> holder, Configuration configuration = DEFAULT) { |
| 151 name = Name::Flatten(name); |
150 uint32_t index; | 152 uint32_t index; |
151 LookupIterator it = | 153 LookupIterator it = |
152 name->AsArrayIndex(&index) | 154 name->AsArrayIndex(&index) |
153 ? LookupIterator(isolate, receiver, index, holder, configuration) | 155 ? LookupIterator(isolate, receiver, index, holder, configuration) |
154 : LookupIterator(receiver, name, holder, configuration); | 156 : LookupIterator(receiver, name, holder, configuration); |
155 it.name_ = name; | 157 it.name_ = name; |
156 return it; | 158 return it; |
157 } | 159 } |
| 160 |
158 Isolate* isolate() const { return isolate_; } | 161 Isolate* isolate() const { return isolate_; } |
159 State state() const { return state_; } | 162 State state() const { return state_; } |
160 | 163 |
161 Handle<Name> name() const { | 164 Handle<Name> name() const { |
162 DCHECK(!IsElement()); | 165 DCHECK(!IsElement()); |
163 return name_; | 166 return name_; |
164 } | 167 } |
165 Handle<Name> GetName() { | 168 Handle<Name> GetName() { |
166 if (name_.is_null()) { | 169 if (name_.is_null()) { |
167 DCHECK(IsElement()); | 170 DCHECK(IsElement()); |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 Handle<JSReceiver> holder_; | 308 Handle<JSReceiver> holder_; |
306 Handle<Map> holder_map_; | 309 Handle<Map> holder_map_; |
307 const Handle<JSReceiver> initial_holder_; | 310 const Handle<JSReceiver> initial_holder_; |
308 uint32_t number_; | 311 uint32_t number_; |
309 }; | 312 }; |
310 | 313 |
311 | 314 |
312 } } // namespace v8::internal | 315 } } // namespace v8::internal |
313 | 316 |
314 #endif // V8_LOOKUP_H_ | 317 #endif // V8_LOOKUP_H_ |
OLD | NEW |