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 CHECK_OWN_REAL = 0, |
19 CHECK_HIDDEN = 1 << 0, | 19 CHECK_HIDDEN = 1 << 0, |
20 CHECK_DERIVED = 1 << 1, | 20 CHECK_DERIVED = 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_ALL = CHECK_HIDDEN | CHECK_DERIVED | | 23 CHECK_HIDDEN_ACCESS = CHECK_HIDDEN | CHECK_ACCESS_CHECK, |
24 CHECK_INTERCEPTOR | CHECK_ACCESS_CHECK, | 24 SKIP_INTERCEPTOR = CHECK_HIDDEN_ACCESS | CHECK_DERIVED, |
25 SKIP_INTERCEPTOR = CHECK_ALL ^ CHECK_INTERCEPTOR, | 25 CHECK_ALL = SKIP_INTERCEPTOR | CHECK_INTERCEPTOR, |
26 CHECK_OWN = CHECK_ALL ^ CHECK_DERIVED | 26 CHECK_OWN = CHECK_HIDDEN_ACCESS | CHECK_INTERCEPTOR |
27 }; | 27 }; |
28 | 28 |
29 enum State { | 29 enum State { |
30 NOT_FOUND, | 30 NOT_FOUND, |
31 PROPERTY, | 31 PROPERTY, |
32 INTERCEPTOR, | 32 INTERCEPTOR, |
33 ACCESS_CHECK, | 33 ACCESS_CHECK, |
34 JSPROXY | 34 JSPROXY |
35 }; | 35 }; |
36 | 36 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 Isolate* isolate() const { return isolate_; } | 83 Isolate* isolate() const { return isolate_; } |
84 State state() const { return state_; } | 84 State state() const { return state_; } |
85 Handle<Name> name() const { return name_; } | 85 Handle<Name> name() const { return name_; } |
86 | 86 |
87 bool IsFound() const { return state_ != NOT_FOUND; } | 87 bool IsFound() const { return state_ != NOT_FOUND; } |
88 void Next(); | 88 void Next(); |
89 | 89 |
90 Heap* heap() const { return isolate_->heap(); } | 90 Heap* heap() const { return isolate_->heap(); } |
91 Factory* factory() const { return isolate_->factory(); } | 91 Factory* factory() const { return isolate_->factory(); } |
92 Handle<Object> GetReceiver() const { | 92 Handle<Object> GetReceiver() const { |
93 return Handle<Object>::cast(maybe_receiver_.ToHandleChecked()); | 93 return maybe_receiver_.ToHandleChecked(); |
94 } | 94 } |
95 Handle<Map> holder_map() const { return holder_map_; } | 95 Handle<Map> holder_map() const { return holder_map_; } |
96 template <class T> | 96 template <class T> |
97 Handle<T> GetHolder() const { | 97 Handle<T> GetHolder() const { |
98 DCHECK(IsFound()); | 98 DCHECK(IsFound()); |
99 return Handle<T>::cast(maybe_holder_.ToHandleChecked()); | 99 return Handle<T>::cast(maybe_holder_.ToHandleChecked()); |
100 } | 100 } |
101 Handle<JSReceiver> GetRoot() const; | 101 Handle<JSReceiver> GetRoot() const; |
102 bool HolderIsReceiverOrHiddenPrototype() const; | 102 bool HolderIsReceiverOrHiddenPrototype() const; |
103 | 103 bool HolderIsNonGlobalHiddenPrototype() const; |
104 /* Dynamically reduce the trapped types. */ | |
105 void skip_interceptor() { | |
106 configuration_ = static_cast<Configuration>( | |
107 configuration_ & ~CHECK_INTERCEPTOR); | |
108 } | |
109 void skip_access_check() { | |
110 configuration_ = static_cast<Configuration>( | |
111 configuration_ & ~CHECK_ACCESS_CHECK); | |
112 } | |
113 | 104 |
114 /* ACCESS_CHECK */ | 105 /* ACCESS_CHECK */ |
115 bool HasAccess(v8::AccessType access_type) const; | 106 bool HasAccess(v8::AccessType access_type) const; |
116 | 107 |
117 /* PROPERTY */ | 108 /* PROPERTY */ |
118 // HasProperty needs to be called before any of the other PROPERTY methods | 109 // HasProperty needs to be called before any of the other PROPERTY methods |
119 // below can be used. It ensures that we are able to provide a definite | 110 // below can be used. It ensures that we are able to provide a definite |
120 // answer, and loads extra information about the property. | 111 // answer, and loads extra information about the property. |
121 bool HasProperty(); | 112 bool HasProperty(); |
122 void PrepareForDataProperty(Handle<Object> value); | 113 void PrepareForDataProperty(Handle<Object> value); |
123 void TransitionToDataProperty(Handle<Object> value, | 114 void TransitionToDataProperty(Handle<Object> value, |
124 PropertyAttributes attributes, | 115 PropertyAttributes attributes, |
125 Object::StoreFromKeyed store_mode); | 116 Object::StoreFromKeyed store_mode); |
| 117 void ReconfigureDataProperty(Handle<Object> value, |
| 118 PropertyAttributes attributes); |
126 PropertyKind property_kind() const { | 119 PropertyKind property_kind() const { |
127 DCHECK(has_property_); | 120 DCHECK(has_property_); |
128 return property_kind_; | 121 return property_kind_; |
129 } | 122 } |
130 PropertyEncoding property_encoding() const { | 123 PropertyEncoding property_encoding() const { |
131 DCHECK(has_property_); | 124 DCHECK(has_property_); |
132 return property_encoding_; | 125 return property_encoding_; |
133 } | 126 } |
134 PropertyDetails property_details() const { | 127 PropertyDetails property_details() const { |
135 DCHECK(has_property_); | 128 DCHECK(has_property_); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 | 182 |
190 static Configuration ComputeConfiguration( | 183 static Configuration ComputeConfiguration( |
191 Configuration configuration, Handle<Name> name) { | 184 Configuration configuration, Handle<Name> name) { |
192 if (name->IsOwn()) { | 185 if (name->IsOwn()) { |
193 return static_cast<Configuration>(configuration & CHECK_OWN); | 186 return static_cast<Configuration>(configuration & CHECK_OWN); |
194 } else { | 187 } else { |
195 return configuration; | 188 return configuration; |
196 } | 189 } |
197 } | 190 } |
198 | 191 |
| 192 // If configuration_ becomes mutable, update |
| 193 // HolderIsReceiverOrHiddenPrototype. |
199 Configuration configuration_; | 194 Configuration configuration_; |
200 State state_; | 195 State state_; |
201 bool has_property_; | 196 bool has_property_; |
202 PropertyKind property_kind_; | 197 PropertyKind property_kind_; |
203 PropertyEncoding property_encoding_; | 198 PropertyEncoding property_encoding_; |
204 PropertyDetails property_details_; | 199 PropertyDetails property_details_; |
205 Isolate* isolate_; | 200 Isolate* isolate_; |
206 Handle<Name> name_; | 201 Handle<Name> name_; |
207 Handle<Map> holder_map_; | 202 Handle<Map> holder_map_; |
208 MaybeHandle<Object> maybe_receiver_; | 203 MaybeHandle<Object> maybe_receiver_; |
209 MaybeHandle<JSReceiver> maybe_holder_; | 204 MaybeHandle<JSReceiver> maybe_holder_; |
210 | 205 |
211 int number_; | 206 int number_; |
212 }; | 207 }; |
213 | 208 |
214 | 209 |
215 } } // namespace v8::internal | 210 } } // namespace v8::internal |
216 | 211 |
217 #endif // V8_LOOKUP_H_ | 212 #endif // V8_LOOKUP_H_ |
OLD | NEW |