| 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_KEY_ACCUMULATOR_H_ | 5 #ifndef V8_KEY_ACCUMULATOR_H_ |
| 6 #define V8_KEY_ACCUMULATOR_H_ | 6 #define V8_KEY_ACCUMULATOR_H_ |
| 7 | 7 |
| 8 #include "src/isolate.h" | 8 #include "src/isolate.h" |
| 9 #include "src/objects.h" | 9 #include "src/objects.h" |
| 10 | 10 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 Maybe<bool> AddKeysFromProxy(Handle<JSProxy> proxy, Handle<FixedArray> keys); | 45 Maybe<bool> AddKeysFromProxy(Handle<JSProxy> proxy, Handle<FixedArray> keys); |
| 46 void AddElementKeysFromInterceptor(Handle<JSObject> array); | 46 void AddElementKeysFromInterceptor(Handle<JSObject> array); |
| 47 // Jump to the next level, pushing the current |levelLength_| to | 47 // Jump to the next level, pushing the current |levelLength_| to |
| 48 // |levelLengths_| and adding a new list to |elements_|. | 48 // |levelLengths_| and adding a new list to |elements_|. |
| 49 void NextPrototype(); | 49 void NextPrototype(); |
| 50 // Sort the integer indices in the last list in |elements_| | 50 // Sort the integer indices in the last list in |elements_| |
| 51 void SortCurrentElementsList(); | 51 void SortCurrentElementsList(); |
| 52 Handle<FixedArray> GetKeys(GetKeysConversion convert = KEEP_NUMBERS); | 52 Handle<FixedArray> GetKeys(GetKeysConversion convert = KEEP_NUMBERS); |
| 53 int length() { return length_; } | 53 int length() { return length_; } |
| 54 Isolate* isolate() { return isolate_; } | 54 Isolate* isolate() { return isolate_; } |
| 55 void set_filter_proxy_keys(bool filter) { filter_proxy_keys_ = filter; } |
| 55 | 56 |
| 56 private: | 57 private: |
| 57 bool AddIntegerKey(uint32_t key); | 58 bool AddIntegerKey(uint32_t key); |
| 58 bool AddStringKey(Handle<Object> key, AddKeyConversion convert); | 59 bool AddStringKey(Handle<Object> key, AddKeyConversion convert); |
| 59 bool AddSymbolKey(Handle<Object> array); | 60 bool AddSymbolKey(Handle<Object> array); |
| 60 void SortCurrentElementsListRemoveDuplicates(); | 61 void SortCurrentElementsListRemoveDuplicates(); |
| 61 | 62 |
| 62 Isolate* isolate_; | 63 Isolate* isolate_; |
| 63 KeyCollectionType type_; | 64 KeyCollectionType type_; |
| 64 PropertyFilter filter_; | 65 PropertyFilter filter_; |
| 66 bool filter_proxy_keys_ = true; |
| 65 // |elements_| contains the sorted element keys (indices) per level. | 67 // |elements_| contains the sorted element keys (indices) per level. |
| 66 std::vector<std::vector<uint32_t>*> elements_; | 68 std::vector<std::vector<uint32_t>*> elements_; |
| 67 // |protoLengths_| contains the total number of keys (elements + properties) | 69 // |protoLengths_| contains the total number of keys (elements + properties) |
| 68 // per level. Negative values mark counts for a level with keys from a proxy. | 70 // per level. Negative values mark counts for a level with keys from a proxy. |
| 69 std::vector<int> level_lengths_; | 71 std::vector<int> level_lengths_; |
| 70 // |string_properties_| contains the unique String property keys for all | 72 // |string_properties_| contains the unique String property keys for all |
| 71 // levels in insertion order per level. | 73 // levels in insertion order per level. |
| 72 Handle<OrderedHashSet> string_properties_; | 74 Handle<OrderedHashSet> string_properties_; |
| 73 // |symbol_properties_| contains the unique Symbol property keys for all | 75 // |symbol_properties_| contains the unique Symbol property keys for all |
| 74 // levels in insertion order per level. | 76 // levels in insertion order per level. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 94 FastKeyAccumulator(Isolate* isolate, Handle<JSReceiver> receiver, | 96 FastKeyAccumulator(Isolate* isolate, Handle<JSReceiver> receiver, |
| 95 KeyCollectionType type, PropertyFilter filter) | 97 KeyCollectionType type, PropertyFilter filter) |
| 96 : isolate_(isolate), receiver_(receiver), type_(type), filter_(filter) { | 98 : isolate_(isolate), receiver_(receiver), type_(type), filter_(filter) { |
| 97 Prepare(); | 99 Prepare(); |
| 98 // TODO(cbruni): pass filter_ directly to the KeyAccumulator. | 100 // TODO(cbruni): pass filter_ directly to the KeyAccumulator. |
| 99 USE(filter_); | 101 USE(filter_); |
| 100 } | 102 } |
| 101 | 103 |
| 102 bool is_receiver_simple_enum() { return is_receiver_simple_enum_; } | 104 bool is_receiver_simple_enum() { return is_receiver_simple_enum_; } |
| 103 bool has_empty_prototype() { return has_empty_prototype_; } | 105 bool has_empty_prototype() { return has_empty_prototype_; } |
| 106 void set_filter_proxy_keys(bool filter) { filter_proxy_keys_ = filter; } |
| 104 | 107 |
| 105 MaybeHandle<FixedArray> GetKeys(GetKeysConversion convert = KEEP_NUMBERS); | 108 MaybeHandle<FixedArray> GetKeys(GetKeysConversion convert = KEEP_NUMBERS); |
| 106 | 109 |
| 107 private: | 110 private: |
| 108 void Prepare(); | 111 void Prepare(); |
| 109 MaybeHandle<FixedArray> GetKeysFast(GetKeysConversion convert); | 112 MaybeHandle<FixedArray> GetKeysFast(GetKeysConversion convert); |
| 110 MaybeHandle<FixedArray> GetKeysSlow(GetKeysConversion convert); | 113 MaybeHandle<FixedArray> GetKeysSlow(GetKeysConversion convert); |
| 111 | 114 |
| 112 Isolate* isolate_; | 115 Isolate* isolate_; |
| 113 Handle<JSReceiver> receiver_; | 116 Handle<JSReceiver> receiver_; |
| 114 KeyCollectionType type_; | 117 KeyCollectionType type_; |
| 115 PropertyFilter filter_; | 118 PropertyFilter filter_; |
| 116 bool is_receiver_simple_enum_ = false; | 119 bool is_receiver_simple_enum_ = false; |
| 117 bool has_empty_prototype_ = false; | 120 bool has_empty_prototype_ = false; |
| 121 bool filter_proxy_keys_ = true; |
| 118 | 122 |
| 119 DISALLOW_COPY_AND_ASSIGN(FastKeyAccumulator); | 123 DISALLOW_COPY_AND_ASSIGN(FastKeyAccumulator); |
| 120 }; | 124 }; |
| 121 | 125 |
| 122 } // namespace internal | 126 } // namespace internal |
| 123 } // namespace v8 | 127 } // namespace v8 |
| 124 | 128 |
| 125 #endif // V8_KEY_ACCUMULATOR_H_ | 129 #endif // V8_KEY_ACCUMULATOR_H_ |
| OLD | NEW |