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

Side by Side Diff: src/lookup.h

Issue 570293002: Simplify the LookupIterator (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 3 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 | Annotate | Revision Log
« 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 16 matching lines...) Expand all
27 HIDDEN = kHidden | kInterceptor, 27 HIDDEN = kHidden | kInterceptor,
28 PROTOTYPE_CHAIN_SKIP_INTERCEPTOR = kHidden | kPrototypeChain, 28 PROTOTYPE_CHAIN_SKIP_INTERCEPTOR = kHidden | kPrototypeChain,
29 PROTOTYPE_CHAIN = kHidden | kPrototypeChain | kInterceptor 29 PROTOTYPE_CHAIN = kHidden | kPrototypeChain | kInterceptor
30 }; 30 };
31 31
32 enum State { 32 enum State {
33 ACCESS_CHECK, 33 ACCESS_CHECK,
34 INTERCEPTOR, 34 INTERCEPTOR,
35 JSPROXY, 35 JSPROXY,
36 NOT_FOUND, 36 NOT_FOUND,
37 UNKNOWN, // Dictionary-mode holder map without a holder.
38 ACCESSOR, 37 ACCESSOR,
39 DATA, 38 DATA,
40 TRANSITION, 39 TRANSITION,
41 // Set state_ to BEFORE_PROPERTY to ensure that the next lookup will be a 40 // Set state_ to BEFORE_PROPERTY to ensure that the next lookup will be a
42 // PROPERTY lookup. 41 // PROPERTY lookup.
43 BEFORE_PROPERTY = INTERCEPTOR 42 BEFORE_PROPERTY = INTERCEPTOR
44 }; 43 };
45 44
46 LookupIterator(Handle<Object> receiver, Handle<Name> name, 45 LookupIterator(Handle<Object> receiver, Handle<Name> name,
47 Configuration configuration = PROTOTYPE_CHAIN) 46 Configuration configuration = PROTOTYPE_CHAIN)
48 : configuration_(ComputeConfiguration(configuration, name)), 47 : configuration_(ComputeConfiguration(configuration, name)),
49 state_(NOT_FOUND), 48 state_(NOT_FOUND),
50 property_details_(NONE, NORMAL, Representation::None()), 49 property_details_(NONE, NORMAL, Representation::None()),
51 isolate_(name->GetIsolate()), 50 isolate_(name->GetIsolate()),
52 name_(name), 51 name_(name),
53 maybe_receiver_(receiver), 52 receiver_(receiver),
54 number_(DescriptorArray::kNotFound) { 53 number_(DescriptorArray::kNotFound) {
55 Handle<JSReceiver> root = GetRoot(); 54 holder_ = GetRoot();
56 holder_map_ = handle(root->map(), isolate_); 55 holder_map_ = handle(holder_->map(), isolate_);
57 maybe_holder_ = root;
58 Next(); 56 Next();
59 } 57 }
60 58
61 LookupIterator(Handle<Object> receiver, Handle<Name> name, 59 LookupIterator(Handle<Object> receiver, Handle<Name> name,
62 Handle<JSReceiver> holder, 60 Handle<JSReceiver> holder,
63 Configuration configuration = PROTOTYPE_CHAIN) 61 Configuration configuration = PROTOTYPE_CHAIN)
64 : configuration_(ComputeConfiguration(configuration, name)), 62 : configuration_(ComputeConfiguration(configuration, name)),
65 state_(NOT_FOUND), 63 state_(NOT_FOUND),
66 property_details_(NONE, NORMAL, Representation::None()), 64 property_details_(NONE, NORMAL, Representation::None()),
67 isolate_(name->GetIsolate()), 65 isolate_(name->GetIsolate()),
68 name_(name), 66 name_(name),
69 holder_map_(holder->map(), isolate_), 67 holder_map_(holder->map(), isolate_),
70 maybe_receiver_(receiver), 68 receiver_(receiver),
71 maybe_holder_(holder), 69 holder_(holder),
72 number_(DescriptorArray::kNotFound) { 70 number_(DescriptorArray::kNotFound) {
73 Next(); 71 Next();
74 } 72 }
75 73
76 Isolate* isolate() const { return isolate_; } 74 Isolate* isolate() const { return isolate_; }
77 State state() const { return state_; } 75 State state() const { return state_; }
78 Handle<Name> name() const { return name_; } 76 Handle<Name> name() const { return name_; }
79 77
80 bool IsFound() const { return state_ != NOT_FOUND; } 78 bool IsFound() const { return state_ != NOT_FOUND; }
81 void Next(); 79 void Next();
82 void NotFound() { 80 void NotFound() {
83 has_property_ = false; 81 has_property_ = false;
84 state_ = NOT_FOUND; 82 state_ = NOT_FOUND;
85 } 83 }
86 84
87 Factory* factory() const { return isolate_->factory(); } 85 Factory* factory() const { return isolate_->factory(); }
88 Handle<Object> GetReceiver() const { 86 Handle<Object> GetReceiver() const { return receiver_; }
89 return maybe_receiver_.ToHandleChecked();
90 }
91 Handle<JSObject> GetStoreTarget() const; 87 Handle<JSObject> GetStoreTarget() const;
92 bool is_dictionary_holder() const { return holder_map_->is_dictionary_map(); } 88 bool is_dictionary_holder() const { return holder_map_->is_dictionary_map(); }
93 Handle<Map> transition_map() const { 89 Handle<Map> transition_map() const {
94 DCHECK_EQ(TRANSITION, state_); 90 DCHECK_EQ(TRANSITION, state_);
95 return transition_map_; 91 return transition_map_;
96 } 92 }
97 template <class T> 93 template <class T>
98 Handle<T> GetHolder() const { 94 Handle<T> GetHolder() const {
99 DCHECK(IsFound()); 95 DCHECK(IsFound());
100 return Handle<T>::cast(maybe_holder_.ToHandleChecked()); 96 return Handle<T>::cast(holder_);
101 } 97 }
102 Handle<JSReceiver> GetRoot() const; 98 Handle<JSReceiver> GetRoot() const;
103 bool HolderIsReceiverOrHiddenPrototype() const; 99 bool HolderIsReceiverOrHiddenPrototype() const;
104 100
105 /* ACCESS_CHECK */ 101 /* ACCESS_CHECK */
106 bool HasAccess(v8::AccessType access_type) const; 102 bool HasAccess(v8::AccessType access_type) const;
107 103
108 /* PROPERTY */ 104 /* PROPERTY */
109 void PrepareForDataProperty(Handle<Object> value); 105 void PrepareForDataProperty(Handle<Object> value);
110 void PrepareTransitionToDataProperty(Handle<Object> value, 106 void PrepareTransitionToDataProperty(Handle<Object> value,
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 private: 143 private:
148 Handle<Map> GetReceiverMap() const; 144 Handle<Map> GetReceiverMap() const;
149 145
150 MUST_USE_RESULT inline JSReceiver* NextHolder(Map* map); 146 MUST_USE_RESULT inline JSReceiver* NextHolder(Map* map);
151 inline State LookupInHolder(Map* map, JSReceiver* holder); 147 inline State LookupInHolder(Map* map, JSReceiver* holder);
152 Handle<Object> FetchValue() const; 148 Handle<Object> FetchValue() const;
153 void ReloadPropertyInformation(); 149 void ReloadPropertyInformation();
154 150
155 bool IsBootstrapping() const; 151 bool IsBootstrapping() const;
156 152
157 // Methods that fetch data from the holder ensure they always have a holder.
158 // This means the receiver needs to be present as opposed to just the receiver
159 // map. Other objects in the prototype chain are transitively guaranteed to be
160 // present via the receiver map.
161 bool is_guaranteed_to_have_holder() const {
162 return !maybe_receiver_.is_null();
163 }
164 bool check_hidden() const { return (configuration_ & kHidden) != 0; } 153 bool check_hidden() const { return (configuration_ & kHidden) != 0; }
165 bool check_interceptor() const { 154 bool check_interceptor() const {
166 return !IsBootstrapping() && (configuration_ & kInterceptor) != 0; 155 return !IsBootstrapping() && (configuration_ & kInterceptor) != 0;
167 } 156 }
168 bool check_prototype_chain() const { 157 bool check_prototype_chain() const {
169 return (configuration_ & kPrototypeChain) != 0; 158 return (configuration_ & kPrototypeChain) != 0;
170 } 159 }
171 int descriptor_number() const { 160 int descriptor_number() const {
172 DCHECK(has_property_); 161 DCHECK(has_property_);
173 DCHECK(!holder_map_->is_dictionary_map()); 162 DCHECK(!holder_map_->is_dictionary_map());
(...skipping 17 matching lines...) Expand all
191 // If configuration_ becomes mutable, update 180 // If configuration_ becomes mutable, update
192 // HolderIsReceiverOrHiddenPrototype. 181 // HolderIsReceiverOrHiddenPrototype.
193 Configuration configuration_; 182 Configuration configuration_;
194 State state_; 183 State state_;
195 bool has_property_; 184 bool has_property_;
196 PropertyDetails property_details_; 185 PropertyDetails property_details_;
197 Isolate* isolate_; 186 Isolate* isolate_;
198 Handle<Name> name_; 187 Handle<Name> name_;
199 Handle<Map> holder_map_; 188 Handle<Map> holder_map_;
200 Handle<Map> transition_map_; 189 Handle<Map> transition_map_;
201 MaybeHandle<Object> maybe_receiver_; 190 Handle<Object> receiver_;
202 MaybeHandle<JSReceiver> maybe_holder_; 191 Handle<JSReceiver> holder_;
203 192
204 int number_; 193 int number_;
205 }; 194 };
206 195
207 196
208 } } // namespace v8::internal 197 } } // namespace v8::internal
209 198
210 #endif // V8_LOOKUP_H_ 199 #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