OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 static const int kElementsKindCount = | 167 static const int kElementsKindCount = |
168 LAST_ELEMENTS_KIND - FIRST_ELEMENTS_KIND + 1; | 168 LAST_ELEMENTS_KIND - FIRST_ELEMENTS_KIND + 1; |
169 | 169 |
170 // PropertyDetails captures type and attributes for a property. | 170 // PropertyDetails captures type and attributes for a property. |
171 // They are used both in property dictionaries and instance descriptors. | 171 // They are used both in property dictionaries and instance descriptors. |
172 class PropertyDetails BASE_EMBEDDED { | 172 class PropertyDetails BASE_EMBEDDED { |
173 public: | 173 public: |
174 PropertyDetails(PropertyAttributes attributes, | 174 PropertyDetails(PropertyAttributes attributes, |
175 PropertyType type, | 175 PropertyType type, |
176 int index = 0) { | 176 int index = 0) { |
177 ASSERT(type != EXTERNAL_ARRAY_TRANSITION); | 177 ASSERT(type != ELEMENTS_TRANSITION); |
178 ASSERT(TypeField::is_valid(type)); | 178 ASSERT(TypeField::is_valid(type)); |
179 ASSERT(AttributesField::is_valid(attributes)); | 179 ASSERT(AttributesField::is_valid(attributes)); |
180 ASSERT(StorageField::is_valid(index)); | 180 ASSERT(StorageField::is_valid(index)); |
181 | 181 |
182 value_ = TypeField::encode(type) | 182 value_ = TypeField::encode(type) |
183 | AttributesField::encode(attributes) | 183 | AttributesField::encode(attributes) |
184 | StorageField::encode(index); | 184 | StorageField::encode(index); |
185 | 185 |
186 ASSERT(type == this->type()); | 186 ASSERT(type == this->type()); |
187 ASSERT(attributes == this->attributes()); | 187 ASSERT(attributes == this->attributes()); |
188 ASSERT(index == this->index()); | 188 ASSERT(index == this->index()); |
189 } | 189 } |
190 | 190 |
191 PropertyDetails(PropertyAttributes attributes, | 191 PropertyDetails(PropertyAttributes attributes, |
192 PropertyType type, | 192 PropertyType type, |
193 ExternalArrayType array_type) { | 193 ElementsKind elements_kind) { |
194 ASSERT(type == EXTERNAL_ARRAY_TRANSITION); | 194 ASSERT(type == ELEMENTS_TRANSITION); |
195 ASSERT(TypeField::is_valid(type)); | 195 ASSERT(TypeField::is_valid(type)); |
196 ASSERT(AttributesField::is_valid(attributes)); | 196 ASSERT(AttributesField::is_valid(attributes)); |
197 ASSERT(StorageField::is_valid(static_cast<int>(array_type))); | 197 ASSERT(StorageField::is_valid(static_cast<int>(elements_kind))); |
198 | 198 |
199 value_ = TypeField::encode(type) | 199 value_ = TypeField::encode(type) |
200 | AttributesField::encode(attributes) | 200 | AttributesField::encode(attributes) |
201 | StorageField::encode(static_cast<int>(array_type)); | 201 | StorageField::encode(static_cast<int>(elements_kind)); |
202 | 202 |
203 ASSERT(type == this->type()); | 203 ASSERT(type == this->type()); |
204 ASSERT(attributes == this->attributes()); | 204 ASSERT(attributes == this->attributes()); |
205 ASSERT(array_type == this->array_type()); | 205 ASSERT(elements_kind == this->elements_kind()); |
206 } | 206 } |
207 | 207 |
208 // Conversion for storing details as Object*. | 208 // Conversion for storing details as Object*. |
209 explicit inline PropertyDetails(Smi* smi); | 209 explicit inline PropertyDetails(Smi* smi); |
210 inline Smi* AsSmi(); | 210 inline Smi* AsSmi(); |
211 | 211 |
212 PropertyType type() { return TypeField::decode(value_); } | 212 PropertyType type() { return TypeField::decode(value_); } |
213 | 213 |
214 bool IsTransition() { | 214 bool IsTransition() { |
215 PropertyType t = type(); | 215 PropertyType t = type(); |
216 ASSERT(t != INTERCEPTOR); | 216 ASSERT(t != INTERCEPTOR); |
217 return t == MAP_TRANSITION || t == CONSTANT_TRANSITION || | 217 return t == MAP_TRANSITION || t == CONSTANT_TRANSITION || |
218 t == EXTERNAL_ARRAY_TRANSITION; | 218 t == ELEMENTS_TRANSITION; |
219 } | 219 } |
220 | 220 |
221 bool IsProperty() { | 221 bool IsProperty() { |
222 return type() < FIRST_PHANTOM_PROPERTY_TYPE; | 222 return type() < FIRST_PHANTOM_PROPERTY_TYPE; |
223 } | 223 } |
224 | 224 |
225 PropertyAttributes attributes() { return AttributesField::decode(value_); } | 225 PropertyAttributes attributes() { return AttributesField::decode(value_); } |
226 | 226 |
227 int index() { return StorageField::decode(value_); } | 227 int index() { return StorageField::decode(value_); } |
228 | 228 |
229 ExternalArrayType array_type() { | 229 ElementsKind elements_kind() { |
230 ASSERT(type() == EXTERNAL_ARRAY_TRANSITION); | 230 ASSERT(type() == ELEMENTS_TRANSITION); |
231 return static_cast<ExternalArrayType>(StorageField::decode(value_)); | 231 return static_cast<ElementsKind>(StorageField::decode(value_)); |
232 } | 232 } |
233 | 233 |
234 inline PropertyDetails AsDeleted(); | 234 inline PropertyDetails AsDeleted(); |
235 | 235 |
236 static bool IsValidIndex(int index) { | 236 static bool IsValidIndex(int index) { |
237 return StorageField::is_valid(index); | 237 return StorageField::is_valid(index); |
238 } | 238 } |
239 | 239 |
240 bool IsReadOnly() { return (attributes() & READ_ONLY) != 0; } | 240 bool IsReadOnly() { return (attributes() & READ_ONLY) != 0; } |
241 bool IsDontDelete() { return (attributes() & DONT_DELETE) != 0; } | 241 bool IsDontDelete() { return (attributes() & DONT_DELETE) != 0; } |
(...skipping 3905 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4147 // otherwise returns a copy of the map, with all transitions dropped from the | 4147 // otherwise returns a copy of the map, with all transitions dropped from the |
4148 // descriptors and the ElementsKind set to FAST_DOUBLE_ELEMENTS. | 4148 // descriptors and the ElementsKind set to FAST_DOUBLE_ELEMENTS. |
4149 MUST_USE_RESULT inline MaybeObject* GetFastDoubleElementsMap(); | 4149 MUST_USE_RESULT inline MaybeObject* GetFastDoubleElementsMap(); |
4150 | 4150 |
4151 // Returns this map if already has dictionary elements, otherwise returns a | 4151 // Returns this map if already has dictionary elements, otherwise returns a |
4152 // copy of the map, with all transitions dropped from the descriptors and the | 4152 // copy of the map, with all transitions dropped from the descriptors and the |
4153 // ElementsKind set to DICTIONARY_ELEMENTS. | 4153 // ElementsKind set to DICTIONARY_ELEMENTS. |
4154 MUST_USE_RESULT inline MaybeObject* GetSlowElementsMap(); | 4154 MUST_USE_RESULT inline MaybeObject* GetSlowElementsMap(); |
4155 | 4155 |
4156 // Returns a new map with all transitions dropped from the descriptors and the | 4156 // Returns a new map with all transitions dropped from the descriptors and the |
4157 // ElementsKind set to one of the value corresponding to array_type. | 4157 // ElementsKind set. |
4158 MUST_USE_RESULT MaybeObject* GetExternalArrayElementsMap( | 4158 MUST_USE_RESULT MaybeObject* GetElementsTransitionMap( |
4159 ExternalArrayType array_type, | 4159 ElementsKind elements_kind, |
4160 bool safe_to_add_transition); | 4160 bool safe_to_add_transition); |
4161 | 4161 |
4162 // Returns the property index for name (only valid for FAST MODE). | 4162 // Returns the property index for name (only valid for FAST MODE). |
4163 int PropertyIndexFor(String* name); | 4163 int PropertyIndexFor(String* name); |
4164 | 4164 |
4165 // Returns the next free property index (only valid for FAST MODE). | 4165 // Returns the next free property index (only valid for FAST MODE). |
4166 int NextFreePropertyIndex(); | 4166 int NextFreePropertyIndex(); |
4167 | 4167 |
4168 // Returns the number of properties described in instance_descriptors. | 4168 // Returns the number of properties described in instance_descriptors. |
4169 int NumberOfDescribedProperties(); | 4169 int NumberOfDescribedProperties(); |
(...skipping 3285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7455 } else { | 7455 } else { |
7456 value &= ~(1 << bit_position); | 7456 value &= ~(1 << bit_position); |
7457 } | 7457 } |
7458 return value; | 7458 return value; |
7459 } | 7459 } |
7460 }; | 7460 }; |
7461 | 7461 |
7462 } } // namespace v8::internal | 7462 } } // namespace v8::internal |
7463 | 7463 |
7464 #endif // V8_OBJECTS_H_ | 7464 #endif // V8_OBJECTS_H_ |
OLD | NEW |