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 23 matching lines...) Expand all Loading... | |
34 namespace v8 { | 34 namespace v8 { |
35 namespace internal { | 35 namespace internal { |
36 | 36 |
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 kinds is significant. | |
45 // Must fit in the BitField PropertyDetails::KindField. | |
46 enum PropertyKind { DATA = 0, ACCESSOR = 1 }; | |
47 | |
48 | |
49 // Order of modes is significant. | |
50 // Must fit in the BitField PropertyDetails::StoreModeField. | |
51 enum PropertyStoreMode { IN_OBJECT = 0, IN_DESCRIPTOR = 1 }; | |
Jakob Kummerow
2014/12/12 12:19:04
nit: we already have two enums called StoreMode. C
Igor Sheludko
2014/12/12 12:38:30
Renamed to PropertyLocation.
| |
52 | |
53 | |
44 // Order of properties is significant. | 54 // Order of properties is significant. |
45 // Must fit in the BitField PropertyDetails::TypeField. | 55 // Must fit in the BitField PropertyDetails::TypeField. |
46 // A copy of this is in mirror-debugger.js. | 56 // A copy of this is in mirror-debugger.js. |
47 enum PropertyType { FIELD = 0, CONSTANT = 1, CALLBACKS = 2 }; | 57 enum PropertyType { |
58 FIELD = (IN_OBJECT << 1) | DATA, | |
59 CONSTANT = (IN_DESCRIPTOR << 1) | DATA, | |
60 CALLBACKS = (IN_DESCRIPTOR << 1) | ACCESSOR | |
61 }; | |
48 | 62 |
49 | 63 |
50 class Representation { | 64 class Representation { |
51 public: | 65 public: |
52 enum Kind { | 66 enum Kind { |
53 kNone, | 67 kNone, |
54 kInteger8, | 68 kInteger8, |
55 kUInteger8, | 69 kUInteger8, |
56 kInteger16, | 70 kInteger16, |
57 kUInteger16, | 71 kUInteger16, |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
215 inline Smi* AsSmi() const; | 229 inline Smi* AsSmi() const; |
216 | 230 |
217 static uint8_t EncodeRepresentation(Representation representation) { | 231 static uint8_t EncodeRepresentation(Representation representation) { |
218 return representation.kind(); | 232 return representation.kind(); |
219 } | 233 } |
220 | 234 |
221 static Representation DecodeRepresentation(uint32_t bits) { | 235 static Representation DecodeRepresentation(uint32_t bits) { |
222 return Representation::FromKind(static_cast<Representation::Kind>(bits)); | 236 return Representation::FromKind(static_cast<Representation::Kind>(bits)); |
223 } | 237 } |
224 | 238 |
239 PropertyKind kind() const { return KindField::decode(value_); } | |
240 PropertyStoreMode store_mode() const { | |
241 return StoreModeField::decode(value_); | |
242 } | |
243 | |
225 PropertyType type() const { return TypeField::decode(value_); } | 244 PropertyType type() const { return TypeField::decode(value_); } |
226 | 245 |
227 PropertyAttributes attributes() const { | 246 PropertyAttributes attributes() const { |
228 return AttributesField::decode(value_); | 247 return AttributesField::decode(value_); |
229 } | 248 } |
230 | 249 |
231 int dictionary_index() const { | 250 int dictionary_index() const { |
232 return DictionaryStorageField::decode(value_); | 251 return DictionaryStorageField::decode(value_); |
233 } | 252 } |
234 | 253 |
(...skipping 11 matching lines...) Expand all Loading... | |
246 return DictionaryStorageField::is_valid(index); | 265 return DictionaryStorageField::is_valid(index); |
247 } | 266 } |
248 | 267 |
249 bool IsReadOnly() const { return (attributes() & READ_ONLY) != 0; } | 268 bool IsReadOnly() const { return (attributes() & READ_ONLY) != 0; } |
250 bool IsConfigurable() const { return (attributes() & DONT_DELETE) == 0; } | 269 bool IsConfigurable() const { return (attributes() & DONT_DELETE) == 0; } |
251 bool IsDontEnum() const { return (attributes() & DONT_ENUM) != 0; } | 270 bool IsDontEnum() const { return (attributes() & DONT_ENUM) != 0; } |
252 bool IsDeleted() const { return DeletedField::decode(value_) != 0; } | 271 bool IsDeleted() const { return DeletedField::decode(value_) != 0; } |
253 | 272 |
254 // Bit fields in value_ (type, shift, size). Must be public so the | 273 // Bit fields in value_ (type, shift, size). Must be public so the |
255 // constants can be embedded in generated code. | 274 // constants can be embedded in generated code. |
256 class TypeField : public BitField<PropertyType, 0, 2> {}; | 275 class KindField : public BitField<PropertyKind, 0, 1> {}; |
276 class StoreModeField : public BitField<PropertyStoreMode, 1, 1> {}; | |
257 class AttributesField : public BitField<PropertyAttributes, 2, 3> {}; | 277 class AttributesField : public BitField<PropertyAttributes, 2, 3> {}; |
258 | 278 |
259 // Bit fields for normalized objects. | 279 // Bit fields for normalized objects. |
260 class DeletedField : public BitField<uint32_t, 5, 1> {}; | 280 class DeletedField : public BitField<uint32_t, 5, 1> {}; |
261 class DictionaryStorageField : public BitField<uint32_t, 6, 24> {}; | 281 class DictionaryStorageField : public BitField<uint32_t, 6, 24> {}; |
262 | 282 |
263 // Bit fields for fast objects. | 283 // Bit fields for fast objects. |
264 class RepresentationField : public BitField<uint32_t, 5, 4> {}; | 284 class RepresentationField : public BitField<uint32_t, 5, 4> {}; |
265 class DescriptorPointer | 285 class DescriptorPointer |
266 : public BitField<uint32_t, 9, kDescriptorIndexBitCount> {}; // NOLINT | 286 : public BitField<uint32_t, 9, kDescriptorIndexBitCount> {}; // NOLINT |
267 class FieldIndexField | 287 class FieldIndexField |
268 : public BitField<uint32_t, 9 + kDescriptorIndexBitCount, | 288 : public BitField<uint32_t, 9 + kDescriptorIndexBitCount, |
269 kDescriptorIndexBitCount> {}; // NOLINT | 289 kDescriptorIndexBitCount> {}; // NOLINT |
270 | 290 |
291 // NOTE: TypeField overlaps with KindField and StoreModeField. | |
292 class TypeField : public BitField<PropertyType, 0, 2> {}; | |
293 STATIC_ASSERT(KindField::kNext == StoreModeField::kShift); | |
294 STATIC_ASSERT(TypeField::kShift == KindField::kShift); | |
295 STATIC_ASSERT(TypeField::kNext == StoreModeField::kNext); | |
296 | |
271 // All bits for both fast and slow objects must fit in a smi. | 297 // All bits for both fast and slow objects must fit in a smi. |
272 STATIC_ASSERT(DictionaryStorageField::kNext <= 31); | 298 STATIC_ASSERT(DictionaryStorageField::kNext <= 31); |
273 STATIC_ASSERT(FieldIndexField::kNext <= 31); | 299 STATIC_ASSERT(FieldIndexField::kNext <= 31); |
274 | 300 |
275 static const int kInitialIndex = 1; | 301 static const int kInitialIndex = 1; |
276 | 302 |
277 #ifdef OBJECT_PRINT | 303 #ifdef OBJECT_PRINT |
278 // For our gdb macros, we should perhaps change these in the future. | 304 // For our gdb macros, we should perhaps change these in the future. |
279 void Print(bool dictionary_mode); | 305 void Print(bool dictionary_mode); |
280 #endif | 306 #endif |
(...skipping 13 matching lines...) Expand all Loading... | |
294 uint32_t value_; | 320 uint32_t value_; |
295 }; | 321 }; |
296 | 322 |
297 | 323 |
298 std::ostream& operator<<(std::ostream& os, | 324 std::ostream& operator<<(std::ostream& os, |
299 const PropertyAttributes& attributes); | 325 const PropertyAttributes& attributes); |
300 std::ostream& operator<<(std::ostream& os, const PropertyDetails& details); | 326 std::ostream& operator<<(std::ostream& os, const PropertyDetails& details); |
301 } } // namespace v8::internal | 327 } } // namespace v8::internal |
302 | 328 |
303 #endif // V8_PROPERTY_DETAILS_H_ | 329 #endif // V8_PROPERTY_DETAILS_H_ |
OLD | NEW |