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 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 private: | 187 private: |
188 explicit Representation(Kind k) : kind_(k) { } | 188 explicit Representation(Kind k) : kind_(k) { } |
189 | 189 |
190 // Make sure kind fits in int8. | 190 // Make sure kind fits in int8. |
191 STATIC_ASSERT(kNumRepresentations <= (1 << kBitsPerByte)); | 191 STATIC_ASSERT(kNumRepresentations <= (1 << kBitsPerByte)); |
192 | 192 |
193 int8_t kind_; | 193 int8_t kind_; |
194 }; | 194 }; |
195 | 195 |
196 | 196 |
| 197 static const int kDescriptorIndexBitCount = 10; |
| 198 // The maximum number of descriptors we want in a descriptor array (should |
| 199 // fit in a page). |
| 200 static const int kMaxNumberOfDescriptors = |
| 201 (1 << kDescriptorIndexBitCount) - 2; |
| 202 static const int kInvalidEnumCacheSentinel = |
| 203 (1 << kDescriptorIndexBitCount) - 1; |
| 204 |
| 205 |
197 // PropertyDetails captures type and attributes for a property. | 206 // PropertyDetails captures type and attributes for a property. |
198 // They are used both in property dictionaries and instance descriptors. | 207 // They are used both in property dictionaries and instance descriptors. |
199 class PropertyDetails BASE_EMBEDDED { | 208 class PropertyDetails BASE_EMBEDDED { |
200 public: | 209 public: |
201 PropertyDetails(PropertyAttributes attributes, | 210 PropertyDetails(PropertyAttributes attributes, |
202 PropertyType type, | 211 PropertyType type, |
203 int index) { | 212 int index) { |
204 value_ = TypeField::encode(type) | 213 value_ = TypeField::encode(type) |
205 | AttributesField::encode(attributes) | 214 | AttributesField::encode(attributes) |
206 | DictionaryStorageField::encode(index); | 215 | DictionaryStorageField::encode(index); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 // Bit fields in value_ (type, shift, size). Must be public so the | 286 // Bit fields in value_ (type, shift, size). Must be public so the |
278 // constants can be embedded in generated code. | 287 // constants can be embedded in generated code. |
279 class TypeField: public BitField<PropertyType, 0, 3> {}; | 288 class TypeField: public BitField<PropertyType, 0, 3> {}; |
280 class AttributesField: public BitField<PropertyAttributes, 3, 3> {}; | 289 class AttributesField: public BitField<PropertyAttributes, 3, 3> {}; |
281 | 290 |
282 // Bit fields for normalized objects. | 291 // Bit fields for normalized objects. |
283 class DeletedField: public BitField<uint32_t, 6, 1> {}; | 292 class DeletedField: public BitField<uint32_t, 6, 1> {}; |
284 class DictionaryStorageField: public BitField<uint32_t, 7, 24> {}; | 293 class DictionaryStorageField: public BitField<uint32_t, 7, 24> {}; |
285 | 294 |
286 // Bit fields for fast objects. | 295 // Bit fields for fast objects. |
287 class DescriptorPointer: public BitField<uint32_t, 6, 11> {}; | 296 class RepresentationField: public BitField<uint32_t, 6, 4> {}; |
288 class RepresentationField: public BitField<uint32_t, 17, 4> {}; | 297 class DescriptorPointer: public BitField<uint32_t, 10, |
289 class FieldIndexField: public BitField<uint32_t, 21, 10> {}; | 298 kDescriptorIndexBitCount> {}; |
| 299 class FieldIndexField: public BitField<uint32_t, |
| 300 10 + kDescriptorIndexBitCount, |
| 301 kDescriptorIndexBitCount> {}; |
| 302 // All bits for fast objects must fix in a smi. |
| 303 STATIC_ASSERT(10 + kDescriptorIndexBitCount + kDescriptorIndexBitCount <= 31); |
290 | 304 |
291 static const int kInitialIndex = 1; | 305 static const int kInitialIndex = 1; |
292 | 306 |
293 private: | 307 private: |
294 PropertyDetails(int value, int pointer) { | 308 PropertyDetails(int value, int pointer) { |
295 value_ = DescriptorPointer::update(value, pointer); | 309 value_ = DescriptorPointer::update(value, pointer); |
296 } | 310 } |
297 PropertyDetails(int value, Representation representation) { | 311 PropertyDetails(int value, Representation representation) { |
298 value_ = RepresentationField::update( | 312 value_ = RepresentationField::update( |
299 value, EncodeRepresentation(representation)); | 313 value, EncodeRepresentation(representation)); |
300 } | 314 } |
301 PropertyDetails(int value, PropertyAttributes attributes) { | 315 PropertyDetails(int value, PropertyAttributes attributes) { |
302 value_ = AttributesField::update(value, attributes); | 316 value_ = AttributesField::update(value, attributes); |
303 } | 317 } |
304 | 318 |
305 uint32_t value_; | 319 uint32_t value_; |
306 }; | 320 }; |
307 | 321 |
308 } } // namespace v8::internal | 322 } } // namespace v8::internal |
309 | 323 |
310 #endif // V8_PROPERTY_DETAILS_H_ | 324 #endif // V8_PROPERTY_DETAILS_H_ |
OLD | NEW |