OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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_OBJECTS_H_ | 5 #ifndef V8_OBJECTS_H_ |
6 #define V8_OBJECTS_H_ | 6 #define V8_OBJECTS_H_ |
7 | 7 |
8 #include <iosfwd> | 8 #include <iosfwd> |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
(...skipping 3115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3126 DISALLOW_IMPLICIT_CONSTRUCTORS(FrameArray); | 3126 DISALLOW_IMPLICIT_CONSTRUCTORS(FrameArray); |
3127 }; | 3127 }; |
3128 | 3128 |
3129 // DescriptorArrays are fixed arrays used to hold instance descriptors. | 3129 // DescriptorArrays are fixed arrays used to hold instance descriptors. |
3130 // The format of the these objects is: | 3130 // The format of the these objects is: |
3131 // [0]: Number of descriptors | 3131 // [0]: Number of descriptors |
3132 // [1]: Either Smi(0) if uninitialized, or a pointer to small fixed array: | 3132 // [1]: Either Smi(0) if uninitialized, or a pointer to small fixed array: |
3133 // [0]: pointer to fixed array with enum cache | 3133 // [0]: pointer to fixed array with enum cache |
3134 // [1]: either Smi(0) or pointer to fixed array with indices | 3134 // [1]: either Smi(0) or pointer to fixed array with indices |
3135 // [2]: first key | 3135 // [2]: first key |
3136 // [2 + number of descriptors * kDescriptorSize]: start of slack | 3136 // [2 + number of descriptors * kEntrySize]: start of slack |
3137 class DescriptorArray: public FixedArray { | 3137 class DescriptorArray: public FixedArray { |
3138 public: | 3138 public: |
3139 // Returns true for both shared empty_descriptor_array and for smis, which the | 3139 // Returns true for both shared empty_descriptor_array and for smis, which the |
3140 // map uses to encode additional bit fields when the descriptor array is not | 3140 // map uses to encode additional bit fields when the descriptor array is not |
3141 // yet used. | 3141 // yet used. |
3142 inline bool IsEmpty(); | 3142 inline bool IsEmpty(); |
3143 | 3143 |
3144 // Returns the number of descriptors in the array. | 3144 // Returns the number of descriptors in the array. |
3145 inline int number_of_descriptors(); | 3145 inline int number_of_descriptors(); |
3146 | 3146 |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3247 | 3247 |
3248 // Layout description. | 3248 // Layout description. |
3249 static const int kDescriptorLengthOffset = FixedArray::kHeaderSize; | 3249 static const int kDescriptorLengthOffset = FixedArray::kHeaderSize; |
3250 static const int kEnumCacheOffset = kDescriptorLengthOffset + kPointerSize; | 3250 static const int kEnumCacheOffset = kDescriptorLengthOffset + kPointerSize; |
3251 static const int kFirstOffset = kEnumCacheOffset + kPointerSize; | 3251 static const int kFirstOffset = kEnumCacheOffset + kPointerSize; |
3252 | 3252 |
3253 // Layout description for the bridge array. | 3253 // Layout description for the bridge array. |
3254 static const int kEnumCacheBridgeCacheOffset = FixedArray::kHeaderSize; | 3254 static const int kEnumCacheBridgeCacheOffset = FixedArray::kHeaderSize; |
3255 | 3255 |
3256 // Layout of descriptor. | 3256 // Layout of descriptor. |
3257 static const int kDescriptorKey = 0; | 3257 // Naming is consistent with Dictionary classes for easy templating. |
3258 static const int kDescriptorDetails = 1; | 3258 static const int kEntryKeyIndex = 0; |
3259 static const int kDescriptorValue = 2; | 3259 static const int kEntryDetailsIndex = 1; |
3260 static const int kDescriptorSize = 3; | 3260 static const int kEntryValueIndex = 2; |
| 3261 static const int kEntrySize = 3; |
3261 | 3262 |
3262 #if defined(DEBUG) || defined(OBJECT_PRINT) | 3263 #if defined(DEBUG) || defined(OBJECT_PRINT) |
3263 // For our gdb macros, we should perhaps change these in the future. | 3264 // For our gdb macros, we should perhaps change these in the future. |
3264 void Print(); | 3265 void Print(); |
3265 | 3266 |
3266 // Print all the descriptors. | 3267 // Print all the descriptors. |
3267 void PrintDescriptors(std::ostream& os); // NOLINT | 3268 void PrintDescriptors(std::ostream& os); // NOLINT |
3268 | 3269 |
3269 void PrintDescriptorDetails(std::ostream& os, int descriptor, | 3270 void PrintDescriptorDetails(std::ostream& os, int descriptor, |
3270 PropertyDetails::PrintMode mode); | 3271 PropertyDetails::PrintMode mode); |
(...skipping 10 matching lines...) Expand all Loading... |
3281 bool IsEqualTo(DescriptorArray* other); | 3282 bool IsEqualTo(DescriptorArray* other); |
3282 #endif | 3283 #endif |
3283 | 3284 |
3284 // Returns the fixed array length required to hold number_of_descriptors | 3285 // Returns the fixed array length required to hold number_of_descriptors |
3285 // descriptors. | 3286 // descriptors. |
3286 static int LengthFor(int number_of_descriptors) { | 3287 static int LengthFor(int number_of_descriptors) { |
3287 return ToKeyIndex(number_of_descriptors); | 3288 return ToKeyIndex(number_of_descriptors); |
3288 } | 3289 } |
3289 | 3290 |
3290 static int ToDetailsIndex(int descriptor_number) { | 3291 static int ToDetailsIndex(int descriptor_number) { |
3291 return kFirstIndex + (descriptor_number * kDescriptorSize) + | 3292 return kFirstIndex + (descriptor_number * kEntrySize) + kEntryDetailsIndex; |
3292 kDescriptorDetails; | |
3293 } | 3293 } |
3294 | 3294 |
3295 // Conversion from descriptor number to array indices. | 3295 // Conversion from descriptor number to array indices. |
3296 static int ToKeyIndex(int descriptor_number) { | 3296 static int ToKeyIndex(int descriptor_number) { |
3297 return kFirstIndex + (descriptor_number * kDescriptorSize) + kDescriptorKey; | 3297 return kFirstIndex + (descriptor_number * kEntrySize) + kEntryKeyIndex; |
3298 } | 3298 } |
3299 | 3299 |
3300 static int ToValueIndex(int descriptor_number) { | 3300 static int ToValueIndex(int descriptor_number) { |
3301 return kFirstIndex + (descriptor_number * kDescriptorSize) + | 3301 return kFirstIndex + (descriptor_number * kEntrySize) + kEntryValueIndex; |
3302 kDescriptorValue; | |
3303 } | 3302 } |
3304 | 3303 |
3305 private: | 3304 private: |
3306 // Transfer a complete descriptor from the src descriptor array to this | 3305 // Transfer a complete descriptor from the src descriptor array to this |
3307 // descriptor array. | 3306 // descriptor array. |
3308 void CopyFrom(int index, DescriptorArray* src); | 3307 void CopyFrom(int index, DescriptorArray* src); |
3309 | 3308 |
3310 // Swap first and second descriptor. | 3309 // Swap first and second descriptor. |
3311 inline void SwapSortedKeys(int first, int second); | 3310 inline void SwapSortedKeys(int first, int second); |
3312 | 3311 |
(...skipping 8318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11631 } | 11630 } |
11632 }; | 11631 }; |
11633 | 11632 |
11634 | 11633 |
11635 } // NOLINT, false-positive due to second-order macros. | 11634 } // NOLINT, false-positive due to second-order macros. |
11636 } // NOLINT, false-positive due to second-order macros. | 11635 } // NOLINT, false-positive due to second-order macros. |
11637 | 11636 |
11638 #include "src/objects/object-macros-undef.h" | 11637 #include "src/objects/object-macros-undef.h" |
11639 | 11638 |
11640 #endif // V8_OBJECTS_H_ | 11639 #endif // V8_OBJECTS_H_ |
OLD | NEW |