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 10783 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10794 // level later when assembling the final list, |levelLengths_| keeps track of | 10794 // level later when assembling the final list, |levelLengths_| keeps track of |
10795 // the total number of keys (integers + strings) per level. | 10795 // the total number of keys (integers + strings) per level. |
10796 // | 10796 // |
10797 // Only unique keys are kept by the KeyAccumulator, strings are stored in a | 10797 // Only unique keys are kept by the KeyAccumulator, strings are stored in a |
10798 // HashSet for inexpensive lookups. Integer keys are kept in sorted lists which | 10798 // HashSet for inexpensive lookups. Integer keys are kept in sorted lists which |
10799 // are more compact and allow for reasonably fast includes check. | 10799 // are more compact and allow for reasonably fast includes check. |
10800 class KeyAccumulator final BASE_EMBEDDED { | 10800 class KeyAccumulator final BASE_EMBEDDED { |
10801 public: | 10801 public: |
10802 explicit KeyAccumulator(Isolate* isolate, | 10802 explicit KeyAccumulator(Isolate* isolate, |
10803 KeyFilter filter = KeyFilter::SKIP_SYMBOLS) | 10803 KeyFilter filter = KeyFilter::SKIP_SYMBOLS) |
10804 : isolate_(isolate), filter_(filter), length_(0), levelLength_(0) {} | 10804 : isolate_(isolate), filter_(filter) {} |
10805 ~KeyAccumulator(); | 10805 ~KeyAccumulator(); |
10806 | 10806 |
10807 bool AddKey(uint32_t key); | 10807 bool AddKey(uint32_t key); |
10808 bool AddKey(Object* key, AddKeyConversion convert = DO_NOT_CONVERT); | 10808 bool AddKey(Object* key, AddKeyConversion convert = DO_NOT_CONVERT); |
10809 bool AddKey(Handle<Object> key, AddKeyConversion convert = DO_NOT_CONVERT); | 10809 bool AddKey(Handle<Object> key, AddKeyConversion convert = DO_NOT_CONVERT); |
10810 void AddKeys(Handle<FixedArray> array, | 10810 void AddKeys(Handle<FixedArray> array, |
10811 AddKeyConversion convert = DO_NOT_CONVERT); | 10811 AddKeyConversion convert = DO_NOT_CONVERT); |
10812 void AddKeys(Handle<JSObject> array, | 10812 void AddKeys(Handle<JSObject> array, |
10813 AddKeyConversion convert = DO_NOT_CONVERT); | 10813 AddKeyConversion convert = DO_NOT_CONVERT); |
10814 void AddKeysFromProxy(Handle<JSObject> array); | 10814 void AddKeysFromProxy(Handle<JSObject> array); |
| 10815 void AddElementKeysFromInterceptor(Handle<JSObject> array); |
10815 // Jump to the next level, pushing the current |levelLength_| to | 10816 // Jump to the next level, pushing the current |levelLength_| to |
10816 // |levelLengths_| and adding a new list to |elements_|. | 10817 // |levelLengths_| and adding a new list to |elements_|. |
10817 void NextPrototype(); | 10818 void NextPrototype(); |
10818 // Sort the integer indices in the last list in |elements_| | 10819 // Sort the integer indices in the last list in |elements_| |
10819 void SortCurrentElementsList(); | 10820 void SortCurrentElementsList(); |
| 10821 void SortCurrentElementsListRemoveDuplicates(); |
10820 Handle<FixedArray> GetKeys(GetKeysConversion convert = KEEP_NUMBERS); | 10822 Handle<FixedArray> GetKeys(GetKeysConversion convert = KEEP_NUMBERS); |
10821 | 10823 |
10822 | 10824 |
10823 private: | 10825 private: |
10824 Isolate* isolate_; | 10826 Isolate* isolate_; |
10825 KeyFilter filter_; | 10827 KeyFilter filter_; |
10826 // |elements_| contains the sorted element keys (indices) per level. | 10828 // |elements_| contains the sorted element keys (indices) per level. |
10827 List<List<uint32_t>*> elements_; | 10829 std::vector<std::vector<uint32_t>*> elements_; |
10828 // |protoLengths_| contains the total number of keys (elements + properties) | 10830 // |protoLengths_| contains the total number of keys (elements + properties) |
10829 // per level. Negative values mark counts for a level with keys from a proxy. | 10831 // per level. Negative values mark counts for a level with keys from a proxy. |
10830 List<int> levelLengths_; | 10832 std::vector<int> levelLengths_; |
10831 // |properties_| contains the property keys per level in insertion order. | 10833 // |properties_| contains the property keys per level in insertion order. |
10832 Handle<OrderedHashSet> properties_; | 10834 Handle<OrderedHashSet> properties_; |
10833 // |length_| keeps track of the total number of all element and property keys. | 10835 // |length_| keeps track of the total number of all element and property keys. |
10834 int length_; | 10836 int length_ = 0; |
10835 // |levelLength_| keeps track of the total number of keys | 10837 // |levelLength_| keeps track of the total number of keys |
10836 // (elements + properties) in the current level. | 10838 // (elements + properties) in the current level. |
10837 int levelLength_; | 10839 int levelLength_ = 0; |
10838 | 10840 |
10839 DISALLOW_COPY_AND_ASSIGN(KeyAccumulator); | 10841 DISALLOW_COPY_AND_ASSIGN(KeyAccumulator); |
10840 }; | 10842 }; |
10841 | 10843 |
10842 } // NOLINT, false-positive due to second-order macros. | 10844 } // NOLINT, false-positive due to second-order macros. |
10843 } // NOLINT, false-positive due to second-order macros. | 10845 } // NOLINT, false-positive due to second-order macros. |
10844 | 10846 |
10845 #endif // V8_OBJECTS_H_ | 10847 #endif // V8_OBJECTS_H_ |
OLD | NEW |