Index: src/objects.cc |
diff --git a/src/objects.cc b/src/objects.cc |
index 9a903f1ff59ad217d25a74e53589927ea1d12ff7..190fc42f8fb3f98b7c198348bc78b81f89713865 100644 |
--- a/src/objects.cc |
+++ b/src/objects.cc |
@@ -17324,6 +17324,12 @@ Dictionary<NameDictionary, NameDictionaryShape, Handle<Name>>::CopyEnumKeysTo( |
Handle<FixedArray> storage, KeyCollectionMode mode, |
KeyAccumulator* accumulator); |
+template Handle<FixedArray> |
+Dictionary<GlobalDictionary, GlobalDictionaryShape, Handle<Name>>:: |
+ GetOrderedKeyIndices( |
+ Handle< |
+ Dictionary<GlobalDictionary, GlobalDictionaryShape, Handle<Name>>> |
+ dictionary); |
template void |
Dictionary<GlobalDictionary, GlobalDictionaryShape, Handle<Name>>:: |
CollectKeysTo(Handle<Dictionary<GlobalDictionary, GlobalDictionaryShape, |
@@ -17331,6 +17337,11 @@ Dictionary<GlobalDictionary, GlobalDictionaryShape, Handle<Name>>:: |
dictionary, |
KeyAccumulator* keys); |
+template Handle<FixedArray> |
+Dictionary<NameDictionary, NameDictionaryShape, Handle<Name>>:: |
+ GetOrderedKeyIndices( |
+ Handle<Dictionary<NameDictionary, NameDictionaryShape, Handle<Name>>> |
+ dictionary); |
template void |
Dictionary<NameDictionary, NameDictionaryShape, Handle<Name>>::CollectKeysTo( |
Handle<Dictionary<NameDictionary, NameDictionaryShape, Handle<Name>>> |
@@ -18359,6 +18370,32 @@ void Dictionary<Derived, Shape, Key>::CopyEnumKeysTo( |
} |
template <typename Derived, typename Shape, typename Key> |
+Handle<FixedArray> Dictionary<Derived, Shape, Key>::GetOrderedKeyIndices( |
Igor Sheludko
2016/12/05 15:26:06
We already have Dictionary::BuildIterationIndicesA
|
+ Handle<Dictionary<Derived, Shape, Key>> dictionary) { |
+ Isolate* isolate = dictionary->GetIsolate(); |
+ int capacity = dictionary->Capacity(); |
+ Handle<FixedArray> array = |
+ isolate->factory()->NewFixedArray(dictionary->NumberOfElements()); |
+ int array_size = 0; |
+ { |
+ DisallowHeapAllocation no_gc; |
+ Dictionary<Derived, Shape, Key>* raw_dict = *dictionary; |
+ for (int i = 0; i < capacity; i++) { |
+ Object* k = raw_dict->KeyAt(i); |
+ if (!raw_dict->IsKey(isolate, k)) continue; |
+ if (raw_dict->IsDeleted(i)) continue; |
+ array->set(array_size++, Smi::FromInt(i)); |
+ } |
+ |
+ EnumIndexComparator<Derived> cmp(static_cast<Derived*>(raw_dict)); |
+ Smi** start = reinterpret_cast<Smi**>(array->GetFirstElementAddress()); |
+ std::sort(start, start + array_size, cmp); |
+ } |
+ array->Shrink(array_size); |
+ return array; |
+} |
+ |
+template <typename Derived, typename Shape, typename Key> |
void Dictionary<Derived, Shape, Key>::CollectKeysTo( |
Handle<Dictionary<Derived, Shape, Key>> dictionary, KeyAccumulator* keys) { |
Isolate* isolate = keys->isolate(); |