OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
94 | 94 |
95 friend class DescriptorArray; | 95 friend class DescriptorArray; |
96 }; | 96 }; |
97 | 97 |
98 | 98 |
99 class FieldDescriptor: public Descriptor { | 99 class FieldDescriptor: public Descriptor { |
100 public: | 100 public: |
101 FieldDescriptor(Name* key, | 101 FieldDescriptor(Name* key, |
102 int field_index, | 102 int field_index, |
103 PropertyAttributes attributes, | 103 PropertyAttributes attributes, |
104 Representation representation) | 104 Representation representation); |
105 : Descriptor(key, Smi::FromInt(0), attributes, | 105 FieldDescriptor(Name* key, |
106 FIELD, representation, field_index) {} | 106 int field_index, |
107 HeapType* field_type, | |
108 PropertyAttributes attributes, | |
109 Representation representation); | |
107 }; | 110 }; |
108 | 111 |
109 | 112 |
110 class ConstantDescriptor: public Descriptor { | 113 class ConstantDescriptor: public Descriptor { |
111 public: | 114 public: |
112 ConstantDescriptor(Name* key, | 115 ConstantDescriptor(Name* key, |
113 Object* value, | 116 Object* value, |
114 PropertyAttributes attributes) | 117 PropertyAttributes attributes) |
115 : Descriptor(key, value, attributes, CONSTANT, | 118 : Descriptor(key, value, attributes, CONSTANT, |
116 value->OptimalRepresentation()) {} | 119 value->OptimalRepresentation()) {} |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
198 Isolate* isolate() const { return isolate_; } | 201 Isolate* isolate() const { return isolate_; } |
199 | 202 |
200 void DescriptorResult(JSObject* holder, PropertyDetails details, int number) { | 203 void DescriptorResult(JSObject* holder, PropertyDetails details, int number) { |
201 lookup_type_ = DESCRIPTOR_TYPE; | 204 lookup_type_ = DESCRIPTOR_TYPE; |
202 holder_ = holder; | 205 holder_ = holder; |
203 transition_ = NULL; | 206 transition_ = NULL; |
204 details_ = details; | 207 details_ = details; |
205 number_ = number; | 208 number_ = number; |
206 } | 209 } |
207 | 210 |
208 bool CanHoldValue(Handle<Object> value) { | 211 bool CanHoldValue(Handle<Object> value) const; |
209 if (IsNormal()) return true; | |
210 ASSERT(!IsTransition()); | |
211 return value->FitsRepresentation(details_.representation()); | |
212 } | |
213 | 212 |
214 void TransitionResult(JSObject* holder, Map* target) { | 213 void TransitionResult(JSObject* holder, Map* target) { |
215 lookup_type_ = TRANSITION_TYPE; | 214 lookup_type_ = TRANSITION_TYPE; |
216 details_ = PropertyDetails(NONE, TRANSITION, Representation::None()); | 215 details_ = PropertyDetails(NONE, TRANSITION, Representation::None()); |
217 holder_ = holder; | 216 holder_ = holder; |
218 transition_ = target; | 217 transition_ = target; |
219 number_ = 0xAAAA; | 218 number_ = 0xAAAA; |
220 } | 219 } |
221 | 220 |
222 void DictionaryResult(JSObject* holder, int entry) { | 221 void DictionaryResult(JSObject* holder, int entry) { |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
447 Object* GetValue() const { | 446 Object* GetValue() const { |
448 if (lookup_type_ == DESCRIPTOR_TYPE) { | 447 if (lookup_type_ == DESCRIPTOR_TYPE) { |
449 return GetValueFromMap(holder()->map()); | 448 return GetValueFromMap(holder()->map()); |
450 } | 449 } |
451 // In the dictionary case, the data is held in the value field. | 450 // In the dictionary case, the data is held in the value field. |
452 ASSERT(lookup_type_ == DICTIONARY_TYPE); | 451 ASSERT(lookup_type_ == DICTIONARY_TYPE); |
453 return holder()->GetNormalizedProperty(this); | 452 return holder()->GetNormalizedProperty(this); |
454 } | 453 } |
455 | 454 |
456 Object* GetValueFromMap(Map* map) const { | 455 Object* GetValueFromMap(Map* map) const { |
457 ASSERT(lookup_type_ == DESCRIPTOR_TYPE); | 456 if (lookup_type_ == DESCRIPTOR_TYPE) { |
458 ASSERT(number_ < map->NumberOfOwnDescriptors()); | 457 ASSERT(number_ < map->NumberOfOwnDescriptors()); |
459 return map->instance_descriptors()->GetValue(number_); | 458 return map->instance_descriptors()->GetValue(number_); |
459 } | |
460 ASSERT(lookup_type_ == TRANSITION_TYPE); | |
461 return transition_->instance_descriptors()->GetValue( | |
462 transition_->LastAdded()); | |
460 } | 463 } |
461 | 464 |
462 int GetFieldIndexFromMap(Map* map) const { | 465 int GetFieldIndexFromMap(Map* map) const { |
463 ASSERT(lookup_type_ == DESCRIPTOR_TYPE); | 466 ASSERT(lookup_type_ == DESCRIPTOR_TYPE); |
464 ASSERT(number_ < map->NumberOfOwnDescriptors()); | 467 ASSERT(number_ < map->NumberOfOwnDescriptors()); |
465 return map->instance_descriptors()->GetFieldIndex(number_); | 468 return map->instance_descriptors()->GetFieldIndex(number_); |
466 } | 469 } |
467 | 470 |
471 HeapType* GetFieldType() const { | |
472 return GetFieldTypeFromMap(holder()->map()); | |
Toon Verwaest
2014/03/21 14:33:37
Aarg, this is ugly. We really need to cache holder
Benedikt Meurer
2014/04/11 11:12:00
ACK.
| |
473 } | |
474 | |
475 HeapType* GetFieldTypeFromMap(Map* map) const; | |
476 | |
477 Map* GetFieldOwner() const { | |
478 return GetFieldOwnerFromMap(holder()->map()); | |
479 } | |
480 | |
481 Map* GetFieldOwnerFromMap(Map* map) const { | |
482 ASSERT(lookup_type_ == DESCRIPTOR_TYPE); | |
483 ASSERT(number_ < map->NumberOfOwnDescriptors()); | |
484 return map->FindFieldOwner(number_); | |
485 } | |
486 | |
468 void Iterate(ObjectVisitor* visitor); | 487 void Iterate(ObjectVisitor* visitor); |
469 | 488 |
470 private: | 489 private: |
471 Isolate* isolate_; | 490 Isolate* isolate_; |
472 LookupResult* next_; | 491 LookupResult* next_; |
473 | 492 |
474 // Where did we find the result; | 493 // Where did we find the result; |
475 enum { | 494 enum { |
476 NOT_FOUND, | 495 NOT_FOUND, |
477 DESCRIPTOR_TYPE, | 496 DESCRIPTOR_TYPE, |
478 TRANSITION_TYPE, | 497 TRANSITION_TYPE, |
479 DICTIONARY_TYPE, | 498 DICTIONARY_TYPE, |
480 HANDLER_TYPE, | 499 HANDLER_TYPE, |
481 INTERCEPTOR_TYPE | 500 INTERCEPTOR_TYPE |
482 } lookup_type_; | 501 } lookup_type_; |
483 | 502 |
484 JSReceiver* holder_; | 503 JSReceiver* holder_; |
485 Map* transition_; | 504 Map* transition_; |
486 int number_; | 505 int number_; |
487 bool cacheable_; | 506 bool cacheable_; |
488 PropertyDetails details_; | 507 PropertyDetails details_; |
489 }; | 508 }; |
490 | 509 |
491 | 510 |
492 } } // namespace v8::internal | 511 } } // namespace v8::internal |
493 | 512 |
494 #endif // V8_PROPERTY_H_ | 513 #endif // V8_PROPERTY_H_ |
OLD | NEW |