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 22 matching lines...) Expand all Loading... |
33 public: | 33 public: |
34 KeyAccumulator(Isolate* isolate, KeyCollectionMode mode, | 34 KeyAccumulator(Isolate* isolate, KeyCollectionMode mode, |
35 PropertyFilter filter) | 35 PropertyFilter filter) |
36 : isolate_(isolate), mode_(mode), filter_(filter) {} | 36 : isolate_(isolate), mode_(mode), filter_(filter) {} |
37 ~KeyAccumulator(); | 37 ~KeyAccumulator(); |
38 | 38 |
39 static MaybeHandle<FixedArray> GetKeys( | 39 static MaybeHandle<FixedArray> GetKeys( |
40 Handle<JSReceiver> object, KeyCollectionMode mode, PropertyFilter filter, | 40 Handle<JSReceiver> object, KeyCollectionMode mode, PropertyFilter filter, |
41 GetKeysConversion keys_conversion = GetKeysConversion::kKeepNumbers, | 41 GetKeysConversion keys_conversion = GetKeysConversion::kKeepNumbers, |
42 bool filter_proxy_keys = true, bool is_for_in = false); | 42 bool filter_proxy_keys = true, bool is_for_in = false); |
| 43 |
43 Handle<FixedArray> GetKeys( | 44 Handle<FixedArray> GetKeys( |
44 GetKeysConversion convert = GetKeysConversion::kKeepNumbers); | 45 GetKeysConversion convert = GetKeysConversion::kKeepNumbers); |
45 Maybe<bool> CollectKeys(Handle<JSReceiver> receiver, | 46 Maybe<bool> CollectKeys(Handle<JSReceiver> receiver, |
46 Handle<JSReceiver> object); | 47 Handle<JSReceiver> object); |
47 Maybe<bool> CollectOwnElementIndices(Handle<JSReceiver> receiver, | 48 Maybe<bool> CollectOwnElementIndices(Handle<JSReceiver> receiver, |
48 Handle<JSObject> object); | 49 Handle<JSObject> object); |
49 Maybe<bool> CollectOwnPropertyNames(Handle<JSReceiver> receiver, | 50 Maybe<bool> CollectOwnPropertyNames(Handle<JSReceiver> receiver, |
50 Handle<JSObject> object); | 51 Handle<JSObject> object); |
51 | 52 |
52 static Handle<FixedArray> GetEnumPropertyKeys(Isolate* isolate, | 53 static Handle<FixedArray> GetEnumPropertyKeys(Isolate* isolate, |
53 Handle<JSObject> object); | 54 Handle<JSObject> object); |
54 | 55 |
55 void AddKey(Object* key, AddKeyConversion convert = DO_NOT_CONVERT); | 56 void AddKey(Object* key, AddKeyConversion convert = DO_NOT_CONVERT); |
56 void AddKey(Handle<Object> key, AddKeyConversion convert = DO_NOT_CONVERT); | 57 void AddKey(Handle<Object> key, AddKeyConversion convert = DO_NOT_CONVERT); |
57 void AddKeys(Handle<FixedArray> array, AddKeyConversion convert); | 58 void AddKeys(Handle<FixedArray> array, AddKeyConversion convert); |
58 void AddKeys(Handle<JSObject> array_like, AddKeyConversion convert); | 59 void AddKeys(Handle<JSObject> array_like, AddKeyConversion convert); |
59 | 60 |
60 // Jump to the next level, pushing the current |levelLength_| to | 61 // Jump to the next level, pushing the current |levelLength_| to |
61 // |levelLengths_| and adding a new list to |elements_|. | 62 // |levelLengths_| and adding a new list to |elements_|. |
62 Isolate* isolate() { return isolate_; } | 63 Isolate* isolate() { return isolate_; } |
63 PropertyFilter filter() { return filter_; } | 64 PropertyFilter filter() { return filter_; } |
64 void set_filter_proxy_keys(bool filter) { filter_proxy_keys_ = filter; } | 65 void set_filter_proxy_keys(bool filter) { filter_proxy_keys_ = filter; } |
65 void set_is_for_in(bool value) { is_for_in_ = value; } | 66 void set_is_for_in(bool value) { is_for_in_ = value; } |
66 void set_skip_indices(bool value) { skip_indices_ = value; } | 67 void set_skip_indices(bool value) { skip_indices_ = value; } |
| 68 void set_last_non_empty_prototype(Handle<JSReceiver> object) { |
| 69 last_non_empty_prototype_ = object; |
| 70 } |
67 | 71 |
68 private: | 72 private: |
69 Maybe<bool> CollectOwnKeys(Handle<JSReceiver> receiver, | 73 Maybe<bool> CollectOwnKeys(Handle<JSReceiver> receiver, |
70 Handle<JSObject> object); | 74 Handle<JSObject> object); |
71 Maybe<bool> CollectOwnJSProxyKeys(Handle<JSReceiver> receiver, | 75 Maybe<bool> CollectOwnJSProxyKeys(Handle<JSReceiver> receiver, |
72 Handle<JSProxy> proxy); | 76 Handle<JSProxy> proxy); |
73 Maybe<bool> CollectOwnJSProxyTargetKeys(Handle<JSProxy> proxy, | 77 Maybe<bool> CollectOwnJSProxyTargetKeys(Handle<JSProxy> proxy, |
74 Handle<JSReceiver> target); | 78 Handle<JSReceiver> target); |
75 | 79 |
76 Maybe<bool> AddKeysFromJSProxy(Handle<JSProxy> proxy, | 80 Maybe<bool> AddKeysFromJSProxy(Handle<JSProxy> proxy, |
77 Handle<FixedArray> keys); | 81 Handle<FixedArray> keys); |
78 | 82 |
79 Handle<OrderedHashSet> keys() { return Handle<OrderedHashSet>::cast(keys_); } | 83 Handle<OrderedHashSet> keys() { return Handle<OrderedHashSet>::cast(keys_); } |
80 | 84 |
81 Isolate* isolate_; | 85 Isolate* isolate_; |
82 // keys_ is either an Handle<OrderedHashSet> or in the case of own JSProxy | 86 // keys_ is either an Handle<OrderedHashSet> or in the case of own JSProxy |
83 // keys a Handle<FixedArray>. | 87 // keys a Handle<FixedArray>. |
84 Handle<FixedArray> keys_; | 88 Handle<FixedArray> keys_; |
| 89 Handle<JSReceiver> last_non_empty_prototype_; |
85 KeyCollectionMode mode_; | 90 KeyCollectionMode mode_; |
86 PropertyFilter filter_; | 91 PropertyFilter filter_; |
87 bool filter_proxy_keys_ = true; | 92 bool filter_proxy_keys_ = true; |
88 bool is_for_in_ = false; | 93 bool is_for_in_ = false; |
89 bool skip_indices_ = false; | 94 bool skip_indices_ = false; |
90 | 95 |
91 DISALLOW_COPY_AND_ASSIGN(KeyAccumulator); | 96 DISALLOW_COPY_AND_ASSIGN(KeyAccumulator); |
92 }; | 97 }; |
93 | 98 |
94 // The FastKeyAccumulator handles the cases where there are no elements on the | 99 // The FastKeyAccumulator handles the cases where there are no elements on the |
(...skipping 15 matching lines...) Expand all Loading... |
110 MaybeHandle<FixedArray> GetKeys( | 115 MaybeHandle<FixedArray> GetKeys( |
111 GetKeysConversion convert = GetKeysConversion::kKeepNumbers); | 116 GetKeysConversion convert = GetKeysConversion::kKeepNumbers); |
112 | 117 |
113 private: | 118 private: |
114 void Prepare(); | 119 void Prepare(); |
115 MaybeHandle<FixedArray> GetKeysFast(GetKeysConversion convert); | 120 MaybeHandle<FixedArray> GetKeysFast(GetKeysConversion convert); |
116 MaybeHandle<FixedArray> GetKeysSlow(GetKeysConversion convert); | 121 MaybeHandle<FixedArray> GetKeysSlow(GetKeysConversion convert); |
117 | 122 |
118 Isolate* isolate_; | 123 Isolate* isolate_; |
119 Handle<JSReceiver> receiver_; | 124 Handle<JSReceiver> receiver_; |
| 125 Handle<JSReceiver> last_non_empty_prototype_; |
120 KeyCollectionMode mode_; | 126 KeyCollectionMode mode_; |
121 PropertyFilter filter_; | 127 PropertyFilter filter_; |
122 bool filter_proxy_keys_ = true; | 128 bool filter_proxy_keys_ = true; |
123 bool is_for_in_ = false; | 129 bool is_for_in_ = false; |
124 bool is_receiver_simple_enum_ = false; | 130 bool is_receiver_simple_enum_ = false; |
125 bool has_empty_prototype_ = false; | 131 bool has_empty_prototype_ = false; |
126 | 132 |
127 DISALLOW_COPY_AND_ASSIGN(FastKeyAccumulator); | 133 DISALLOW_COPY_AND_ASSIGN(FastKeyAccumulator); |
128 }; | 134 }; |
129 | 135 |
130 } // namespace internal | 136 } // namespace internal |
131 } // namespace v8 | 137 } // namespace v8 |
132 | 138 |
133 #endif // V8_KEYS_H_ | 139 #endif // V8_KEYS_H_ |
OLD | NEW |