| OLD | NEW |
| 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 "src/factory.h" | 8 #include "src/factory.h" |
| 9 #include "src/field-index.h" | 9 #include "src/field-index.h" |
| 10 #include "src/field-index-inl.h" | 10 #include "src/field-index-inl.h" |
| 11 #include "src/isolate.h" | 11 #include "src/isolate.h" |
| 12 #include "src/ostreams.h" |
| 12 #include "src/types.h" | 13 #include "src/types.h" |
| 13 | 14 |
| 14 namespace v8 { | 15 namespace v8 { |
| 15 namespace internal { | 16 namespace internal { |
| 16 | 17 |
| 17 // Abstraction for elements in instance-descriptor arrays. | 18 // Abstraction for elements in instance-descriptor arrays. |
| 18 // | 19 // |
| 19 // Each descriptor has a key, property attributes, property type, | 20 // Each descriptor has a key, property attributes, property type, |
| 20 // property index (in the actual instance-descriptor array) and | 21 // property index (in the actual instance-descriptor array) and |
| 21 // optionally a piece of data. | 22 // optionally a piece of data. |
| 22 class Descriptor BASE_EMBEDDED { | 23 class Descriptor BASE_EMBEDDED { |
| 23 public: | 24 public: |
| 24 void KeyToUniqueName() { | 25 void KeyToUniqueName() { |
| 25 if (!key_->IsUniqueName()) { | 26 if (!key_->IsUniqueName()) { |
| 26 key_ = key_->GetIsolate()->factory()->InternalizeString( | 27 key_ = key_->GetIsolate()->factory()->InternalizeString( |
| 27 Handle<String>::cast(key_)); | 28 Handle<String>::cast(key_)); |
| 28 } | 29 } |
| 29 } | 30 } |
| 30 | 31 |
| 31 Handle<Name> GetKey() { return key_; } | 32 Handle<Name> GetKey() const { return key_; } |
| 32 Handle<Object> GetValue() { return value_; } | 33 Handle<Object> GetValue() const { return value_; } |
| 33 PropertyDetails GetDetails() { return details_; } | 34 PropertyDetails GetDetails() const { return details_; } |
| 34 | |
| 35 #ifdef OBJECT_PRINT | |
| 36 void Print(FILE* out); | |
| 37 #endif | |
| 38 | 35 |
| 39 void SetSortedKeyIndex(int index) { details_ = details_.set_pointer(index); } | 36 void SetSortedKeyIndex(int index) { details_ = details_.set_pointer(index); } |
| 40 | 37 |
| 41 private: | 38 private: |
| 42 Handle<Name> key_; | 39 Handle<Name> key_; |
| 43 Handle<Object> value_; | 40 Handle<Object> value_; |
| 44 PropertyDetails details_; | 41 PropertyDetails details_; |
| 45 | 42 |
| 46 protected: | 43 protected: |
| 47 Descriptor() : details_(Smi::FromInt(0)) {} | 44 Descriptor() : details_(Smi::FromInt(0)) {} |
| (...skipping 17 matching lines...) Expand all Loading... |
| 65 int field_index = 0) | 62 int field_index = 0) |
| 66 : key_(key), | 63 : key_(key), |
| 67 value_(value), | 64 value_(value), |
| 68 details_(attributes, type, representation, field_index) { } | 65 details_(attributes, type, representation, field_index) { } |
| 69 | 66 |
| 70 friend class DescriptorArray; | 67 friend class DescriptorArray; |
| 71 friend class Map; | 68 friend class Map; |
| 72 }; | 69 }; |
| 73 | 70 |
| 74 | 71 |
| 72 OStream& operator<<(OStream& os, const Descriptor& d); |
| 73 |
| 74 |
| 75 class FieldDescriptor V8_FINAL : public Descriptor { | 75 class FieldDescriptor V8_FINAL : public Descriptor { |
| 76 public: | 76 public: |
| 77 FieldDescriptor(Handle<Name> key, | 77 FieldDescriptor(Handle<Name> key, |
| 78 int field_index, | 78 int field_index, |
| 79 PropertyAttributes attributes, | 79 PropertyAttributes attributes, |
| 80 Representation representation) | 80 Representation representation) |
| 81 : Descriptor(key, HeapType::Any(key->GetIsolate()), attributes, | 81 : Descriptor(key, HeapType::Any(key->GetIsolate()), attributes, |
| 82 FIELD, representation, field_index) {} | 82 FIELD, representation, field_index) {} |
| 83 FieldDescriptor(Handle<Name> key, | 83 FieldDescriptor(Handle<Name> key, |
| 84 int field_index, | 84 int field_index, |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 ASSERT(type() == CONSTANT); | 401 ASSERT(type() == CONSTANT); |
| 402 return GetValue(); | 402 return GetValue(); |
| 403 } | 403 } |
| 404 | 404 |
| 405 Object* GetCallbackObject() const { | 405 Object* GetCallbackObject() const { |
| 406 ASSERT(!IsTransition()); | 406 ASSERT(!IsTransition()); |
| 407 ASSERT(type() == CALLBACKS); | 407 ASSERT(type() == CALLBACKS); |
| 408 return GetValue(); | 408 return GetValue(); |
| 409 } | 409 } |
| 410 | 410 |
| 411 #ifdef OBJECT_PRINT | |
| 412 void Print(FILE* out); | |
| 413 #endif | |
| 414 | |
| 415 Object* GetValue() const { | 411 Object* GetValue() const { |
| 416 if (lookup_type_ == DESCRIPTOR_TYPE) { | 412 if (lookup_type_ == DESCRIPTOR_TYPE) { |
| 417 return GetValueFromMap(holder()->map()); | 413 return GetValueFromMap(holder()->map()); |
| 418 } else if (lookup_type_ == TRANSITION_TYPE) { | 414 } else if (lookup_type_ == TRANSITION_TYPE) { |
| 419 return GetValueFromMap(transition_); | 415 return GetValueFromMap(transition_); |
| 420 } | 416 } |
| 421 // In the dictionary case, the data is held in the value field. | 417 // In the dictionary case, the data is held in the value field. |
| 422 ASSERT(lookup_type_ == DICTIONARY_TYPE); | 418 ASSERT(lookup_type_ == DICTIONARY_TYPE); |
| 423 return holder()->GetNormalizedProperty(this); | 419 return holder()->GetNormalizedProperty(this); |
| 424 } | 420 } |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 480 INTERCEPTOR_TYPE | 476 INTERCEPTOR_TYPE |
| 481 } lookup_type_; | 477 } lookup_type_; |
| 482 | 478 |
| 483 JSReceiver* holder_; | 479 JSReceiver* holder_; |
| 484 Map* transition_; | 480 Map* transition_; |
| 485 int number_; | 481 int number_; |
| 486 bool cacheable_; | 482 bool cacheable_; |
| 487 PropertyDetails details_; | 483 PropertyDetails details_; |
| 488 }; | 484 }; |
| 489 | 485 |
| 486 |
| 487 OStream& operator<<(OStream& os, const LookupResult& r); |
| 490 } } // namespace v8::internal | 488 } } // namespace v8::internal |
| 491 | 489 |
| 492 #endif // V8_PROPERTY_H_ | 490 #endif // V8_PROPERTY_H_ |
| OLD | NEW |