| 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 30 matching lines...) Expand all Loading... |
| 41 // property index (in the actual instance-descriptor array) and | 41 // property index (in the actual instance-descriptor array) and |
| 42 // optionally a piece of data. | 42 // optionally a piece of data. |
| 43 // | 43 // |
| 44 | 44 |
| 45 class Descriptor BASE_EMBEDDED { | 45 class Descriptor BASE_EMBEDDED { |
| 46 public: | 46 public: |
| 47 static int IndexFromValue(Object* value) { | 47 static int IndexFromValue(Object* value) { |
| 48 return Smi::cast(value)->value(); | 48 return Smi::cast(value)->value(); |
| 49 } | 49 } |
| 50 | 50 |
| 51 MUST_USE_RESULT MaybeObject* KeyToInternalizedString() { | 51 MUST_USE_RESULT MaybeObject* KeyToUniqueName() { |
| 52 if (!StringShape(key_).IsInternalized()) { | 52 if (!key_->IsUniqueName()) { |
| 53 MaybeObject* maybe_result = HEAP->InternalizeString(key_); | 53 MaybeObject* maybe_result = HEAP->InternalizeString(String::cast(key_)); |
| 54 if (!maybe_result->To(&key_)) return maybe_result; | 54 if (!maybe_result->To(&key_)) return maybe_result; |
| 55 } | 55 } |
| 56 return key_; | 56 return key_; |
| 57 } | 57 } |
| 58 | 58 |
| 59 String* GetKey() { return key_; } | 59 Name* GetKey() { return key_; } |
| 60 Object* GetValue() { return value_; } | 60 Object* GetValue() { return value_; } |
| 61 PropertyDetails GetDetails() { return details_; } | 61 PropertyDetails GetDetails() { return details_; } |
| 62 | 62 |
| 63 #ifdef OBJECT_PRINT | 63 #ifdef OBJECT_PRINT |
| 64 void Print(FILE* out); | 64 void Print(FILE* out); |
| 65 #endif | 65 #endif |
| 66 | 66 |
| 67 void SetEnumerationIndex(int index) { | 67 void SetEnumerationIndex(int index) { |
| 68 details_ = PropertyDetails(details_.attributes(), details_.type(), index); | 68 details_ = PropertyDetails(details_.attributes(), details_.type(), index); |
| 69 } | 69 } |
| 70 | 70 |
| 71 void SetSortedKeyIndex(int index) { details_ = details_.set_pointer(index); } | 71 void SetSortedKeyIndex(int index) { details_ = details_.set_pointer(index); } |
| 72 | 72 |
| 73 private: | 73 private: |
| 74 String* key_; | 74 Name* key_; |
| 75 Object* value_; | 75 Object* value_; |
| 76 PropertyDetails details_; | 76 PropertyDetails details_; |
| 77 | 77 |
| 78 protected: | 78 protected: |
| 79 Descriptor() : details_(Smi::FromInt(0)) {} | 79 Descriptor() : details_(Smi::FromInt(0)) {} |
| 80 | 80 |
| 81 void Init(String* key, Object* value, PropertyDetails details) { | 81 void Init(Name* key, Object* value, PropertyDetails details) { |
| 82 key_ = key; | 82 key_ = key; |
| 83 value_ = value; | 83 value_ = value; |
| 84 details_ = details; | 84 details_ = details; |
| 85 } | 85 } |
| 86 | 86 |
| 87 Descriptor(String* key, Object* value, PropertyDetails details) | 87 Descriptor(Name* key, Object* value, PropertyDetails details) |
| 88 : key_(key), | 88 : key_(key), |
| 89 value_(value), | 89 value_(value), |
| 90 details_(details) { } | 90 details_(details) { } |
| 91 | 91 |
| 92 Descriptor(String* key, | 92 Descriptor(Name* key, |
| 93 Object* value, | 93 Object* value, |
| 94 PropertyAttributes attributes, | 94 PropertyAttributes attributes, |
| 95 PropertyType type, | 95 PropertyType type, |
| 96 int index) | 96 int index) |
| 97 : key_(key), | 97 : key_(key), |
| 98 value_(value), | 98 value_(value), |
| 99 details_(attributes, type, index) { } | 99 details_(attributes, type, index) { } |
| 100 | 100 |
| 101 friend class DescriptorArray; | 101 friend class DescriptorArray; |
| 102 }; | 102 }; |
| 103 | 103 |
| 104 | 104 |
| 105 class FieldDescriptor: public Descriptor { | 105 class FieldDescriptor: public Descriptor { |
| 106 public: | 106 public: |
| 107 FieldDescriptor(String* key, | 107 FieldDescriptor(Name* key, |
| 108 int field_index, | 108 int field_index, |
| 109 PropertyAttributes attributes, | 109 PropertyAttributes attributes, |
| 110 int index = 0) | 110 int index = 0) |
| 111 : Descriptor(key, Smi::FromInt(field_index), attributes, FIELD, index) {} | 111 : Descriptor(key, Smi::FromInt(field_index), attributes, FIELD, index) {} |
| 112 }; | 112 }; |
| 113 | 113 |
| 114 | 114 |
| 115 class ConstantFunctionDescriptor: public Descriptor { | 115 class ConstantFunctionDescriptor: public Descriptor { |
| 116 public: | 116 public: |
| 117 ConstantFunctionDescriptor(String* key, | 117 ConstantFunctionDescriptor(Name* key, |
| 118 JSFunction* function, | 118 JSFunction* function, |
| 119 PropertyAttributes attributes, | 119 PropertyAttributes attributes, |
| 120 int index) | 120 int index) |
| 121 : Descriptor(key, function, attributes, CONSTANT_FUNCTION, index) {} | 121 : Descriptor(key, function, attributes, CONSTANT_FUNCTION, index) {} |
| 122 }; | 122 }; |
| 123 | 123 |
| 124 | 124 |
| 125 class CallbacksDescriptor: public Descriptor { | 125 class CallbacksDescriptor: public Descriptor { |
| 126 public: | 126 public: |
| 127 CallbacksDescriptor(String* key, | 127 CallbacksDescriptor(Name* key, |
| 128 Object* foreign, | 128 Object* foreign, |
| 129 PropertyAttributes attributes, | 129 PropertyAttributes attributes, |
| 130 int index = 0) | 130 int index = 0) |
| 131 : Descriptor(key, foreign, attributes, CALLBACKS, index) {} | 131 : Descriptor(key, foreign, attributes, CALLBACKS, index) {} |
| 132 }; | 132 }; |
| 133 | 133 |
| 134 | 134 |
| 135 // Holds a property index value distinguishing if it is a field index or an | 135 // Holds a property index value distinguishing if it is a field index or an |
| 136 // index inside the object header. | 136 // index inside the object header. |
| 137 class PropertyIndex { | 137 class PropertyIndex { |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 473 JSReceiver* holder_; | 473 JSReceiver* holder_; |
| 474 int number_; | 474 int number_; |
| 475 bool cacheable_; | 475 bool cacheable_; |
| 476 PropertyDetails details_; | 476 PropertyDetails details_; |
| 477 }; | 477 }; |
| 478 | 478 |
| 479 | 479 |
| 480 } } // namespace v8::internal | 480 } } // namespace v8::internal |
| 481 | 481 |
| 482 #endif // V8_PROPERTY_H_ | 482 #endif // V8_PROPERTY_H_ |
| OLD | NEW |