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

Side by Side Diff: src/lookup.h

Issue 314953006: Implement LookupIterator designed to replace LookupResult (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Adding to BUILD.gn Created 6 years, 6 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef V8_LOOKUP_H_
6 #define V8_LOOKUP_H_
7
8 #include "src/factory.h"
9 #include "src/isolate.h"
10 #include "src/objects.h"
11
12 namespace v8 {
13 namespace internal {
14
15 class LookupIterator V8_FINAL BASE_EMBEDDED {
16 public:
17 enum Type {
rossberg 2014/06/11 15:37:00 Can we not call this Type?
Toon Verwaest 2014/06/11 17:32:18 Renamed to Configuration On 2014/06/11 15:37:00,
18 CHECK_DERIVED = 1 << 0,
19 CHECK_INTERCEPTOR = 1 << 1,
20 CHECK_ACCESS_CHECK = 1 << 2,
21 CHECK_OWN_REAL = 0,
22 CHECK_ALL = CHECK_DERIVED | CHECK_INTERCEPTOR | CHECK_ACCESS_CHECK,
23 SKIP_INTERCEPTOR = CHECK_ALL ^ CHECK_INTERCEPTOR
24 };
25
26 enum State {
27 NOT_FOUND,
28 PROPERTY,
29 INTERCEPTOR,
30 ACCESS_CHECK,
31 JSPROXY
32 };
33
34 enum PropertyType {
rossberg 2014/06/11 15:37:00 PropertyKind, perhaps?
Toon Verwaest 2014/06/11 17:32:18 Done.
35 DATA,
36 ACCESSORS
rossberg 2014/06/11 15:37:00 Spec says "accessor property", so I'd drop the plu
Toon Verwaest 2014/06/11 17:32:18 Done.
37 };
38
39 enum PropertyEncoding {
40 DICTIONARY,
41 DESCRIPTOR
42 };
43
44 LookupIterator(Handle<Object> receiver,
45 Handle<Name> name,
46 Type type = CHECK_ALL)
47 : type_(type),
48 state_(NOT_FOUND),
49 property_type_(DATA),
50 property_encoding_(DESCRIPTOR),
51 property_details_(NONE, NONEXISTENT, Representation::None()),
52 isolate_(name->GetIsolate()),
53 name_(name),
54 maybe_receiver_(receiver),
55 number_(DescriptorArray::kNotFound) {
56 Handle<JSReceiver> origin = GetOrigin();
57 holder_map_ = handle(origin->map());
58 maybe_holder_ = origin;
59 Next();
60 }
61
62 LookupIterator(Handle<Object> receiver,
63 Handle<Name> name,
64 Handle<JSReceiver> holder,
65 Type type = CHECK_ALL)
66 : type_(type),
67 state_(NOT_FOUND),
68 property_type_(DATA),
69 property_encoding_(DESCRIPTOR),
70 property_details_(NONE, NONEXISTENT, Representation::None()),
71 isolate_(name->GetIsolate()),
72 name_(name),
73 holder_map_(holder->map()),
74 maybe_receiver_(receiver),
75 maybe_holder_(holder),
76 number_(DescriptorArray::kNotFound) {
77 Next();
78 }
79
80 Isolate* isolate() const { return isolate_; }
81 State state() const { return state_; }
82 Handle<Name> name() const { return name_; }
83
84 bool IsFound() const { return state_ != NOT_FOUND; }
85 void Next();
86
87 Heap* heap() const { return isolate_->heap(); }
88 Factory* factory() const { return isolate_->factory(); }
89 Handle<Object> GetReceiver() const {
90 return Handle<Object>::cast(maybe_receiver_.ToHandleChecked());
91 }
92 Handle<JSObject> GetHolder() const {
93 ASSERT(IsFound() && state_ != JSPROXY);
94 return Handle<JSObject>::cast(maybe_holder_.ToHandleChecked());
95 }
96 Handle<JSReceiver> GetOrigin() const;
rossberg 2014/06/11 15:37:00 Hm, origin is a bit confusing as well, as it alrea
rossberg 2014/06/11 16:28:47 Perhaps Root might do?
Toon Verwaest 2014/06/11 17:32:18 Done.
97
98 /* ACCESS_CHECK */
99 bool HasAccess(v8::AccessType access_type) const;
100
101 /* PROPERTY */
102 // 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
104 // answer, and loads extra information about the property.
105 bool HasProperty();
106 PropertyType property_type() const {
107 ASSERT(has_property_);
108 return property_type_;
109 }
110 PropertyDetails property_details() const {
111 ASSERT(has_property_);
112 return property_details_;
113 }
114 Handle<Object> GetAccessors() const;
115 Handle<Object> GetDataValue() const;
116
117 /* JSPROXY */
118
119 Handle<JSProxy> GetJSProxy() const {
120 return Handle<JSProxy>::cast(maybe_holder_.ToHandleChecked());
121 }
122
123 private:
124 Handle<Map> GetReceiverMap() const;
125
126 MUST_USE_RESULT bool NextHolder();
127 void LookupInHolder();
128 Handle<Object> FetchValue() const;
129
130 bool IsBootstrapping() const;
131
132 // Methods that fetch data from the holder ensure they always have a holder.
133 // This means the receiver needs to be present as opposed to just the receiver
134 // map. Other objects in the prototype chain are transitively guaranteed to be
135 // present via the receiver map.
136 bool is_guaranteed_to_have_holder() const {
137 return !maybe_receiver_.is_null();
138 }
139 bool check_interceptor() const {
140 return !IsBootstrapping() && (type_ & CHECK_INTERCEPTOR) != 0;
141 }
142 bool check_derived() const {
143 return (type_ & CHECK_DERIVED) != 0;
144 }
145 bool check_access_check() const {
146 return (type_ & CHECK_ACCESS_CHECK) != 0;
147 }
148
149 Type type_;
150 State state_;
151 bool has_property_;
152 PropertyType property_type_;
153 PropertyEncoding property_encoding_;
154 PropertyDetails property_details_;
155 Isolate* isolate_;
156 Handle<Name> name_;
157 Handle<Map> holder_map_;
158 MaybeHandle<Object> maybe_receiver_;
159 MaybeHandle<JSReceiver> maybe_holder_;
160
161 int number_;
162 };
163
164
165 } } // namespace v8::internal
166
167 #endif // V8_LOOKUP_H_
OLDNEW
« no previous file with comments | « src/json-stringifier.h ('k') | src/lookup.cc » ('j') | src/lookup.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698