blob: 941b51d9ec99dc1eb355ac29a8dff563708e8c97 [file] [log] [blame]
rossberg@chromium.org994edf62012-02-06 10:12:55 +00001// Copyright 2012 the V8 project authors. All rights reserved.
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +00002// Redistribution and use in source and binary forms, with or without
3// modification, are permitted provided that the following conditions are
4// met:
5//
6// * Redistributions of source code must retain the above copyright
7// notice, this list of conditions and the following disclaimer.
8// * Redistributions in binary form must reproduce the above
9// copyright notice, this list of conditions and the following
10// disclaimer in the documentation and/or other materials provided
11// with the distribution.
12// * Neither the name of Google Inc. nor the names of its
13// contributors may be used to endorse or promote products derived
14// from this software without specific prior written permission.
15//
16// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28#ifndef V8_PROPERTY_H_
29#define V8_PROPERTY_H_
30
lrn@chromium.org1c092762011-05-09 09:42:16 +000031#include "allocation.h"
yangguo@chromium.org99aa4902012-07-06 16:21:55 +000032#include "transitions.h"
lrn@chromium.org1c092762011-05-09 09:42:16 +000033
kasperl@chromium.org71affb52009-05-26 05:44:31 +000034namespace v8 {
35namespace internal {
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +000036
37
38// Abstraction for elements in instance-descriptor arrays.
39//
40// Each descriptor has a key, property attributes, property type,
41// property index (in the actual instance-descriptor array) and
42// optionally a piece of data.
43//
44
45class Descriptor BASE_EMBEDDED {
46 public:
47 static int IndexFromValue(Object* value) {
48 return Smi::cast(value)->value();
49 }
50
yangguo@chromium.org4a9f6552013-03-04 14:46:33 +000051 MUST_USE_RESULT MaybeObject* KeyToInternalizedString() {
52 if (!StringShape(key_).IsInternalized()) {
53 MaybeObject* maybe_result = HEAP->InternalizeString(key_);
erik.corry@gmail.combbceb572012-03-09 10:52:05 +000054 if (!maybe_result->To(&key_)) return maybe_result;
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +000055 }
56 return key_;
57 }
58
59 String* GetKey() { return key_; }
60 Object* GetValue() { return value_; }
61 PropertyDetails GetDetails() { return details_; }
62
whesse@chromium.org023421e2010-12-21 12:19:12 +000063#ifdef OBJECT_PRINT
64 void Print(FILE* out);
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +000065#endif
66
67 void SetEnumerationIndex(int index) {
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +000068 details_ = PropertyDetails(details_.attributes(), details_.type(), index);
69 }
70
verwaest@chromium.org06ab2ec2012-10-09 17:00:13 +000071 void SetSortedKeyIndex(int index) { details_ = details_.set_pointer(index); }
yangguo@chromium.org46839fb2012-08-28 09:06:19 +000072
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +000073 private:
74 String* key_;
75 Object* value_;
76 PropertyDetails details_;
77
78 protected:
79 Descriptor() : details_(Smi::FromInt(0)) {}
80
81 void Init(String* key, Object* value, PropertyDetails details) {
82 key_ = key;
83 value_ = value;
84 details_ = details;
85 }
86
87 Descriptor(String* key, Object* value, PropertyDetails details)
88 : key_(key),
89 value_(value),
90 details_(details) { }
91
92 Descriptor(String* key,
93 Object* value,
94 PropertyAttributes attributes,
95 PropertyType type,
rossberg@chromium.org657d53b2012-07-12 11:06:03 +000096 int index)
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +000097 : key_(key),
98 value_(value),
99 details_(attributes, type, index) { }
100
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000101 friend class DescriptorArray;
102};
103
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000104
105class FieldDescriptor: public Descriptor {
106 public:
107 FieldDescriptor(String* key,
108 int field_index,
109 PropertyAttributes attributes,
jkummerow@chromium.org28583c92012-07-16 11:31:55 +0000110 int index = 0)
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000111 : Descriptor(key, Smi::FromInt(field_index), attributes, FIELD, index) {}
112};
113
114
115class ConstantFunctionDescriptor: public Descriptor {
116 public:
117 ConstantFunctionDescriptor(String* key,
118 JSFunction* function,
119 PropertyAttributes attributes,
rossberg@chromium.org657d53b2012-07-12 11:06:03 +0000120 int index)
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000121 : Descriptor(key, function, attributes, CONSTANT_FUNCTION, index) {}
122};
123
124
125class CallbacksDescriptor: public Descriptor {
126 public:
127 CallbacksDescriptor(String* key,
ager@chromium.orgea91cc52011-05-23 06:06:11 +0000128 Object* foreign,
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000129 PropertyAttributes attributes,
jkummerow@chromium.org28583c92012-07-16 11:31:55 +0000130 int index = 0)
ager@chromium.orgea91cc52011-05-23 06:06:11 +0000131 : Descriptor(key, foreign, attributes, CALLBACKS, index) {}
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000132};
133
134
yangguo@chromium.orgeeb44b62012-11-13 13:56:09 +0000135// Holds a property index value distinguishing if it is a field index or an
136// index inside the object header.
137class PropertyIndex {
138 public:
139 static PropertyIndex NewFieldIndex(int index) {
140 return PropertyIndex(index, false);
141 }
142 static PropertyIndex NewHeaderIndex(int index) {
143 return PropertyIndex(index, true);
144 }
145
146 bool is_field_index() { return (index_ & kHeaderIndexBit) == 0; }
147 bool is_header_index() { return (index_ & kHeaderIndexBit) != 0; }
148
149 int field_index() {
150 ASSERT(is_field_index());
151 return value();
152 }
153 int header_index() {
154 ASSERT(is_header_index());
155 return value();
156 }
157
yangguo@chromium.org4a9f6552013-03-04 14:46:33 +0000158 bool is_inobject(Handle<JSObject> holder) {
159 if (is_header_index()) return true;
160 return field_index() < holder->map()->inobject_properties();
161 }
162
163 int translate(Handle<JSObject> holder) {
164 if (is_header_index()) return header_index();
165 int index = field_index() - holder->map()->inobject_properties();
166 if (index >= 0) return index;
167 return index + holder->map()->instance_size() / kPointerSize;
168 }
169
yangguo@chromium.orgeeb44b62012-11-13 13:56:09 +0000170 private:
171 static const int kHeaderIndexBit = 1 << 31;
172 static const int kIndexMask = ~kHeaderIndexBit;
173
174 int value() { return index_ & kIndexMask; }
175
176 PropertyIndex(int index, bool is_header_based)
177 : index_(index | (is_header_based ? kHeaderIndexBit : 0)) {
178 ASSERT(index <= kIndexMask);
179 }
180
181 int index_;
182};
183
184
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000185class LookupResult BASE_EMBEDDED {
186 public:
erik.corry@gmail.com394dbcf2011-10-27 07:38:48 +0000187 explicit LookupResult(Isolate* isolate)
188 : isolate_(isolate),
189 next_(isolate->top_lookup_result()),
190 lookup_type_(NOT_FOUND),
191 holder_(NULL),
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000192 cacheable_(true),
yangguo@chromium.orgde0db002012-06-22 13:44:28 +0000193 details_(NONE, NONEXISTENT) {
erik.corry@gmail.com394dbcf2011-10-27 07:38:48 +0000194 isolate->SetTopLookupResult(this);
195 }
196
197 ~LookupResult() {
hpayer@chromium.org8432c912013-02-28 15:55:26 +0000198 ASSERT(isolate()->top_lookup_result() == this);
199 isolate()->SetTopLookupResult(next_);
erik.corry@gmail.com394dbcf2011-10-27 07:38:48 +0000200 }
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000201
hpayer@chromium.org8432c912013-02-28 15:55:26 +0000202 Isolate* isolate() const { return isolate_; }
203
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000204 void DescriptorResult(JSObject* holder, PropertyDetails details, int number) {
205 lookup_type_ = DESCRIPTOR_TYPE;
206 holder_ = holder;
207 details_ = details;
208 number_ = number;
209 }
210
yangguo@chromium.org99aa4902012-07-06 16:21:55 +0000211 void TransitionResult(JSObject* holder, int number) {
212 lookup_type_ = TRANSITION_TYPE;
213 details_ = PropertyDetails(NONE, TRANSITION);
214 holder_ = holder;
215 number_ = number;
216 }
217
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000218 void DictionaryResult(JSObject* holder, int entry) {
219 lookup_type_ = DICTIONARY_TYPE;
220 holder_ = holder;
221 details_ = holder->property_dictionary()->DetailsAt(entry);
222 number_ = entry;
223 }
224
erik.corry@gmail.comc3b670f2011-10-05 21:44:48 +0000225 void HandlerResult(JSProxy* proxy) {
kmillikin@chromium.orgc53e10d2011-05-18 09:12:58 +0000226 lookup_type_ = HANDLER_TYPE;
erik.corry@gmail.comc3b670f2011-10-05 21:44:48 +0000227 holder_ = proxy;
kmillikin@chromium.orgc53e10d2011-05-18 09:12:58 +0000228 details_ = PropertyDetails(NONE, HANDLER);
whesse@chromium.org030d38e2011-07-13 13:23:34 +0000229 cacheable_ = false;
kmillikin@chromium.orgc53e10d2011-05-18 09:12:58 +0000230 }
231
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000232 void InterceptorResult(JSObject* holder) {
233 lookup_type_ = INTERCEPTOR_TYPE;
234 holder_ = holder;
235 details_ = PropertyDetails(NONE, INTERCEPTOR);
236 }
237
238 void NotFound() {
239 lookup_type_ = NOT_FOUND;
yangguo@chromium.orgde0db002012-06-22 13:44:28 +0000240 details_ = PropertyDetails(NONE, NONEXISTENT);
erik.corry@gmail.com394dbcf2011-10-27 07:38:48 +0000241 holder_ = NULL;
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000242 }
243
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000244 JSObject* holder() {
ager@chromium.org5c838252010-02-19 08:53:10 +0000245 ASSERT(IsFound());
erik.corry@gmail.comc3b670f2011-10-05 21:44:48 +0000246 return JSObject::cast(holder_);
247 }
248
249 JSProxy* proxy() {
250 ASSERT(IsFound());
251 return JSProxy::cast(holder_);
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000252 }
253
254 PropertyType type() {
ager@chromium.org5c838252010-02-19 08:53:10 +0000255 ASSERT(IsFound());
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000256 return details_.type();
257 }
258
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000259 PropertyAttributes GetAttributes() {
yangguo@chromium.org99aa4902012-07-06 16:21:55 +0000260 ASSERT(!IsTransition());
ager@chromium.org5c838252010-02-19 08:53:10 +0000261 ASSERT(IsFound());
yangguo@chromium.org99aa4902012-07-06 16:21:55 +0000262 ASSERT(details_.type() != NONEXISTENT);
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000263 return details_.attributes();
264 }
265
266 PropertyDetails GetPropertyDetails() {
yangguo@chromium.org99aa4902012-07-06 16:21:55 +0000267 ASSERT(!IsTransition());
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000268 return details_;
269 }
270
yangguo@chromium.orgde0db002012-06-22 13:44:28 +0000271 bool IsFastPropertyType() {
272 ASSERT(IsFound());
yangguo@chromium.org99aa4902012-07-06 16:21:55 +0000273 return IsTransition() || type() != NORMAL;
274 }
275
276 // Property callbacks does not include transitions to callbacks.
277 bool IsPropertyCallbacks() {
278 ASSERT(!(details_.type() == CALLBACKS && !IsFound()));
279 return details_.type() == CALLBACKS;
280 }
281
yangguo@chromium.orgde0db002012-06-22 13:44:28 +0000282 bool IsReadOnly() {
283 ASSERT(IsFound());
yangguo@chromium.org99aa4902012-07-06 16:21:55 +0000284 ASSERT(!IsTransition());
285 ASSERT(details_.type() != NONEXISTENT);
yangguo@chromium.orgde0db002012-06-22 13:44:28 +0000286 return details_.IsReadOnly();
287 }
288
yangguo@chromium.orgde0db002012-06-22 13:44:28 +0000289 bool IsField() {
290 ASSERT(!(details_.type() == FIELD && !IsFound()));
291 return details_.type() == FIELD;
292 }
293
294 bool IsNormal() {
295 ASSERT(!(details_.type() == NORMAL && !IsFound()));
296 return details_.type() == NORMAL;
297 }
298
299 bool IsConstantFunction() {
300 ASSERT(!(details_.type() == CONSTANT_FUNCTION && !IsFound()));
301 return details_.type() == CONSTANT_FUNCTION;
302 }
303
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000304 bool IsDontDelete() { return details_.IsDontDelete(); }
305 bool IsDontEnum() { return details_.IsDontEnum(); }
kasperl@chromium.org2abc4502009-07-02 07:00:29 +0000306 bool IsDeleted() { return details_.IsDeleted(); }
ager@chromium.org5c838252010-02-19 08:53:10 +0000307 bool IsFound() { return lookup_type_ != NOT_FOUND; }
yangguo@chromium.org99aa4902012-07-06 16:21:55 +0000308 bool IsTransition() { return lookup_type_ == TRANSITION_TYPE; }
kmillikin@chromium.orgc53e10d2011-05-18 09:12:58 +0000309 bool IsHandler() { return lookup_type_ == HANDLER_TYPE; }
yangguo@chromium.orgde0db002012-06-22 13:44:28 +0000310 bool IsInterceptor() { return lookup_type_ == INTERCEPTOR_TYPE; }
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000311
ulan@chromium.org9a21ec42012-03-06 08:42:24 +0000312 // Is the result is a property excluding transitions and the null descriptor?
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000313 bool IsProperty() {
yangguo@chromium.org99aa4902012-07-06 16:21:55 +0000314 return IsFound() && !IsTransition();
ager@chromium.org5c838252010-02-19 08:53:10 +0000315 }
316
yangguo@chromium.orga6bbcc82012-12-21 12:35:02 +0000317 bool IsDataProperty() {
318 switch (type()) {
319 case FIELD:
320 case NORMAL:
321 case CONSTANT_FUNCTION:
322 return true;
323 case CALLBACKS: {
324 Object* callback = GetCallbackObject();
325 return callback->IsAccessorInfo() || callback->IsForeign();
326 }
327 case HANDLER:
328 case INTERCEPTOR:
329 case TRANSITION:
330 case NONEXISTENT:
331 return false;
332 }
333 UNREACHABLE();
334 return false;
335 }
336
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000337 bool IsCacheable() { return cacheable_; }
338 void DisallowCaching() { cacheable_ = false; }
339
ager@chromium.org3a37e9b2009-04-27 09:26:21 +0000340 Object* GetLazyValue() {
341 switch (type()) {
342 case FIELD:
yangguo@chromium.orgeeb44b62012-11-13 13:56:09 +0000343 return holder()->FastPropertyAt(GetFieldIndex().field_index());
kasperl@chromium.org2abc4502009-07-02 07:00:29 +0000344 case NORMAL: {
345 Object* value;
346 value = holder()->property_dictionary()->ValueAt(GetDictionaryEntry());
347 if (holder()->IsGlobalObject()) {
348 value = JSGlobalPropertyCell::cast(value)->value();
349 }
350 return value;
351 }
ager@chromium.org3a37e9b2009-04-27 09:26:21 +0000352 case CONSTANT_FUNCTION:
353 return GetConstantFunction();
yangguo@chromium.orga6bbcc82012-12-21 12:35:02 +0000354 case CALLBACKS:
355 case HANDLER:
356 case INTERCEPTOR:
357 case TRANSITION:
358 case NONEXISTENT:
hpayer@chromium.org8432c912013-02-28 15:55:26 +0000359 return isolate()->heap()->the_hole_value();
ager@chromium.org3a37e9b2009-04-27 09:26:21 +0000360 }
yangguo@chromium.orga6bbcc82012-12-21 12:35:02 +0000361 UNREACHABLE();
362 return NULL;
ager@chromium.org3a37e9b2009-04-27 09:26:21 +0000363 }
364
verwaest@chromium.org753aee42012-07-17 16:15:42 +0000365 Map* GetTransitionTarget() {
yangguo@chromium.org99aa4902012-07-06 16:21:55 +0000366 ASSERT(IsTransition());
367 TransitionArray* transitions = holder()->map()->transitions();
verwaest@chromium.org753aee42012-07-17 16:15:42 +0000368 return transitions->GetTarget(number_);
yangguo@chromium.org99aa4902012-07-06 16:21:55 +0000369 }
370
371 PropertyDetails GetTransitionDetails(Map* map) {
372 ASSERT(IsTransition());
373 TransitionArray* transitions = map->transitions();
374 return transitions->GetTargetDetails(number_);
375 }
376
377 PropertyDetails GetTransitionDetails() {
378 return GetTransitionDetails(holder()->map());
379 }
380
381 bool IsTransitionToField(Map* map) {
382 return IsTransition() && GetTransitionDetails(map).type() == FIELD;
383 }
384
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000385 Map* GetTransitionMap() {
yangguo@chromium.org99aa4902012-07-06 16:21:55 +0000386 ASSERT(IsTransition());
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000387 return Map::cast(GetValue());
388 }
389
kasperl@chromium.orga5551262010-12-07 12:49:48 +0000390 Map* GetTransitionMapFromMap(Map* map) {
yangguo@chromium.org99aa4902012-07-06 16:21:55 +0000391 ASSERT(IsTransition());
verwaest@chromium.org753aee42012-07-17 16:15:42 +0000392 return map->transitions()->GetTarget(number_);
kasperl@chromium.orga5551262010-12-07 12:49:48 +0000393 }
394
jkummerow@chromium.org28583c92012-07-16 11:31:55 +0000395 int GetTransitionIndex() {
396 ASSERT(IsTransition());
397 return number_;
398 }
399
verwaest@chromium.org178fb152012-07-18 11:21:48 +0000400 int GetDescriptorIndex() {
401 ASSERT(lookup_type_ == DESCRIPTOR_TYPE);
402 return number_;
403 }
404
yangguo@chromium.orgeeb44b62012-11-13 13:56:09 +0000405 PropertyIndex GetFieldIndex() {
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000406 ASSERT(lookup_type_ == DESCRIPTOR_TYPE);
yangguo@chromium.orgde0db002012-06-22 13:44:28 +0000407 ASSERT(IsField());
yangguo@chromium.orgeeb44b62012-11-13 13:56:09 +0000408 return PropertyIndex::NewFieldIndex(
409 Descriptor::IndexFromValue(GetValue()));
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000410 }
411
kasperl@chromium.orga5551262010-12-07 12:49:48 +0000412 int GetLocalFieldIndexFromMap(Map* map) {
yangguo@chromium.orgde0db002012-06-22 13:44:28 +0000413 ASSERT(IsField());
yangguo@chromium.org99aa4902012-07-06 16:21:55 +0000414 return Descriptor::IndexFromValue(GetValueFromMap(map)) -
kasperl@chromium.orga5551262010-12-07 12:49:48 +0000415 map->inobject_properties();
416 }
417
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000418 int GetDictionaryEntry() {
419 ASSERT(lookup_type_ == DICTIONARY_TYPE);
420 return number_;
421 }
422
423 JSFunction* GetConstantFunction() {
424 ASSERT(type() == CONSTANT_FUNCTION);
425 return JSFunction::cast(GetValue());
426 }
427
kasperl@chromium.orga5551262010-12-07 12:49:48 +0000428 JSFunction* GetConstantFunctionFromMap(Map* map) {
kasperl@chromium.orga5551262010-12-07 12:49:48 +0000429 ASSERT(type() == CONSTANT_FUNCTION);
yangguo@chromium.org99aa4902012-07-06 16:21:55 +0000430 return JSFunction::cast(GetValueFromMap(map));
kasperl@chromium.orga5551262010-12-07 12:49:48 +0000431 }
432
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000433 Object* GetCallbackObject() {
mstarzinger@chromium.org71fc3462013-02-27 09:34:27 +0000434 ASSERT(type() == CALLBACKS && !IsTransition());
verwaest@chromium.org753aee42012-07-17 16:15:42 +0000435 return GetValue();
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000436 }
437
whesse@chromium.org023421e2010-12-21 12:19:12 +0000438#ifdef OBJECT_PRINT
439 void Print(FILE* out);
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000440#endif
441
442 Object* GetValue() {
443 if (lookup_type_ == DESCRIPTOR_TYPE) {
yangguo@chromium.org99aa4902012-07-06 16:21:55 +0000444 return GetValueFromMap(holder()->map());
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000445 }
446 // In the dictionary case, the data is held in the value field.
447 ASSERT(lookup_type_ == DICTIONARY_TYPE);
kasperl@chromium.org2abc4502009-07-02 07:00:29 +0000448 return holder()->GetNormalizedProperty(this);
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000449 }
450
yangguo@chromium.org99aa4902012-07-06 16:21:55 +0000451 Object* GetValueFromMap(Map* map) const {
452 ASSERT(lookup_type_ == DESCRIPTOR_TYPE);
verwaest@chromium.org06ab2ec2012-10-09 17:00:13 +0000453 ASSERT(number_ < map->NumberOfOwnDescriptors());
yangguo@chromium.org99aa4902012-07-06 16:21:55 +0000454 return map->instance_descriptors()->GetValue(number_);
455 }
456
erik.corry@gmail.com394dbcf2011-10-27 07:38:48 +0000457 void Iterate(ObjectVisitor* visitor);
458
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000459 private:
erik.corry@gmail.com394dbcf2011-10-27 07:38:48 +0000460 Isolate* isolate_;
461 LookupResult* next_;
462
kmillikin@chromium.orgc53e10d2011-05-18 09:12:58 +0000463 // Where did we find the result;
464 enum {
465 NOT_FOUND,
466 DESCRIPTOR_TYPE,
yangguo@chromium.org99aa4902012-07-06 16:21:55 +0000467 TRANSITION_TYPE,
kmillikin@chromium.orgc53e10d2011-05-18 09:12:58 +0000468 DICTIONARY_TYPE,
469 HANDLER_TYPE,
mstarzinger@chromium.org71fc3462013-02-27 09:34:27 +0000470 INTERCEPTOR_TYPE
kmillikin@chromium.orgc53e10d2011-05-18 09:12:58 +0000471 } lookup_type_;
472
erik.corry@gmail.comc3b670f2011-10-05 21:44:48 +0000473 JSReceiver* holder_;
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000474 int number_;
475 bool cacheable_;
476 PropertyDetails details_;
477};
478
479
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000480} } // namespace v8::internal
481
482#endif // V8_PROPERTY_H_