Chromium Code Reviews| 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 10736 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 10747 // Only unique keys are kept by the KeyAccumulator, strings are stored in a | 10747 // Only unique keys are kept by the KeyAccumulator, strings are stored in a |
| 10748 // HashSet for inexpensive lookups. Integer keys are kept in sorted lists which | 10748 // HashSet for inexpensive lookups. Integer keys are kept in sorted lists which |
| 10749 // are more compact and allow for reasonably fast includes check. | 10749 // are more compact and allow for reasonably fast includes check. |
| 10750 class KeyAccumulator final BASE_EMBEDDED { | 10750 class KeyAccumulator final BASE_EMBEDDED { |
| 10751 public: | 10751 public: |
| 10752 explicit KeyAccumulator(Isolate* isolate, | 10752 explicit KeyAccumulator(Isolate* isolate, |
| 10753 KeyFilter filter = KeyFilter::SKIP_SYMBOLS) | 10753 KeyFilter filter = KeyFilter::SKIP_SYMBOLS) |
| 10754 : isolate_(isolate), filter_(filter), length_(0), levelLength_(0) {} | 10754 : isolate_(isolate), filter_(filter), length_(0), levelLength_(0) {} |
| 10755 ~KeyAccumulator(); | 10755 ~KeyAccumulator(); |
| 10756 | 10756 |
| 10757 enum ElementKeyAddCheckLimit { EXCLUDE_CURRENT_LEVEL, INCLUDE_CURRENT_LEVEL }; | |
| 10758 | |
| 10757 bool AddKey(uint32_t key); | 10759 bool AddKey(uint32_t key); |
| 10758 bool AddKey(Object* key, AddKeyConversion convert = DO_NOT_CONVERT); | 10760 bool AddKey(Object* key, AddKeyConversion convert = DO_NOT_CONVERT); |
| 10759 bool AddKey(Handle<Object> key, AddKeyConversion convert = DO_NOT_CONVERT); | 10761 bool AddKey(Handle<Object> key, AddKeyConversion convert = DO_NOT_CONVERT); |
| 10760 void AddKeys(Handle<FixedArray> array, | 10762 void AddKeys(Handle<FixedArray> array, |
| 10761 AddKeyConversion convert = DO_NOT_CONVERT); | 10763 AddKeyConversion convert = DO_NOT_CONVERT); |
| 10762 void AddKeys(Handle<JSObject> array, | 10764 void AddKeys(Handle<JSObject> array, |
| 10763 AddKeyConversion convert = DO_NOT_CONVERT); | 10765 AddKeyConversion convert = DO_NOT_CONVERT); |
| 10764 void AddKeysFromProxy(Handle<JSObject> array); | 10766 void AddKeysFromProxy(Handle<JSObject> array); |
| 10767 void AddKeysFromInterceptor(Handle<JSObject> array); | |
| 10765 // Jump to the next level, pushing the current |levelLength_| to | 10768 // Jump to the next level, pushing the current |levelLength_| to |
| 10766 // |levelLengths_| and adding a new list to |elements_|. | 10769 // |levelLengths_| and adding a new list to |elements_|. |
| 10767 void NextPrototype(); | 10770 void NextPrototype(); |
| 10768 // Sort the integer indices in the last list in |elements_| | 10771 // Sort the integer indices in the last list in |elements_| |
| 10769 void SortCurrentElementsList(); | 10772 void SortCurrentElementsList(); |
| 10770 Handle<FixedArray> GetKeys(GetKeysConversion convert = KEEP_NUMBERS); | 10773 Handle<FixedArray> GetKeys(GetKeysConversion convert = KEEP_NUMBERS); |
| 10771 | 10774 |
| 10772 | 10775 |
| 10773 private: | 10776 private: |
| 10774 Isolate* isolate_; | 10777 Isolate* isolate_; |
| 10775 KeyFilter filter_; | 10778 KeyFilter filter_; |
| 10776 // |elements_| contains the sorted element keys (indices) per level. | 10779 // |elements_| contains the sorted element keys (indices) per level. |
| 10777 List<List<uint32_t>*> elements_; | 10780 std::vector<std::vector<uint32_t>*> elements_; |
|
Igor Sheludko
2015/10/22 21:42:57
Suggestion: use std::unique_ptr:
std::vector<std
Camillo Bruni
2015/10/23 08:56:35
I think I prefer not using smart pointers since we
| |
| 10778 // |protoLengths_| contains the total number of keys (elements + properties) | 10781 // |protoLengths_| contains the total number of keys (elements + properties) |
| 10779 // per level. Negative values mark counts for a level with keys from a proxy. | 10782 // per level. Negative values mark counts for a level with keys from a proxy. |
| 10780 List<int> levelLengths_; | 10783 std::vector<int> levelLengths_; |
| 10781 // |properties_| contains the property keys per level in insertion order. | 10784 // |properties_| contains the property keys per level in insertion order. |
| 10782 Handle<OrderedHashSet> properties_; | 10785 Handle<OrderedHashSet> properties_; |
| 10783 // |length_| keeps track of the total number of all element and property keys. | 10786 // |length_| keeps track of the total number of all element and property keys. |
| 10784 int length_; | 10787 int length_; |
| 10785 // |levelLength_| keeps track of the total number of keys | 10788 // |levelLength_| keeps track of the total number of keys |
| 10786 // (elements + properties) in the current level. | 10789 // (elements + properties) in the current level. |
| 10787 int levelLength_; | 10790 int levelLength_; |
| 10791 // Indicate where to stop looking for duplicates when adding new element keys. | |
| 10792 ElementKeyAddCheckLimit elementKeysAddCheckLimit_ = EXCLUDE_CURRENT_LEVEL; | |
|
Igor Sheludko
2015/10/22 21:42:57
Nice! What about initializing lengths fields this
Camillo Bruni
2015/10/23 08:56:35
done
| |
| 10788 | 10793 |
| 10789 DISALLOW_COPY_AND_ASSIGN(KeyAccumulator); | 10794 DISALLOW_COPY_AND_ASSIGN(KeyAccumulator); |
| 10790 }; | 10795 }; |
| 10791 | 10796 |
| 10792 } // NOLINT, false-positive due to second-order macros. | 10797 } // NOLINT, false-positive due to second-order macros. |
| 10793 } // NOLINT, false-positive due to second-order macros. | 10798 } // NOLINT, false-positive due to second-order macros. |
| 10794 | 10799 |
| 10795 #endif // V8_OBJECTS_H_ | 10800 #endif // V8_OBJECTS_H_ |
| OLD | NEW |