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_KEYS_H_ | 5 #ifndef V8_KEYS_H_ |
6 #define V8_KEYS_H_ | 6 #define V8_KEYS_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 18 matching lines...) Expand all Loading... |
29 // Only unique keys are kept by the KeyAccumulator, strings are stored in a | 29 // Only unique keys are kept by the KeyAccumulator, strings are stored in a |
30 // HashSet for inexpensive lookups. Integer keys are kept in sorted lists which | 30 // HashSet for inexpensive lookups. Integer keys are kept in sorted lists which |
31 // are more compact and allow for reasonably fast includes check. | 31 // are more compact and allow for reasonably fast includes check. |
32 class KeyAccumulator final BASE_EMBEDDED { | 32 class KeyAccumulator final BASE_EMBEDDED { |
33 public: | 33 public: |
34 KeyAccumulator(Isolate* isolate, KeyCollectionType type, | 34 KeyAccumulator(Isolate* isolate, KeyCollectionType type, |
35 PropertyFilter filter) | 35 PropertyFilter filter) |
36 : isolate_(isolate), type_(type), filter_(filter) {} | 36 : isolate_(isolate), type_(type), filter_(filter) {} |
37 ~KeyAccumulator(); | 37 ~KeyAccumulator(); |
38 | 38 |
| 39 static MaybeHandle<FixedArray> GetKeys(Handle<JSReceiver> object, |
| 40 KeyCollectionType type, |
| 41 PropertyFilter filter, |
| 42 GetKeysConversion keys_conversion, |
| 43 bool filter_proxy_keys); |
39 Handle<FixedArray> GetKeys(GetKeysConversion convert = KEEP_NUMBERS); | 44 Handle<FixedArray> GetKeys(GetKeysConversion convert = KEEP_NUMBERS); |
40 Maybe<bool> CollectKeys(Handle<JSReceiver> receiver, | 45 Maybe<bool> CollectKeys(Handle<JSReceiver> receiver, |
41 Handle<JSReceiver> object); | 46 Handle<JSReceiver> object); |
42 void CollectOwnElementIndices(Handle<JSObject> object); | 47 void CollectOwnElementIndices(Handle<JSObject> object); |
43 void CollectOwnPropertyNames(Handle<JSObject> object); | 48 void CollectOwnPropertyNames(Handle<JSObject> object); |
44 | 49 |
45 static Handle<FixedArray> GetEnumPropertyKeys(Isolate* isolate, | 50 static Handle<FixedArray> GetEnumPropertyKeys(Isolate* isolate, |
46 Handle<JSObject> object); | 51 Handle<JSObject> object); |
47 | 52 |
48 bool AddKey(uint32_t key); | 53 bool AddKey(uint32_t key); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 | 113 |
109 // The FastKeyAccumulator handles the cases where there are no elements on the | 114 // The FastKeyAccumulator handles the cases where there are no elements on the |
110 // prototype chain and forwords the complex/slow cases to the normal | 115 // prototype chain and forwords the complex/slow cases to the normal |
111 // KeyAccumulator. | 116 // KeyAccumulator. |
112 class FastKeyAccumulator { | 117 class FastKeyAccumulator { |
113 public: | 118 public: |
114 FastKeyAccumulator(Isolate* isolate, Handle<JSReceiver> receiver, | 119 FastKeyAccumulator(Isolate* isolate, Handle<JSReceiver> receiver, |
115 KeyCollectionType type, PropertyFilter filter) | 120 KeyCollectionType type, PropertyFilter filter) |
116 : isolate_(isolate), receiver_(receiver), type_(type), filter_(filter) { | 121 : isolate_(isolate), receiver_(receiver), type_(type), filter_(filter) { |
117 Prepare(); | 122 Prepare(); |
118 // TODO(cbruni): pass filter_ directly to the KeyAccumulator. | |
119 USE(filter_); | |
120 } | 123 } |
121 | 124 |
122 bool is_receiver_simple_enum() { return is_receiver_simple_enum_; } | 125 bool is_receiver_simple_enum() { return is_receiver_simple_enum_; } |
123 bool has_empty_prototype() { return has_empty_prototype_; } | 126 bool has_empty_prototype() { return has_empty_prototype_; } |
124 void set_filter_proxy_keys(bool filter) { filter_proxy_keys_ = filter; } | 127 void set_filter_proxy_keys(bool filter) { filter_proxy_keys_ = filter; } |
125 | 128 |
126 MaybeHandle<FixedArray> GetKeys(GetKeysConversion convert = KEEP_NUMBERS); | 129 MaybeHandle<FixedArray> GetKeys(GetKeysConversion convert = KEEP_NUMBERS); |
127 | 130 |
128 private: | 131 private: |
129 void Prepare(); | 132 void Prepare(); |
130 MaybeHandle<FixedArray> GetKeysFast(GetKeysConversion convert); | 133 MaybeHandle<FixedArray> GetKeysFast(GetKeysConversion convert); |
131 MaybeHandle<FixedArray> GetKeysSlow(GetKeysConversion convert); | 134 MaybeHandle<FixedArray> GetKeysSlow(GetKeysConversion convert); |
132 | 135 |
133 Isolate* isolate_; | 136 Isolate* isolate_; |
134 Handle<JSReceiver> receiver_; | 137 Handle<JSReceiver> receiver_; |
135 KeyCollectionType type_; | 138 KeyCollectionType type_; |
136 PropertyFilter filter_; | 139 PropertyFilter filter_; |
| 140 bool filter_proxy_keys_ = true; |
137 bool is_receiver_simple_enum_ = false; | 141 bool is_receiver_simple_enum_ = false; |
138 bool has_empty_prototype_ = false; | 142 bool has_empty_prototype_ = false; |
139 bool filter_proxy_keys_ = true; | |
140 | 143 |
141 DISALLOW_COPY_AND_ASSIGN(FastKeyAccumulator); | 144 DISALLOW_COPY_AND_ASSIGN(FastKeyAccumulator); |
142 }; | 145 }; |
143 | 146 |
144 } // namespace internal | 147 } // namespace internal |
145 } // namespace v8 | 148 } // namespace v8 |
146 | 149 |
147 #endif // V8_KEYS_H_ | 150 #endif // V8_KEYS_H_ |
OLD | NEW |