Index: src/objects.h |
diff --git a/src/objects.h b/src/objects.h |
index 7dbc9f41213960045901a72e1792b283d3a3daee..8217b8cd090ffe751808ef4bb794d68a7d4b4856 100644 |
--- a/src/objects.h |
+++ b/src/objects.h |
@@ -854,6 +854,7 @@ class FixedArrayBase; |
class FunctionLiteral; |
class GlobalObject; |
class JSBuiltinsObject; |
+class KeyAccumulator; |
class LayoutDescriptor; |
class LiteralsArray; |
class LookupIterator; |
@@ -2196,6 +2197,9 @@ class JSObject: public JSReceiver { |
// Returns the number of elements on this object filtering out elements |
// with the specified attributes (ignoring interceptors). |
int GetOwnElementKeys(FixedArray* storage, PropertyAttributes filter); |
+ static void CollectOwnElementKeys(Handle<JSObject> object, |
+ KeyAccumulator* keys, |
+ PropertyAttributes filter); |
// Count and fill in the enumerable elements into storage. |
// (storage->length() == NumberOfEnumElements()). |
// If storage is NULL, will count the elements without adding |
@@ -3330,6 +3334,9 @@ class Dictionary: public HashTable<Derived, Shape, Key> { |
// Returns the number of properties added. |
int CopyKeysTo(FixedArray* storage, int index, PropertyAttributes filter, |
SortMode sort_mode); |
+ static void CopyElementKeysTo(Handle<Derived> dictionary, |
Igor Sheludko
2015/10/15 09:51:44
Maybe CollectElementKeys is a better name.
Camillo Bruni
2015/10/16 09:38:02
sounds good.
|
+ KeyAccumulator* keys, PropertyAttributes filter, |
+ uint32_t start); |
// Copies enumerable keys to preallocated fixed array. |
void CopyEnumKeysTo(FixedArray* storage); |
@@ -10660,26 +10667,50 @@ class BooleanBit : public AllStatic { |
}; |
+enum AddKeyConversion { DO_NOT_CONVERT, CONVERT_TO_ARRAY_INDEX, PROXY_MAGIC }; |
+ |
+ |
+enum GetKeysConversion { CONVERT_TO_STRING, KEEP_NUMBERS }; |
+ |
+ |
class KeyAccumulator final BASE_EMBEDDED { |
Igor Sheludko
2015/10/15 09:51:44
I think it became complex enough to have a comment
Camillo Bruni
2015/10/16 09:38:02
indeed :) I already added extensive comments.
|
public: |
- explicit KeyAccumulator(Isolate* isolate) : isolate_(isolate), length_(0) {} |
+ explicit KeyAccumulator(Isolate* isolate, |
+ KeyFilter filter = KeyFilter::SKIP_SYMBOLS) |
+ : isolate_(isolate), filter_(filter), length_(0), levelLength_(0) {} |
+ ~KeyAccumulator(); |
+ |
+ bool AddKey(uint32_t key); |
+ bool AddKey(Object* key, AddKeyConversion convert = DO_NOT_CONVERT); |
+ bool AddKey(Handle<Object> key, AddKeyConversion convert = DO_NOT_CONVERT); |
+ void AddKeys(Handle<FixedArray> array, |
+ AddKeyConversion convert = DO_NOT_CONVERT); |
+ void AddKeys(Handle<JSObject> array, |
+ AddKeyConversion convert = DO_NOT_CONVERT); |
+ void AddKeysFromProxy(Handle<JSObject> array); |
+ // Jump to the next level, pushing the current |levelLength_| to |
+ // |levelLengths_| and adding a new list to |elements_|. |
+ void NextPrototype(); |
+ void SortCurrentElementsList(); |
+ Handle<FixedArray> GetKeys(GetKeysConversion convert = CONVERT_TO_STRING); |
- void AddKey(Handle<Object> key, int check_limit); |
- void AddKeys(Handle<FixedArray> array, KeyFilter filter); |
- void AddKeys(Handle<JSObject> array, KeyFilter filter); |
- void PrepareForComparisons(int count); |
- Handle<FixedArray> GetKeys(); |
- |
- int GetLength() { return length_; } |
private: |
- void EnsureCapacity(int capacity); |
- void Grow(); |
- |
Isolate* isolate_; |
- Handle<FixedArray> keys_; |
- Handle<OrderedHashSet> set_; |
+ KeyFilter filter_; |
+ // |elements_| contains the sorted element keys (indices) per level. |
+ List<List<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. |
+ List<int> levelLengths_; |
+ // |properties_| contains the property keys per level in insertion order. |
+ Handle<OrderedHashSet> properties_; |
+ // |length_| keeps track of the total number of all element and property keys. |
int length_; |
+ // |levelLength_| keeps track of the total number of keys |
+ // (elements + properties) in the current level. |
+ int levelLength_; |
+ |
DISALLOW_COPY_AND_ASSIGN(KeyAccumulator); |
}; |