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

Side by Side Diff: src/lookup.h

Issue 962613002: add interceptors which do not mask existing properties (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 9 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/ic/ic.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 // Set state_ to BEFORE_PROPERTY to ensure that the next lookup will be a 41 // Set state_ to BEFORE_PROPERTY to ensure that the next lookup will be a
42 // PROPERTY lookup. 42 // PROPERTY lookup.
43 BEFORE_PROPERTY = INTERCEPTOR 43 BEFORE_PROPERTY = INTERCEPTOR
44 }; 44 };
45 45
46 LookupIterator(Handle<Object> receiver, Handle<Name> name, 46 LookupIterator(Handle<Object> receiver, Handle<Name> name,
47 Configuration configuration = PROTOTYPE_CHAIN) 47 Configuration configuration = PROTOTYPE_CHAIN)
48 : configuration_(ComputeConfiguration(configuration, name)), 48 : configuration_(ComputeConfiguration(configuration, name)),
49 state_(NOT_FOUND), 49 state_(NOT_FOUND),
50 exotic_index_state_(ExoticIndexState::kUninitialized), 50 exotic_index_state_(ExoticIndexState::kUninitialized),
51 interceptor_state_(InterceptorState::kUninitialized),
51 property_details_(PropertyDetails::Empty()), 52 property_details_(PropertyDetails::Empty()),
52 isolate_(name->GetIsolate()), 53 isolate_(name->GetIsolate()),
53 name_(name), 54 name_(name),
54 receiver_(receiver), 55 receiver_(receiver),
56 holder_(GetRoot(receiver_, isolate_)),
57 holder_map_(holder_->map(), isolate_),
58 initial_holder_(holder_),
55 number_(DescriptorArray::kNotFound) { 59 number_(DescriptorArray::kNotFound) {
56 holder_ = GetRoot();
57 holder_map_ = handle(holder_->map(), isolate_);
58 Next(); 60 Next();
59 } 61 }
60 62
61 LookupIterator(Handle<Object> receiver, Handle<Name> name, 63 LookupIterator(Handle<Object> receiver, Handle<Name> name,
62 Handle<JSReceiver> holder, 64 Handle<JSReceiver> holder,
63 Configuration configuration = PROTOTYPE_CHAIN) 65 Configuration configuration = PROTOTYPE_CHAIN)
64 : configuration_(ComputeConfiguration(configuration, name)), 66 : configuration_(ComputeConfiguration(configuration, name)),
65 state_(NOT_FOUND), 67 state_(NOT_FOUND),
66 exotic_index_state_(ExoticIndexState::kUninitialized), 68 exotic_index_state_(ExoticIndexState::kUninitialized),
69 interceptor_state_(InterceptorState::kUninitialized),
67 property_details_(PropertyDetails::Empty()), 70 property_details_(PropertyDetails::Empty()),
68 isolate_(name->GetIsolate()), 71 isolate_(name->GetIsolate()),
69 name_(name), 72 name_(name),
70 holder_map_(holder->map(), isolate_),
71 receiver_(receiver), 73 receiver_(receiver),
72 holder_(holder), 74 holder_(holder),
75 holder_map_(holder_->map(), isolate_),
76 initial_holder_(holder_),
73 number_(DescriptorArray::kNotFound) { 77 number_(DescriptorArray::kNotFound) {
74 Next(); 78 Next();
75 } 79 }
76 80
77 Isolate* isolate() const { return isolate_; } 81 Isolate* isolate() const { return isolate_; }
78 State state() const { return state_; } 82 State state() const { return state_; }
79 Handle<Name> name() const { return name_; } 83 Handle<Name> name() const { return name_; }
80 84
81 bool IsFound() const { return state_ != NOT_FOUND; } 85 bool IsFound() const { return state_ != NOT_FOUND; }
82 void Next(); 86 void Next();
83 void NotFound() { 87 void NotFound() {
84 has_property_ = false; 88 has_property_ = false;
85 state_ = NOT_FOUND; 89 state_ = NOT_FOUND;
86 } 90 }
87 91
88 Factory* factory() const { return isolate_->factory(); } 92 Factory* factory() const { return isolate_->factory(); }
89 Handle<Object> GetReceiver() const { return receiver_; } 93 Handle<Object> GetReceiver() const { return receiver_; }
90 Handle<JSObject> GetStoreTarget() const; 94 Handle<JSObject> GetStoreTarget() const;
91 bool is_dictionary_holder() const { return holder_map_->is_dictionary_map(); } 95 bool is_dictionary_holder() const { return holder_map_->is_dictionary_map(); }
92 Handle<Map> transition_map() const { 96 Handle<Map> transition_map() const {
93 DCHECK_EQ(TRANSITION, state_); 97 DCHECK_EQ(TRANSITION, state_);
94 return Handle<Map>::cast(transition_); 98 return Handle<Map>::cast(transition_);
95 } 99 }
96 template <class T> 100 template <class T>
97 Handle<T> GetHolder() const { 101 Handle<T> GetHolder() const {
98 DCHECK(IsFound()); 102 DCHECK(IsFound());
99 return Handle<T>::cast(holder_); 103 return Handle<T>::cast(holder_);
100 } 104 }
101 Handle<JSReceiver> GetRoot() const; 105 static Handle<JSReceiver> GetRoot(Handle<Object> receiver, Isolate* isolate);
102 bool HolderIsReceiverOrHiddenPrototype() const; 106 bool HolderIsReceiverOrHiddenPrototype() const;
103 107
104 /* ACCESS_CHECK */ 108 /* ACCESS_CHECK */
105 bool HasAccess() const; 109 bool HasAccess() const;
106 110
107 /* PROPERTY */ 111 /* PROPERTY */
108 void PrepareForDataProperty(Handle<Object> value); 112 void PrepareForDataProperty(Handle<Object> value);
109 void PrepareTransitionToDataProperty(Handle<Object> value, 113 void PrepareTransitionToDataProperty(Handle<Object> value,
110 PropertyAttributes attributes, 114 PropertyAttributes attributes,
111 Object::StoreFromKeyed store_mode); 115 Object::StoreFromKeyed store_mode);
(...skipping 27 matching lines...) Expand all
139 return Handle<PropertyCell>::cast(transition_); 143 return Handle<PropertyCell>::cast(transition_);
140 } 144 }
141 Handle<Object> GetAccessors() const; 145 Handle<Object> GetAccessors() const;
142 Handle<Object> GetDataValue() const; 146 Handle<Object> GetDataValue() const;
143 // Usually returns the value that was passed in, but may perform 147 // Usually returns the value that was passed in, but may perform
144 // non-observable modifications on it, such as internalize strings. 148 // non-observable modifications on it, such as internalize strings.
145 Handle<Object> WriteDataValue(Handle<Object> value); 149 Handle<Object> WriteDataValue(Handle<Object> value);
146 void InternalizeName(); 150 void InternalizeName();
147 151
148 private: 152 private:
153 enum class InterceptorState {
154 kUninitialized,
155 kSkipNonMasking,
156 kProcessNonMasking
157 };
158
149 Handle<Map> GetReceiverMap() const; 159 Handle<Map> GetReceiverMap() const;
150 160
151 MUST_USE_RESULT inline JSReceiver* NextHolder(Map* map); 161 MUST_USE_RESULT inline JSReceiver* NextHolder(Map* map);
152 inline State LookupInHolder(Map* map, JSReceiver* holder); 162 inline State LookupInHolder(Map* map, JSReceiver* holder);
163 void RestartLookupForNonMaskingInterceptors();
164 State LookupNonMaskingInterceptorInHolder(Map* map, JSReceiver* holder);
153 Handle<Object> FetchValue() const; 165 Handle<Object> FetchValue() const;
154 void ReloadPropertyInformation(); 166 void ReloadPropertyInformation();
167 bool SkipInterceptor(JSObject* holder);
155 168
156 bool IsBootstrapping() const; 169 bool IsBootstrapping() const;
157 170
158 bool check_hidden() const { return (configuration_ & kHidden) != 0; } 171 bool check_hidden() const { return (configuration_ & kHidden) != 0; }
159 bool check_interceptor() const { 172 bool check_interceptor() const {
160 return !IsBootstrapping() && (configuration_ & kInterceptor) != 0; 173 return !IsBootstrapping() && (configuration_ & kInterceptor) != 0;
161 } 174 }
162 bool check_prototype_chain() const { 175 bool check_prototype_chain() const {
163 return (configuration_ & kPrototypeChain) != 0; 176 return (configuration_ & kPrototypeChain) != 0;
164 } 177 }
(...skipping 16 matching lines...) Expand all
181 } else { 194 } else {
182 return configuration; 195 return configuration;
183 } 196 }
184 } 197 }
185 198
186 enum class ExoticIndexState { kUninitialized, kNoIndex, kIndex }; 199 enum class ExoticIndexState { kUninitialized, kNoIndex, kIndex };
187 bool IsIntegerIndexedExotic(JSReceiver* holder); 200 bool IsIntegerIndexedExotic(JSReceiver* holder);
188 201
189 // If configuration_ becomes mutable, update 202 // If configuration_ becomes mutable, update
190 // HolderIsReceiverOrHiddenPrototype. 203 // HolderIsReceiverOrHiddenPrototype.
191 Configuration configuration_; 204 const Configuration configuration_;
192 State state_; 205 State state_;
193 bool has_property_; 206 bool has_property_;
194 ExoticIndexState exotic_index_state_; 207 ExoticIndexState exotic_index_state_;
208 InterceptorState interceptor_state_;
195 PropertyDetails property_details_; 209 PropertyDetails property_details_;
196 Isolate* isolate_; 210 Isolate* const isolate_;
197 Handle<Name> name_; 211 Handle<Name> name_;
212 Handle<Object> transition_;
213 const Handle<Object> receiver_;
214 Handle<JSReceiver> holder_;
198 Handle<Map> holder_map_; 215 Handle<Map> holder_map_;
199 Handle<Object> transition_; 216 const Handle<JSReceiver> initial_holder_;
200 Handle<Object> receiver_;
201 Handle<JSReceiver> holder_;
202
203 int number_; 217 int number_;
204 }; 218 };
205 219
206 220
207 } } // namespace v8::internal 221 } } // namespace v8::internal
208 222
209 #endif // V8_LOOKUP_H_ 223 #endif // V8_LOOKUP_H_
OLDNEW
« no previous file with comments | « src/ic/ic.cc ('k') | src/lookup.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698