Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(185)

Side by Side Diff: src/keys.h

Issue 2002203002: [api] Add more parameters to Object::GetPropertyNames (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@2016-05-06_keys_fast_path_1995263002
Patch Set: reverting accidental formatting Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 13 matching lines...) Expand all
24 // collected in |string_properties_|, a single OrderedHashSet (similar for 24 // collected in |string_properties_|, a single OrderedHashSet (similar for
25 // Symbols in |symbol_properties_|. To separate the keys per level later when 25 // Symbols in |symbol_properties_|. To separate the keys per level later when
26 // assembling the final list, |levelLengths_| keeps track of the number of 26 // assembling the final list, |levelLengths_| keeps track of the number of
27 // String and Symbol keys per level. 27 // String and Symbol keys per level.
28 // 28 //
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, KeysCollectionLimit type,
Igor Sheludko 2016/05/25 14:52:56 I would rename |type| here, below and above as wel
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( 39 static MaybeHandle<FixedArray> GetKeys(
40 Handle<JSReceiver> object, KeyCollectionType type, PropertyFilter filter, 40 Handle<JSReceiver> object, KeysCollectionLimit type,
41 GetKeysConversion keys_conversion = KEEP_NUMBERS, 41 PropertyFilter filter, GetKeysConversion keys_conversion = KEEP_NUMBERS,
42 bool filter_proxy_keys = true, bool is_for_in = false); 42 bool filter_proxy_keys = true, bool is_for_in = false);
43 Handle<FixedArray> GetKeys(GetKeysConversion convert = KEEP_NUMBERS); 43 Handle<FixedArray> GetKeys(GetKeysConversion convert = KEEP_NUMBERS);
44 Maybe<bool> CollectKeys(Handle<JSReceiver> receiver, 44 Maybe<bool> CollectKeys(Handle<JSReceiver> receiver,
45 Handle<JSReceiver> object); 45 Handle<JSReceiver> object);
46 Maybe<bool> CollectOwnElementIndices(Handle<JSReceiver> receiver, 46 Maybe<bool> CollectOwnElementIndices(Handle<JSReceiver> receiver,
47 Handle<JSObject> object); 47 Handle<JSObject> object);
48 Maybe<bool> CollectOwnPropertyNames(Handle<JSReceiver> receiver, 48 Maybe<bool> CollectOwnPropertyNames(Handle<JSReceiver> receiver,
49 Handle<JSObject> object); 49 Handle<JSObject> object);
50 50
51 static Handle<FixedArray> GetEnumPropertyKeys(Isolate* isolate, 51 static Handle<FixedArray> GetEnumPropertyKeys(Isolate* isolate,
(...skipping 22 matching lines...) Expand all
74 74
75 Maybe<bool> AddKeysFromJSProxy(Handle<JSProxy> proxy, 75 Maybe<bool> AddKeysFromJSProxy(Handle<JSProxy> proxy,
76 Handle<FixedArray> keys); 76 Handle<FixedArray> keys);
77 77
78 Handle<OrderedHashSet> keys() { return Handle<OrderedHashSet>::cast(keys_); } 78 Handle<OrderedHashSet> keys() { return Handle<OrderedHashSet>::cast(keys_); }
79 79
80 Isolate* isolate_; 80 Isolate* isolate_;
81 // keys_ is either an Handle<OrderedHashSet> or in the case of own JSProxy 81 // keys_ is either an Handle<OrderedHashSet> or in the case of own JSProxy
82 // keys a Handle<FixedArray>. 82 // keys a Handle<FixedArray>.
83 Handle<FixedArray> keys_; 83 Handle<FixedArray> keys_;
84 KeyCollectionType type_; 84 KeysCollectionLimit type_;
85 PropertyFilter filter_; 85 PropertyFilter filter_;
86 bool filter_proxy_keys_ = true; 86 bool filter_proxy_keys_ = true;
87 bool is_for_in_ = false; 87 bool is_for_in_ = false;
88 bool skip_indices_ = false; 88 bool skip_indices_ = false;
89 89
90 DISALLOW_COPY_AND_ASSIGN(KeyAccumulator); 90 DISALLOW_COPY_AND_ASSIGN(KeyAccumulator);
91 }; 91 };
92 92
93 // The FastKeyAccumulator handles the cases where there are no elements on the 93 // The FastKeyAccumulator handles the cases where there are no elements on the
94 // prototype chain and forwords the complex/slow cases to the normal 94 // prototype chain and forwords the complex/slow cases to the normal
95 // KeyAccumulator. 95 // KeyAccumulator.
96 class FastKeyAccumulator { 96 class FastKeyAccumulator {
97 public: 97 public:
98 FastKeyAccumulator(Isolate* isolate, Handle<JSReceiver> receiver, 98 FastKeyAccumulator(Isolate* isolate, Handle<JSReceiver> receiver,
99 KeyCollectionType type, PropertyFilter filter) 99 KeysCollectionLimit type, PropertyFilter filter)
100 : isolate_(isolate), receiver_(receiver), type_(type), filter_(filter) { 100 : isolate_(isolate), receiver_(receiver), type_(type), filter_(filter) {
101 Prepare(); 101 Prepare();
102 } 102 }
103 103
104 bool is_receiver_simple_enum() { return is_receiver_simple_enum_; } 104 bool is_receiver_simple_enum() { return is_receiver_simple_enum_; }
105 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; } 106 void set_filter_proxy_keys(bool filter) { filter_proxy_keys_ = filter; }
107 void set_is_for_in(bool value) { is_for_in_ = value; } 107 void set_is_for_in(bool value) { is_for_in_ = value; }
108 108
109 MaybeHandle<FixedArray> GetKeys(GetKeysConversion convert = KEEP_NUMBERS); 109 MaybeHandle<FixedArray> GetKeys(GetKeysConversion convert = KEEP_NUMBERS);
110 110
111 private: 111 private:
112 void Prepare(); 112 void Prepare();
113 MaybeHandle<FixedArray> GetKeysFast(GetKeysConversion convert); 113 MaybeHandle<FixedArray> GetKeysFast(GetKeysConversion convert);
114 MaybeHandle<FixedArray> GetKeysSlow(GetKeysConversion convert); 114 MaybeHandle<FixedArray> GetKeysSlow(GetKeysConversion convert);
115 115
116 Isolate* isolate_; 116 Isolate* isolate_;
117 Handle<JSReceiver> receiver_; 117 Handle<JSReceiver> receiver_;
118 KeyCollectionType type_; 118 KeysCollectionLimit type_;
119 PropertyFilter filter_; 119 PropertyFilter filter_;
120 bool filter_proxy_keys_ = true; 120 bool filter_proxy_keys_ = true;
121 bool is_for_in_ = false; 121 bool is_for_in_ = false;
122 bool is_receiver_simple_enum_ = false; 122 bool is_receiver_simple_enum_ = false;
123 bool has_empty_prototype_ = false; 123 bool has_empty_prototype_ = false;
124 124
125 DISALLOW_COPY_AND_ASSIGN(FastKeyAccumulator); 125 DISALLOW_COPY_AND_ASSIGN(FastKeyAccumulator);
126 }; 126 };
127 127
128 } // namespace internal 128 } // namespace internal
129 } // namespace v8 129 } // namespace v8
130 130
131 #endif // V8_KEYS_H_ 131 #endif // V8_KEYS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698