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" |
11 | 11 |
12 namespace v8 { | 12 namespace v8 { |
13 namespace internal { | 13 namespace internal { |
14 | 14 |
15 class LookupIterator V8_FINAL BASE_EMBEDDED { | 15 class LookupIterator V8_FINAL BASE_EMBEDDED { |
16 public: | 16 public: |
17 enum Configuration { | 17 enum Configuration { |
18 CHECK_OWN_REAL = 0, | 18 // Configuration bits. |
19 CHECK_HIDDEN = 1 << 0, | 19 CHECK_HIDDEN_PROPERTY = 1 << 0, |
20 CHECK_DERIVED = 1 << 1, | 20 CHECK_DERIVED_PROPERTY = 1 << 1, |
21 CHECK_INTERCEPTOR = 1 << 2, | 21 CHECK_INTERCEPTOR = 1 << 2, |
22 CHECK_ACCESS_CHECK = 1 << 3, | 22 CHECK_ACCESS_CHECK = 1 << 3, |
23 CHECK_HIDDEN_ACCESS = CHECK_HIDDEN | CHECK_ACCESS_CHECK, | 23 |
24 SKIP_INTERCEPTOR = CHECK_HIDDEN_ACCESS | CHECK_DERIVED, | 24 // Convience combinations of bits. |
25 CHECK_ALL = SKIP_INTERCEPTOR | CHECK_INTERCEPTOR, | 25 CHECK_PROPERTY = 0, |
26 CHECK_OWN = CHECK_HIDDEN_ACCESS | CHECK_INTERCEPTOR | 26 CHECK_HIDDEN_SKIP_INTERCEPTOR = CHECK_HIDDEN_PROPERTY | CHECK_ACCESS_CHECK, |
| 27 CHECK_DERIVED_SKIP_INTERCEPTOR = |
| 28 CHECK_HIDDEN_SKIP_INTERCEPTOR | CHECK_DERIVED_PROPERTY, |
| 29 CHECK_DERIVED = CHECK_DERIVED_SKIP_INTERCEPTOR | CHECK_INTERCEPTOR, |
| 30 CHECK_HIDDEN = CHECK_HIDDEN_SKIP_INTERCEPTOR | CHECK_INTERCEPTOR |
27 }; | 31 }; |
28 | 32 |
29 enum State { | 33 enum State { |
30 NOT_FOUND, | 34 NOT_FOUND, |
31 PROPERTY, | 35 PROPERTY, |
32 INTERCEPTOR, | 36 INTERCEPTOR, |
33 ACCESS_CHECK, | 37 ACCESS_CHECK, |
34 JSPROXY | 38 JSPROXY |
35 }; | 39 }; |
36 | 40 |
37 enum PropertyKind { | 41 enum PropertyKind { |
38 DATA, | 42 DATA, |
39 ACCESSOR | 43 ACCESSOR |
40 }; | 44 }; |
41 | 45 |
42 enum PropertyEncoding { | 46 enum PropertyEncoding { |
43 DICTIONARY, | 47 DICTIONARY, |
44 DESCRIPTOR | 48 DESCRIPTOR |
45 }; | 49 }; |
46 | 50 |
47 LookupIterator(Handle<Object> receiver, | 51 LookupIterator(Handle<Object> receiver, Handle<Name> name, |
48 Handle<Name> name, | 52 Configuration configuration = CHECK_DERIVED) |
49 Configuration configuration = CHECK_ALL) | |
50 : configuration_(ComputeConfiguration(configuration, name)), | 53 : configuration_(ComputeConfiguration(configuration, name)), |
51 state_(NOT_FOUND), | 54 state_(NOT_FOUND), |
52 property_kind_(DATA), | 55 property_kind_(DATA), |
53 property_encoding_(DESCRIPTOR), | 56 property_encoding_(DESCRIPTOR), |
54 property_details_(NONE, NONEXISTENT, Representation::None()), | 57 property_details_(NONE, NONEXISTENT, Representation::None()), |
55 isolate_(name->GetIsolate()), | 58 isolate_(name->GetIsolate()), |
56 name_(name), | 59 name_(name), |
57 maybe_receiver_(receiver), | 60 maybe_receiver_(receiver), |
58 number_(DescriptorArray::kNotFound) { | 61 number_(DescriptorArray::kNotFound) { |
59 Handle<JSReceiver> root = GetRoot(); | 62 Handle<JSReceiver> root = GetRoot(); |
60 holder_map_ = handle(root->map()); | 63 holder_map_ = handle(root->map()); |
61 maybe_holder_ = root; | 64 maybe_holder_ = root; |
62 Next(); | 65 Next(); |
63 } | 66 } |
64 | 67 |
65 LookupIterator(Handle<Object> receiver, | 68 LookupIterator(Handle<Object> receiver, Handle<Name> name, |
66 Handle<Name> name, | |
67 Handle<JSReceiver> holder, | 69 Handle<JSReceiver> holder, |
68 Configuration configuration = CHECK_ALL) | 70 Configuration configuration = CHECK_DERIVED) |
69 : configuration_(ComputeConfiguration(configuration, name)), | 71 : configuration_(ComputeConfiguration(configuration, name)), |
70 state_(NOT_FOUND), | 72 state_(NOT_FOUND), |
71 property_kind_(DATA), | 73 property_kind_(DATA), |
72 property_encoding_(DESCRIPTOR), | 74 property_encoding_(DESCRIPTOR), |
73 property_details_(NONE, NONEXISTENT, Representation::None()), | 75 property_details_(NONE, NONEXISTENT, Representation::None()), |
74 isolate_(name->GetIsolate()), | 76 isolate_(name->GetIsolate()), |
75 name_(name), | 77 name_(name), |
76 holder_map_(holder->map()), | 78 holder_map_(holder->map()), |
77 maybe_receiver_(receiver), | 79 maybe_receiver_(receiver), |
78 maybe_holder_(holder), | 80 maybe_holder_(holder), |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 // This means the receiver needs to be present as opposed to just the receiver | 156 // This means the receiver needs to be present as opposed to just the receiver |
155 // map. Other objects in the prototype chain are transitively guaranteed to be | 157 // map. Other objects in the prototype chain are transitively guaranteed to be |
156 // present via the receiver map. | 158 // present via the receiver map. |
157 bool is_guaranteed_to_have_holder() const { | 159 bool is_guaranteed_to_have_holder() const { |
158 return !maybe_receiver_.is_null(); | 160 return !maybe_receiver_.is_null(); |
159 } | 161 } |
160 bool check_interceptor() const { | 162 bool check_interceptor() const { |
161 return !IsBootstrapping() && (configuration_ & CHECK_INTERCEPTOR) != 0; | 163 return !IsBootstrapping() && (configuration_ & CHECK_INTERCEPTOR) != 0; |
162 } | 164 } |
163 bool check_derived() const { | 165 bool check_derived() const { |
164 return (configuration_ & CHECK_DERIVED) != 0; | 166 return (configuration_ & CHECK_DERIVED_PROPERTY) != 0; |
165 } | 167 } |
166 bool check_hidden() const { | 168 bool check_hidden() const { |
167 return (configuration_ & CHECK_HIDDEN) != 0; | 169 return (configuration_ & CHECK_HIDDEN_PROPERTY) != 0; |
168 } | 170 } |
169 bool check_access_check() const { | 171 bool check_access_check() const { |
170 return (configuration_ & CHECK_ACCESS_CHECK) != 0; | 172 return (configuration_ & CHECK_ACCESS_CHECK) != 0; |
171 } | 173 } |
172 int descriptor_number() const { | 174 int descriptor_number() const { |
173 DCHECK(has_property_); | 175 DCHECK(has_property_); |
174 DCHECK_EQ(DESCRIPTOR, property_encoding_); | 176 DCHECK_EQ(DESCRIPTOR, property_encoding_); |
175 return number_; | 177 return number_; |
176 } | 178 } |
177 int dictionary_entry() const { | 179 int dictionary_entry() const { |
178 DCHECK(has_property_); | 180 DCHECK(has_property_); |
179 DCHECK_EQ(DICTIONARY, property_encoding_); | 181 DCHECK_EQ(DICTIONARY, property_encoding_); |
180 return number_; | 182 return number_; |
181 } | 183 } |
182 | 184 |
183 static Configuration ComputeConfiguration( | 185 static Configuration ComputeConfiguration( |
184 Configuration configuration, Handle<Name> name) { | 186 Configuration configuration, Handle<Name> name) { |
185 if (name->IsOwn()) { | 187 if (name->IsOwn()) { |
186 return static_cast<Configuration>(configuration & CHECK_OWN); | 188 return static_cast<Configuration>(configuration & CHECK_HIDDEN); |
187 } else { | 189 } else { |
188 return configuration; | 190 return configuration; |
189 } | 191 } |
190 } | 192 } |
191 | 193 |
192 // If configuration_ becomes mutable, update | 194 // If configuration_ becomes mutable, update |
193 // HolderIsReceiverOrHiddenPrototype. | 195 // HolderIsReceiverOrHiddenPrototype. |
194 Configuration configuration_; | 196 Configuration configuration_; |
195 State state_; | 197 State state_; |
196 bool has_property_; | 198 bool has_property_; |
197 PropertyKind property_kind_; | 199 PropertyKind property_kind_; |
198 PropertyEncoding property_encoding_; | 200 PropertyEncoding property_encoding_; |
199 PropertyDetails property_details_; | 201 PropertyDetails property_details_; |
200 Isolate* isolate_; | 202 Isolate* isolate_; |
201 Handle<Name> name_; | 203 Handle<Name> name_; |
202 Handle<Map> holder_map_; | 204 Handle<Map> holder_map_; |
203 MaybeHandle<Object> maybe_receiver_; | 205 MaybeHandle<Object> maybe_receiver_; |
204 MaybeHandle<JSReceiver> maybe_holder_; | 206 MaybeHandle<JSReceiver> maybe_holder_; |
205 | 207 |
206 int number_; | 208 int number_; |
207 }; | 209 }; |
208 | 210 |
209 | 211 |
210 } } // namespace v8::internal | 212 } } // namespace v8::internal |
211 | 213 |
212 #endif // V8_LOOKUP_H_ | 214 #endif // V8_LOOKUP_H_ |
OLD | NEW |