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

Unified Diff: src/keys.h

Issue 2010593002: Revert of [keys] Simplify KeyAccumulator (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/json-stringifier.cc ('k') | src/keys.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/keys.h
diff --git a/src/keys.h b/src/keys.h
index 4f99bb5bd43e5e03ac9536fe01dea2de83cba18d..c73f10911df3c81f54ea875fa12bd1bfbfcf3b68 100644
--- a/src/keys.h
+++ b/src/keys.h
@@ -11,7 +11,7 @@
namespace v8 {
namespace internal {
-enum AddKeyConversion { DO_NOT_CONVERT, CONVERT_TO_ARRAY_INDEX };
+enum AddKeyConversion { DO_NOT_CONVERT, CONVERT_TO_ARRAY_INDEX, PROXY_MAGIC };
// This is a helper class for JSReceiver::GetKeys which collects and sorts keys.
// GetKeys needs to sort keys per prototype level, first showing the integer
@@ -36,33 +36,36 @@
: isolate_(isolate), type_(type), filter_(filter) {}
~KeyAccumulator();
- static MaybeHandle<FixedArray> GetKeys(
- Handle<JSReceiver> object, KeyCollectionType type, PropertyFilter filter,
- GetKeysConversion keys_conversion = KEEP_NUMBERS,
- bool filter_proxy_keys = true, bool is_for_in = false);
+ static MaybeHandle<FixedArray> GetKeys(Handle<JSReceiver> object,
+ KeyCollectionType type,
+ PropertyFilter filter,
+ GetKeysConversion keys_conversion,
+ bool filter_proxy_keys);
Handle<FixedArray> GetKeys(GetKeysConversion convert = KEEP_NUMBERS);
Maybe<bool> CollectKeys(Handle<JSReceiver> receiver,
Handle<JSReceiver> object);
- Maybe<bool> CollectOwnElementIndices(Handle<JSReceiver> receiver,
- Handle<JSObject> object);
- Maybe<bool> CollectOwnPropertyNames(Handle<JSReceiver> receiver,
- Handle<JSObject> object);
+ void CollectOwnElementIndices(Handle<JSObject> object);
+ void CollectOwnPropertyNames(Handle<JSObject> object);
static Handle<FixedArray> GetEnumPropertyKeys(Isolate* isolate,
Handle<JSObject> object);
- void AddKey(Object* key, AddKeyConversion convert = DO_NOT_CONVERT);
- void AddKey(Handle<Object> key, AddKeyConversion convert = DO_NOT_CONVERT);
+ bool AddKey(uint32_t key);
+ bool AddKey(Object* key, AddKeyConversion convert);
+ bool AddKey(Handle<Object> key, AddKeyConversion convert);
void AddKeys(Handle<FixedArray> array, AddKeyConversion convert);
- void AddKeys(Handle<JSObject> array_like, AddKeyConversion convert);
+ void AddKeys(Handle<JSObject> array, AddKeyConversion convert);
+ void AddElementKeysFromInterceptor(Handle<JSObject> array);
// Jump to the next level, pushing the current |levelLength_| to
// |levelLengths_| and adding a new list to |elements_|.
+ void NextPrototype();
+ // Sort the integer indices in the last list in |elements_|
+ void SortCurrentElementsList();
+ int length() { return length_; }
Isolate* isolate() { return isolate_; }
PropertyFilter filter() { return filter_; }
void set_filter_proxy_keys(bool filter) { filter_proxy_keys_ = filter; }
- void set_is_for_in(bool value) { is_for_in_ = value; }
- void set_skip_indices(bool value) { skip_indices_ = value; }
private:
Maybe<bool> CollectOwnKeys(Handle<JSReceiver> receiver,
@@ -75,17 +78,35 @@
Maybe<bool> AddKeysFromJSProxy(Handle<JSProxy> proxy,
Handle<FixedArray> keys);
- Handle<OrderedHashSet> keys() { return Handle<OrderedHashSet>::cast(keys_); }
+ bool AddIntegerKey(uint32_t key);
+ bool AddStringKey(Handle<Object> key, AddKeyConversion convert);
+ bool AddSymbolKey(Handle<Object> array);
+ void SortCurrentElementsListRemoveDuplicates();
Isolate* isolate_;
- // keys_ is either an Handle<OrderedHashSet> or in the case of own JSProxy
- // keys a Handle<FixedArray>.
- Handle<FixedArray> keys_;
KeyCollectionType type_;
PropertyFilter filter_;
bool filter_proxy_keys_ = true;
- bool is_for_in_ = false;
- bool skip_indices_ = false;
+ // |elements_| contains the sorted element keys (indices) per level.
+ std::vector<std::vector<uint32_t>*> elements_;
+ // |protoLengths_| contains the total number of keys (elements + properties)
+ // per level. Negative values mark counts for a level with keys from a proxy.
+ std::vector<int> level_lengths_;
+ // |string_properties_| contains the unique String property keys for all
+ // levels in insertion order per level.
+ Handle<OrderedHashSet> string_properties_;
+ // |symbol_properties_| contains the unique Symbol property keys for all
+ // levels in insertion order per level.
+ Handle<OrderedHashSet> symbol_properties_;
+ Handle<FixedArray> ownProxyKeys_;
+ // |length_| keeps track of the total number of all element and property keys.
+ int length_ = 0;
+ // |levelLength_| keeps track of the number of String keys in the current
+ // level.
+ int level_string_length_ = 0;
+ // |levelSymbolLength_| keeps track of the number of Symbol keys in the
+ // current level.
+ int level_symbol_length_ = 0;
DISALLOW_COPY_AND_ASSIGN(KeyAccumulator);
};
@@ -104,7 +125,6 @@
bool is_receiver_simple_enum() { return is_receiver_simple_enum_; }
bool has_empty_prototype() { return has_empty_prototype_; }
void set_filter_proxy_keys(bool filter) { filter_proxy_keys_ = filter; }
- void set_is_for_in(bool value) { is_for_in_ = value; }
MaybeHandle<FixedArray> GetKeys(GetKeysConversion convert = KEEP_NUMBERS);
@@ -118,7 +138,6 @@
KeyCollectionType type_;
PropertyFilter filter_;
bool filter_proxy_keys_ = true;
- bool is_for_in_ = false;
bool is_receiver_simple_enum_ = false;
bool has_empty_prototype_ = false;
« no previous file with comments | « src/json-stringifier.cc ('k') | src/keys.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698