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

Side by Side Diff: src/property.h

Issue 936813002: Contribution of PowerPC port (continuation of 422063005) - PPC dir update 2 (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 10 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/ppc/macro-assembler-ppc.cc ('k') | src/property.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_PROPERTY_H_ 5 #ifndef V8_PROPERTY_H_
6 #define V8_PROPERTY_H_ 6 #define V8_PROPERTY_H_
7 7
8 #include <iosfwd> 8 #include <iosfwd>
9 9
10 #include "src/factory.h" 10 #include "src/factory.h"
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 97
98 class AccessorConstantDescriptor FINAL : public Descriptor { 98 class AccessorConstantDescriptor FINAL : public Descriptor {
99 public: 99 public:
100 AccessorConstantDescriptor(Handle<Name> key, Handle<Object> foreign, 100 AccessorConstantDescriptor(Handle<Name> key, Handle<Object> foreign,
101 PropertyAttributes attributes) 101 PropertyAttributes attributes)
102 : Descriptor(key, foreign, attributes, ACCESSOR_CONSTANT, 102 : Descriptor(key, foreign, attributes, ACCESSOR_CONSTANT,
103 Representation::Tagged()) {} 103 Representation::Tagged()) {}
104 }; 104 };
105 105
106 106
107 class LookupResult FINAL BASE_EMBEDDED {
108 public:
109 explicit LookupResult(Isolate* isolate)
110 : isolate_(isolate),
111 next_(isolate->top_lookup_result()),
112 lookup_type_(NOT_FOUND),
113 holder_(NULL),
114 transition_(NULL),
115 details_(NONE, DATA, Representation::None()) {
116 isolate->set_top_lookup_result(this);
117 }
118
119 ~LookupResult() {
120 DCHECK(isolate()->top_lookup_result() == this);
121 isolate()->set_top_lookup_result(next_);
122 }
123
124 Isolate* isolate() const { return isolate_; }
125
126 void DescriptorResult(JSObject* holder, PropertyDetails details, int number) {
127 lookup_type_ = DESCRIPTOR_TYPE;
128 holder_ = holder;
129 transition_ = NULL;
130 details_ = details;
131 number_ = number;
132 }
133
134 void TransitionResult(JSObject* holder, Map* target) {
135 lookup_type_ = TRANSITION_TYPE;
136 number_ = target->LastAdded();
137 details_ = target->instance_descriptors()->GetDetails(number_);
138 holder_ = holder;
139 transition_ = target;
140 }
141
142 void NotFound() {
143 lookup_type_ = NOT_FOUND;
144 details_ = PropertyDetails(NONE, DATA, 0);
145 holder_ = NULL;
146 transition_ = NULL;
147 }
148
149 Representation representation() const {
150 DCHECK(IsFound());
151 return details_.representation();
152 }
153
154 // Property callbacks does not include transitions to callbacks.
155 bool IsAccessorConstant() const {
156 return !IsTransition() && details_.type() == ACCESSOR_CONSTANT;
157 }
158
159 bool IsReadOnly() const {
160 DCHECK(IsFound());
161 return details_.IsReadOnly();
162 }
163
164 bool IsData() const {
165 return lookup_type_ == DESCRIPTOR_TYPE && details_.type() == DATA;
166 }
167
168 bool IsDataConstant() const {
169 return lookup_type_ == DESCRIPTOR_TYPE && details_.type() == DATA_CONSTANT;
170 }
171
172 bool IsConfigurable() const { return details_.IsConfigurable(); }
173 bool IsFound() const { return lookup_type_ != NOT_FOUND; }
174 bool IsTransition() const { return lookup_type_ == TRANSITION_TYPE; }
175
176 // Is the result is a property excluding transitions and the null descriptor?
177 bool IsProperty() const {
178 return IsFound() && !IsTransition();
179 }
180
181 Map* GetTransitionTarget() const {
182 DCHECK(IsTransition());
183 return transition_;
184 }
185
186 bool IsTransitionToData() const {
187 return IsTransition() && details_.type() == DATA;
188 }
189
190 int GetLocalFieldIndexFromMap(Map* map) const {
191 return GetFieldIndexFromMap(map) - map->inobject_properties();
192 }
193
194 Object* GetConstantFromMap(Map* map) const {
195 DCHECK(details_.type() == DATA_CONSTANT);
196 return GetValueFromMap(map);
197 }
198
199 Object* GetValueFromMap(Map* map) const {
200 DCHECK(lookup_type_ == DESCRIPTOR_TYPE ||
201 lookup_type_ == TRANSITION_TYPE);
202 DCHECK(number_ < map->NumberOfOwnDescriptors());
203 return map->instance_descriptors()->GetValue(number_);
204 }
205
206 int GetFieldIndexFromMap(Map* map) const {
207 DCHECK(lookup_type_ == DESCRIPTOR_TYPE ||
208 lookup_type_ == TRANSITION_TYPE);
209 DCHECK(number_ < map->NumberOfOwnDescriptors());
210 return map->instance_descriptors()->GetFieldIndex(number_);
211 }
212
213 HeapType* GetFieldTypeFromMap(Map* map) const {
214 DCHECK_NE(NOT_FOUND, lookup_type_);
215 DCHECK(number_ < map->NumberOfOwnDescriptors());
216 return map->instance_descriptors()->GetFieldType(number_);
217 }
218
219 Map* GetFieldOwnerFromMap(Map* map) const {
220 DCHECK(lookup_type_ == DESCRIPTOR_TYPE ||
221 lookup_type_ == TRANSITION_TYPE);
222 DCHECK(number_ < map->NumberOfOwnDescriptors());
223 return map->FindFieldOwner(number_);
224 }
225
226 void Iterate(ObjectVisitor* visitor);
227
228 private:
229 Isolate* isolate_;
230 LookupResult* next_;
231
232 // Where did we find the result;
233 enum { NOT_FOUND, DESCRIPTOR_TYPE, TRANSITION_TYPE } lookup_type_;
234
235 JSReceiver* holder_;
236 Map* transition_;
237 int number_;
238 PropertyDetails details_;
239 };
240
241
242 std::ostream& operator<<(std::ostream& os, const LookupResult& r);
243 } } // namespace v8::internal 107 } } // namespace v8::internal
244 108
245 #endif // V8_PROPERTY_H_ 109 #endif // V8_PROPERTY_H_
OLDNEW
« no previous file with comments | « src/ppc/macro-assembler-ppc.cc ('k') | src/property.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698