| 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 26 matching lines...) Expand all Loading... |
| 37 class Smi; | 37 class Smi; |
| 38 template<class> class TypeImpl; | 38 template<class> class TypeImpl; |
| 39 struct ZoneTypeConfig; | 39 struct ZoneTypeConfig; |
| 40 typedef TypeImpl<ZoneTypeConfig> Type; | 40 typedef TypeImpl<ZoneTypeConfig> Type; |
| 41 class TypeInfo; | 41 class TypeInfo; |
| 42 | 42 |
| 43 // Type of properties. | 43 // Type of properties. |
| 44 // Order of properties is significant. | 44 // Order of properties is significant. |
| 45 // Must fit in the BitField PropertyDetails::TypeField. | 45 // Must fit in the BitField PropertyDetails::TypeField. |
| 46 // A copy of this is in mirror-debugger.js. | 46 // A copy of this is in mirror-debugger.js. |
| 47 enum PropertyType { | 47 enum PropertyType { FIELD = 0, CONSTANT = 1, CALLBACKS = 2 }; |
| 48 // Only in slow mode. | |
| 49 NORMAL = 0, | |
| 50 // Only in fast mode. | |
| 51 FIELD = 1, | |
| 52 CONSTANT = 2, | |
| 53 CALLBACKS = 3 | |
| 54 }; | |
| 55 | 48 |
| 56 | 49 |
| 57 class Representation { | 50 class Representation { |
| 58 public: | 51 public: |
| 59 enum Kind { | 52 enum Kind { |
| 60 kNone, | 53 kNone, |
| 61 kInteger8, | 54 kInteger8, |
| 62 kUInteger8, | 55 kUInteger8, |
| 63 kInteger16, | 56 kInteger16, |
| 64 kUInteger16, | 57 kUInteger16, |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 | 226 |
| 234 PropertyAttributes attributes() const { | 227 PropertyAttributes attributes() const { |
| 235 return AttributesField::decode(value_); | 228 return AttributesField::decode(value_); |
| 236 } | 229 } |
| 237 | 230 |
| 238 int dictionary_index() const { | 231 int dictionary_index() const { |
| 239 return DictionaryStorageField::decode(value_); | 232 return DictionaryStorageField::decode(value_); |
| 240 } | 233 } |
| 241 | 234 |
| 242 Representation representation() const { | 235 Representation representation() const { |
| 243 DCHECK(type() != NORMAL); | |
| 244 return DecodeRepresentation(RepresentationField::decode(value_)); | 236 return DecodeRepresentation(RepresentationField::decode(value_)); |
| 245 } | 237 } |
| 246 | 238 |
| 247 int field_index() const { | 239 int field_index() const { return FieldIndexField::decode(value_); } |
| 248 return FieldIndexField::decode(value_); | |
| 249 } | |
| 250 | 240 |
| 251 inline int field_width_in_words() const; | 241 inline int field_width_in_words() const; |
| 252 | 242 |
| 253 inline PropertyDetails AsDeleted() const; | 243 inline PropertyDetails AsDeleted() const; |
| 254 | 244 |
| 255 static bool IsValidIndex(int index) { | 245 static bool IsValidIndex(int index) { |
| 256 return DictionaryStorageField::is_valid(index); | 246 return DictionaryStorageField::is_valid(index); |
| 257 } | 247 } |
| 258 | 248 |
| 259 bool IsReadOnly() const { return (attributes() & READ_ONLY) != 0; } | 249 bool IsReadOnly() const { return (attributes() & READ_ONLY) != 0; } |
| 260 bool IsConfigurable() const { return (attributes() & DONT_DELETE) == 0; } | 250 bool IsConfigurable() const { return (attributes() & DONT_DELETE) == 0; } |
| 261 bool IsDontEnum() const { return (attributes() & DONT_ENUM) != 0; } | 251 bool IsDontEnum() const { return (attributes() & DONT_ENUM) != 0; } |
| 262 bool IsDeleted() const { return DeletedField::decode(value_) != 0;} | 252 bool IsDeleted() const { return DeletedField::decode(value_) != 0; } |
| 263 | 253 |
| 264 // Bit fields in value_ (type, shift, size). Must be public so the | 254 // Bit fields in value_ (type, shift, size). Must be public so the |
| 265 // constants can be embedded in generated code. | 255 // constants can be embedded in generated code. |
| 266 class TypeField : public BitField<PropertyType, 0, 2> {}; | 256 class TypeField : public BitField<PropertyType, 0, 2> {}; |
| 267 class AttributesField : public BitField<PropertyAttributes, 2, 3> {}; | 257 class AttributesField : public BitField<PropertyAttributes, 2, 3> {}; |
| 268 | 258 |
| 269 // Bit fields for normalized objects. | 259 // Bit fields for normalized objects. |
| 270 class DeletedField : public BitField<uint32_t, 5, 1> {}; | 260 class DeletedField : public BitField<uint32_t, 5, 1> {}; |
| 271 class DictionaryStorageField : public BitField<uint32_t, 6, 24> {}; | 261 class DictionaryStorageField : public BitField<uint32_t, 6, 24> {}; |
| 272 | 262 |
| 273 // Bit fields for fast objects. | 263 // Bit fields for fast objects. |
| 274 class RepresentationField : public BitField<uint32_t, 5, 4> {}; | 264 class RepresentationField : public BitField<uint32_t, 5, 4> {}; |
| 275 class DescriptorPointer | 265 class DescriptorPointer |
| 276 : public BitField<uint32_t, 9, kDescriptorIndexBitCount> {}; // NOLINT | 266 : public BitField<uint32_t, 9, kDescriptorIndexBitCount> {}; // NOLINT |
| 277 class FieldIndexField | 267 class FieldIndexField |
| 278 : public BitField<uint32_t, 9 + kDescriptorIndexBitCount, | 268 : public BitField<uint32_t, 9 + kDescriptorIndexBitCount, |
| 279 kDescriptorIndexBitCount> {}; // NOLINT | 269 kDescriptorIndexBitCount> {}; // NOLINT |
| 280 // All bits for fast objects must fix in a smi. | 270 |
| 281 STATIC_ASSERT(9 + kDescriptorIndexBitCount + kDescriptorIndexBitCount <= 31); | 271 // All bits for both fast and slow objects must fit in a smi. |
| 272 STATIC_ASSERT(DictionaryStorageField::kNext <= 31); |
| 273 STATIC_ASSERT(FieldIndexField::kNext <= 31); |
| 282 | 274 |
| 283 static const int kInitialIndex = 1; | 275 static const int kInitialIndex = 1; |
| 284 | 276 |
| 277 #ifdef OBJECT_PRINT |
| 278 // For our gdb macros, we should perhaps change these in the future. |
| 279 void Print(bool dictionary_mode); |
| 280 #endif |
| 281 |
| 285 private: | 282 private: |
| 286 PropertyDetails(int value, int pointer) { | 283 PropertyDetails(int value, int pointer) { |
| 287 value_ = DescriptorPointer::update(value, pointer); | 284 value_ = DescriptorPointer::update(value, pointer); |
| 288 } | 285 } |
| 289 PropertyDetails(int value, Representation representation) { | 286 PropertyDetails(int value, Representation representation) { |
| 290 value_ = RepresentationField::update( | 287 value_ = RepresentationField::update( |
| 291 value, EncodeRepresentation(representation)); | 288 value, EncodeRepresentation(representation)); |
| 292 } | 289 } |
| 293 PropertyDetails(int value, PropertyAttributes attributes) { | 290 PropertyDetails(int value, PropertyAttributes attributes) { |
| 294 value_ = AttributesField::update(value, attributes); | 291 value_ = AttributesField::update(value, attributes); |
| 295 } | 292 } |
| 296 | 293 |
| 297 uint32_t value_; | 294 uint32_t value_; |
| 298 }; | 295 }; |
| 299 | 296 |
| 300 | 297 |
| 301 std::ostream& operator<<(std::ostream& os, | 298 std::ostream& operator<<(std::ostream& os, |
| 302 const PropertyAttributes& attributes); | 299 const PropertyAttributes& attributes); |
| 303 std::ostream& operator<<(std::ostream& os, const PropertyDetails& details); | 300 std::ostream& operator<<(std::ostream& os, const PropertyDetails& details); |
| 304 } } // namespace v8::internal | 301 } } // namespace v8::internal |
| 305 | 302 |
| 306 #endif // V8_PROPERTY_DETAILS_H_ | 303 #endif // V8_PROPERTY_DETAILS_H_ |
| OLD | NEW |