| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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_DETAILS_H_ | 5 #ifndef V8_PROPERTY_DETAILS_H_ |
| 6 #define V8_PROPERTY_DETAILS_H_ | 6 #define V8_PROPERTY_DETAILS_H_ |
| 7 | 7 |
| 8 #include "include/v8.h" | 8 #include "include/v8.h" |
| 9 #include "src/allocation.h" | 9 #include "src/allocation.h" |
| 10 #include "src/utils.h" | 10 #include "src/utils.h" |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 class TypeInfo; | 65 class TypeInfo; |
| 66 | 66 |
| 67 // Order of kinds is significant. | 67 // Order of kinds is significant. |
| 68 // Must fit in the BitField PropertyDetails::KindField. | 68 // Must fit in the BitField PropertyDetails::KindField. |
| 69 enum PropertyKind { kData = 0, kAccessor = 1 }; | 69 enum PropertyKind { kData = 0, kAccessor = 1 }; |
| 70 | 70 |
| 71 // Order of modes is significant. | 71 // Order of modes is significant. |
| 72 // Must fit in the BitField PropertyDetails::LocationField. | 72 // Must fit in the BitField PropertyDetails::LocationField. |
| 73 enum PropertyLocation { kField = 0, kDescriptor = 1 }; | 73 enum PropertyLocation { kField = 0, kDescriptor = 1 }; |
| 74 | 74 |
| 75 | |
| 76 // Order of properties is significant. | |
| 77 // Must fit in the BitField PropertyDetails::TypeField. | |
| 78 // A copy of this is in debug/mirrors.js. | |
| 79 enum PropertyType { | |
| 80 DATA = (kField << 1) | kData, | |
| 81 DATA_CONSTANT = (kDescriptor << 1) | kData, | |
| 82 ACCESSOR = (kField << 1) | kAccessor, | |
| 83 ACCESSOR_CONSTANT = (kDescriptor << 1) | kAccessor | |
| 84 }; | |
| 85 | |
| 86 | |
| 87 class Representation { | 75 class Representation { |
| 88 public: | 76 public: |
| 89 enum Kind { | 77 enum Kind { |
| 90 kNone, | 78 kNone, |
| 91 kInteger8, | 79 kInteger8, |
| 92 kUInteger8, | 80 kUInteger8, |
| 93 kInteger16, | 81 kInteger16, |
| 94 kUInteger16, | 82 kUInteger16, |
| 95 kSmi, | 83 kSmi, |
| 96 kInteger32, | 84 kInteger32, |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 return representation.kind(); | 279 return representation.kind(); |
| 292 } | 280 } |
| 293 | 281 |
| 294 static Representation DecodeRepresentation(uint32_t bits) { | 282 static Representation DecodeRepresentation(uint32_t bits) { |
| 295 return Representation::FromKind(static_cast<Representation::Kind>(bits)); | 283 return Representation::FromKind(static_cast<Representation::Kind>(bits)); |
| 296 } | 284 } |
| 297 | 285 |
| 298 PropertyKind kind() const { return KindField::decode(value_); } | 286 PropertyKind kind() const { return KindField::decode(value_); } |
| 299 PropertyLocation location() const { return LocationField::decode(value_); } | 287 PropertyLocation location() const { return LocationField::decode(value_); } |
| 300 | 288 |
| 301 PropertyType type() const { return TypeField::decode(value_); } | |
| 302 | |
| 303 PropertyAttributes attributes() const { | 289 PropertyAttributes attributes() const { |
| 304 return AttributesField::decode(value_); | 290 return AttributesField::decode(value_); |
| 305 } | 291 } |
| 306 | 292 |
| 307 int dictionary_index() const { | 293 int dictionary_index() const { |
| 308 return DictionaryStorageField::decode(value_); | 294 return DictionaryStorageField::decode(value_); |
| 309 } | 295 } |
| 310 | 296 |
| 311 Representation representation() const { | 297 Representation representation() const { |
| 312 return DecodeRepresentation(RepresentationField::decode(value_)); | 298 return DecodeRepresentation(RepresentationField::decode(value_)); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 341 class DictionaryStorageField : public BitField<uint32_t, 7, 24> {}; | 327 class DictionaryStorageField : public BitField<uint32_t, 7, 24> {}; |
| 342 | 328 |
| 343 // Bit fields for fast objects. | 329 // Bit fields for fast objects. |
| 344 class RepresentationField : public BitField<uint32_t, 5, 4> {}; | 330 class RepresentationField : public BitField<uint32_t, 5, 4> {}; |
| 345 class DescriptorPointer | 331 class DescriptorPointer |
| 346 : public BitField<uint32_t, 9, kDescriptorIndexBitCount> {}; // NOLINT | 332 : public BitField<uint32_t, 9, kDescriptorIndexBitCount> {}; // NOLINT |
| 347 class FieldIndexField | 333 class FieldIndexField |
| 348 : public BitField<uint32_t, 9 + kDescriptorIndexBitCount, | 334 : public BitField<uint32_t, 9 + kDescriptorIndexBitCount, |
| 349 kDescriptorIndexBitCount> {}; // NOLINT | 335 kDescriptorIndexBitCount> {}; // NOLINT |
| 350 | 336 |
| 351 // NOTE: TypeField overlaps with KindField and LocationField. | |
| 352 class TypeField : public BitField<PropertyType, 0, 2> {}; | |
| 353 STATIC_ASSERT(KindField::kNext == LocationField::kShift); | |
| 354 STATIC_ASSERT(TypeField::kShift == KindField::kShift); | |
| 355 STATIC_ASSERT(TypeField::kNext == LocationField::kNext); | |
| 356 | |
| 357 // All bits for both fast and slow objects must fit in a smi. | 337 // All bits for both fast and slow objects must fit in a smi. |
| 358 STATIC_ASSERT(DictionaryStorageField::kNext <= 31); | 338 STATIC_ASSERT(DictionaryStorageField::kNext <= 31); |
| 359 STATIC_ASSERT(FieldIndexField::kNext <= 31); | 339 STATIC_ASSERT(FieldIndexField::kNext <= 31); |
| 360 | 340 |
| 361 static const int kInitialIndex = 1; | 341 static const int kInitialIndex = 1; |
| 362 | 342 |
| 363 #ifdef OBJECT_PRINT | 343 #ifdef OBJECT_PRINT |
| 364 // For our gdb macros, we should perhaps change these in the future. | 344 // For our gdb macros, we should perhaps change these in the future. |
| 365 void Print(bool dictionary_mode); | 345 void Print(bool dictionary_mode); |
| 366 #endif | 346 #endif |
| (...skipping 26 matching lines...) Expand all Loading... |
| 393 uint32_t value_; | 373 uint32_t value_; |
| 394 }; | 374 }; |
| 395 | 375 |
| 396 | 376 |
| 397 std::ostream& operator<<(std::ostream& os, | 377 std::ostream& operator<<(std::ostream& os, |
| 398 const PropertyAttributes& attributes); | 378 const PropertyAttributes& attributes); |
| 399 } // namespace internal | 379 } // namespace internal |
| 400 } // namespace v8 | 380 } // namespace v8 |
| 401 | 381 |
| 402 #endif // V8_PROPERTY_DETAILS_H_ | 382 #endif // V8_PROPERTY_DETAILS_H_ |
| OLD | NEW |