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_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 | 9 |
10 #include "src/allocation.h" | 10 #include "src/allocation.h" |
(...skipping 2954 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2965 bool IsEqualTo(DescriptorArray* other); | 2965 bool IsEqualTo(DescriptorArray* other); |
2966 #endif | 2966 #endif |
2967 | 2967 |
2968 // Returns the fixed array length required to hold number_of_descriptors | 2968 // Returns the fixed array length required to hold number_of_descriptors |
2969 // descriptors. | 2969 // descriptors. |
2970 static int LengthFor(int number_of_descriptors) { | 2970 static int LengthFor(int number_of_descriptors) { |
2971 return ToKeyIndex(number_of_descriptors); | 2971 return ToKeyIndex(number_of_descriptors); |
2972 } | 2972 } |
2973 | 2973 |
2974 private: | 2974 private: |
2975 // WhitenessWitness is used to prove that a descriptor array is white | |
2976 // (unmarked), so incremental write barriers can be skipped because the | |
2977 // marking invariant cannot be broken and slots pointing into evacuation | |
2978 // candidates will be discovered when the object is scanned. A witness is | |
2979 // always stack-allocated right after creating an array. By allocating a | |
2980 // witness, incremental marking is globally disabled. The witness is then | |
2981 // passed along wherever needed to statically prove that the array is known to | |
2982 // be white. | |
2983 class WhitenessWitness { | |
2984 public: | |
2985 inline explicit WhitenessWitness(DescriptorArray* array); | |
2986 inline ~WhitenessWitness(); | |
2987 | |
2988 private: | |
2989 IncrementalMarking* marking_; | |
2990 }; | |
2991 | |
2992 // An entry in a DescriptorArray, represented as an (array, index) pair. | 2975 // An entry in a DescriptorArray, represented as an (array, index) pair. |
2993 class Entry { | 2976 class Entry { |
2994 public: | 2977 public: |
2995 inline explicit Entry(DescriptorArray* descs, int index) : | 2978 inline explicit Entry(DescriptorArray* descs, int index) : |
2996 descs_(descs), index_(index) { } | 2979 descs_(descs), index_(index) { } |
2997 | 2980 |
2998 inline PropertyType type(); | 2981 inline PropertyType type(); |
2999 inline Object* GetCallbackObject(); | 2982 inline Object* GetCallbackObject(); |
3000 | 2983 |
3001 private: | 2984 private: |
(...skipping 15 matching lines...) Expand all Loading... |
3017 } | 3000 } |
3018 | 3001 |
3019 static int ToValueIndex(int descriptor_number) { | 3002 static int ToValueIndex(int descriptor_number) { |
3020 return kFirstIndex + | 3003 return kFirstIndex + |
3021 (descriptor_number * kDescriptorSize) + | 3004 (descriptor_number * kDescriptorSize) + |
3022 kDescriptorValue; | 3005 kDescriptorValue; |
3023 } | 3006 } |
3024 | 3007 |
3025 // Transfer a complete descriptor from the src descriptor array to this | 3008 // Transfer a complete descriptor from the src descriptor array to this |
3026 // descriptor array. | 3009 // descriptor array. |
3027 void CopyFrom(int index, DescriptorArray* src, const WhitenessWitness&); | 3010 void CopyFrom(int index, DescriptorArray* src); |
3028 | 3011 |
3029 inline void Set(int descriptor_number, | 3012 inline void SetDescriptor(int descriptor_number, Descriptor* desc); |
3030 Descriptor* desc, | |
3031 const WhitenessWitness&); | |
3032 | 3013 |
3033 // Swap first and second descriptor. | 3014 // Swap first and second descriptor. |
3034 inline void SwapSortedKeys(int first, int second); | 3015 inline void SwapSortedKeys(int first, int second); |
3035 | 3016 |
3036 DISALLOW_IMPLICIT_CONSTRUCTORS(DescriptorArray); | 3017 DISALLOW_IMPLICIT_CONSTRUCTORS(DescriptorArray); |
3037 }; | 3018 }; |
3038 | 3019 |
3039 | 3020 |
3040 enum SearchMode { ALL_ENTRIES, VALID_ENTRIES }; | 3021 enum SearchMode { ALL_ENTRIES, VALID_ENTRIES }; |
3041 | 3022 |
(...skipping 7697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10739 } | 10720 } |
10740 return value; | 10721 return value; |
10741 } | 10722 } |
10742 }; | 10723 }; |
10743 | 10724 |
10744 | 10725 |
10745 } // NOLINT, false-positive due to second-order macros. | 10726 } // NOLINT, false-positive due to second-order macros. |
10746 } // NOLINT, false-positive due to second-order macros. | 10727 } // NOLINT, false-positive due to second-order macros. |
10747 | 10728 |
10748 #endif // V8_OBJECTS_H_ | 10729 #endif // V8_OBJECTS_H_ |
OLD | NEW |