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_DERIVED = 1 << 0, | |
19 CHECK_INTERCEPTOR = 1 << 1, | |
20 CHECK_ACCESS_CHECK = 1 << 2, | |
21 CHECK_OWN_REAL = 0, | 18 CHECK_OWN_REAL = 0, |
22 CHECK_ALL = CHECK_DERIVED | CHECK_INTERCEPTOR | CHECK_ACCESS_CHECK, | 19 CHECK_HIDDEN = 1 << 0, |
23 SKIP_INTERCEPTOR = CHECK_ALL ^ CHECK_INTERCEPTOR | 20 CHECK_DERIVED = 1 << 1, |
| 21 CHECK_INTERCEPTOR = 1 << 2, |
| 22 CHECK_ACCESS_CHECK = 1 << 3, |
| 23 CHECK_ALL = CHECK_HIDDEN | CHECK_DERIVED | |
| 24 CHECK_INTERCEPTOR | CHECK_ACCESS_CHECK, |
| 25 SKIP_INTERCEPTOR = CHECK_ALL ^ CHECK_INTERCEPTOR, |
| 26 CHECK_OWN = CHECK_ALL ^ CHECK_DERIVED |
24 }; | 27 }; |
25 | 28 |
26 enum State { | 29 enum State { |
27 NOT_FOUND, | 30 NOT_FOUND, |
28 PROPERTY, | 31 PROPERTY, |
29 INTERCEPTOR, | 32 INTERCEPTOR, |
30 ACCESS_CHECK, | 33 ACCESS_CHECK, |
31 JSPROXY | 34 JSPROXY |
32 }; | 35 }; |
33 | 36 |
(...skipping 12 matching lines...) Expand all Loading... |
46 Configuration configuration = CHECK_ALL) | 49 Configuration configuration = CHECK_ALL) |
47 : configuration_(configuration), | 50 : configuration_(configuration), |
48 state_(NOT_FOUND), | 51 state_(NOT_FOUND), |
49 property_kind_(DATA), | 52 property_kind_(DATA), |
50 property_encoding_(DESCRIPTOR), | 53 property_encoding_(DESCRIPTOR), |
51 property_details_(NONE, NONEXISTENT, Representation::None()), | 54 property_details_(NONE, NONEXISTENT, Representation::None()), |
52 isolate_(name->GetIsolate()), | 55 isolate_(name->GetIsolate()), |
53 name_(name), | 56 name_(name), |
54 maybe_receiver_(receiver), | 57 maybe_receiver_(receiver), |
55 number_(DescriptorArray::kNotFound) { | 58 number_(DescriptorArray::kNotFound) { |
56 Handle<JSReceiver> origin = GetRoot(); | 59 Handle<JSReceiver> root = GetRoot(); |
57 holder_map_ = handle(origin->map()); | 60 holder_map_ = handle(root->map()); |
58 maybe_holder_ = origin; | 61 maybe_holder_ = root; |
59 Next(); | 62 Next(); |
60 } | 63 } |
61 | 64 |
62 LookupIterator(Handle<Object> receiver, | 65 LookupIterator(Handle<Object> receiver, |
63 Handle<Name> name, | 66 Handle<Name> name, |
64 Handle<JSReceiver> holder, | 67 Handle<JSReceiver> holder, |
65 Configuration configuration = CHECK_ALL) | 68 Configuration configuration = CHECK_ALL) |
66 : configuration_(configuration), | 69 : configuration_(configuration), |
67 state_(NOT_FOUND), | 70 state_(NOT_FOUND), |
68 property_kind_(DATA), | 71 property_kind_(DATA), |
(...skipping 19 matching lines...) Expand all Loading... |
88 Factory* factory() const { return isolate_->factory(); } | 91 Factory* factory() const { return isolate_->factory(); } |
89 Handle<Object> GetReceiver() const { | 92 Handle<Object> GetReceiver() const { |
90 return Handle<Object>::cast(maybe_receiver_.ToHandleChecked()); | 93 return Handle<Object>::cast(maybe_receiver_.ToHandleChecked()); |
91 } | 94 } |
92 Handle<JSObject> GetHolder() const { | 95 Handle<JSObject> GetHolder() const { |
93 ASSERT(IsFound() && state_ != JSPROXY); | 96 ASSERT(IsFound() && state_ != JSPROXY); |
94 return Handle<JSObject>::cast(maybe_holder_.ToHandleChecked()); | 97 return Handle<JSObject>::cast(maybe_holder_.ToHandleChecked()); |
95 } | 98 } |
96 Handle<JSReceiver> GetRoot() const; | 99 Handle<JSReceiver> GetRoot() const; |
97 | 100 |
| 101 /* Dynamically reduce the trapped types. */ |
| 102 void skip_interceptor() { |
| 103 configuration_ = static_cast<Configuration>( |
| 104 configuration_ & ~CHECK_INTERCEPTOR); |
| 105 } |
| 106 void skip_access_checks() { |
| 107 configuration_ = static_cast<Configuration>( |
| 108 configuration_ & ~CHECK_ACCESS_CHECK); |
| 109 } |
| 110 |
98 /* ACCESS_CHECK */ | 111 /* ACCESS_CHECK */ |
99 bool HasAccess(v8::AccessType access_type) const; | 112 bool HasAccess(v8::AccessType access_type) const; |
100 | 113 |
101 /* PROPERTY */ | 114 /* PROPERTY */ |
102 // HasProperty needs to be called before any of the other PROPERTY methods | 115 // HasProperty needs to be called before any of the other PROPERTY methods |
103 // below can be used. It ensures that we are able to provide a definite | 116 // below can be used. It ensures that we are able to provide a definite |
104 // answer, and loads extra information about the property. | 117 // answer, and loads extra information about the property. |
105 bool HasProperty(); | 118 bool HasProperty(); |
106 PropertyKind property_kind() const { | 119 PropertyKind property_kind() const { |
107 ASSERT(has_property_); | 120 ASSERT(has_property_); |
(...skipping 27 matching lines...) Expand all Loading... |
135 // present via the receiver map. | 148 // present via the receiver map. |
136 bool is_guaranteed_to_have_holder() const { | 149 bool is_guaranteed_to_have_holder() const { |
137 return !maybe_receiver_.is_null(); | 150 return !maybe_receiver_.is_null(); |
138 } | 151 } |
139 bool check_interceptor() const { | 152 bool check_interceptor() const { |
140 return !IsBootstrapping() && (configuration_ & CHECK_INTERCEPTOR) != 0; | 153 return !IsBootstrapping() && (configuration_ & CHECK_INTERCEPTOR) != 0; |
141 } | 154 } |
142 bool check_derived() const { | 155 bool check_derived() const { |
143 return (configuration_ & CHECK_DERIVED) != 0; | 156 return (configuration_ & CHECK_DERIVED) != 0; |
144 } | 157 } |
| 158 bool check_hidden() const { |
| 159 return (configuration_ & CHECK_HIDDEN) != 0; |
| 160 } |
145 bool check_access_check() const { | 161 bool check_access_check() const { |
146 return (configuration_ & CHECK_ACCESS_CHECK) != 0; | 162 return (configuration_ & CHECK_ACCESS_CHECK) != 0; |
147 } | 163 } |
148 | 164 |
149 Configuration configuration_; | 165 Configuration configuration_; |
150 State state_; | 166 State state_; |
151 bool has_property_; | 167 bool has_property_; |
152 PropertyKind property_kind_; | 168 PropertyKind property_kind_; |
153 PropertyEncoding property_encoding_; | 169 PropertyEncoding property_encoding_; |
154 PropertyDetails property_details_; | 170 PropertyDetails property_details_; |
155 Isolate* isolate_; | 171 Isolate* isolate_; |
156 Handle<Name> name_; | 172 Handle<Name> name_; |
157 Handle<Map> holder_map_; | 173 Handle<Map> holder_map_; |
158 MaybeHandle<Object> maybe_receiver_; | 174 MaybeHandle<Object> maybe_receiver_; |
159 MaybeHandle<JSReceiver> maybe_holder_; | 175 MaybeHandle<JSReceiver> maybe_holder_; |
160 | 176 |
161 int number_; | 177 int number_; |
162 }; | 178 }; |
163 | 179 |
164 | 180 |
165 } } // namespace v8::internal | 181 } } // namespace v8::internal |
166 | 182 |
167 #endif // V8_LOOKUP_H_ | 183 #endif // V8_LOOKUP_H_ |
OLD | NEW |