OLD | NEW |
---|---|
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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 #include "src/objects.h" | 5 #include "src/objects.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 #include <iomanip> | 8 #include <iomanip> |
9 #include <memory> | 9 #include <memory> |
10 #include <sstream> | 10 #include <sstream> |
(...skipping 17306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
17317 Handle<FixedArray> storage, KeyCollectionMode mode, | 17317 Handle<FixedArray> storage, KeyCollectionMode mode, |
17318 KeyAccumulator* accumulator); | 17318 KeyAccumulator* accumulator); |
17319 | 17319 |
17320 template void | 17320 template void |
17321 Dictionary<NameDictionary, NameDictionaryShape, Handle<Name>>::CopyEnumKeysTo( | 17321 Dictionary<NameDictionary, NameDictionaryShape, Handle<Name>>::CopyEnumKeysTo( |
17322 Handle<Dictionary<NameDictionary, NameDictionaryShape, Handle<Name>>> | 17322 Handle<Dictionary<NameDictionary, NameDictionaryShape, Handle<Name>>> |
17323 dictionary, | 17323 dictionary, |
17324 Handle<FixedArray> storage, KeyCollectionMode mode, | 17324 Handle<FixedArray> storage, KeyCollectionMode mode, |
17325 KeyAccumulator* accumulator); | 17325 KeyAccumulator* accumulator); |
17326 | 17326 |
17327 template Handle<FixedArray> | |
17328 Dictionary<GlobalDictionary, GlobalDictionaryShape, Handle<Name>>:: | |
17329 GetOrderedKeyIndices( | |
17330 Handle< | |
17331 Dictionary<GlobalDictionary, GlobalDictionaryShape, Handle<Name>>> | |
17332 dictionary); | |
17327 template void | 17333 template void |
17328 Dictionary<GlobalDictionary, GlobalDictionaryShape, Handle<Name>>:: | 17334 Dictionary<GlobalDictionary, GlobalDictionaryShape, Handle<Name>>:: |
17329 CollectKeysTo(Handle<Dictionary<GlobalDictionary, GlobalDictionaryShape, | 17335 CollectKeysTo(Handle<Dictionary<GlobalDictionary, GlobalDictionaryShape, |
17330 Handle<Name>>> | 17336 Handle<Name>>> |
17331 dictionary, | 17337 dictionary, |
17332 KeyAccumulator* keys); | 17338 KeyAccumulator* keys); |
17333 | 17339 |
17340 template Handle<FixedArray> | |
17341 Dictionary<NameDictionary, NameDictionaryShape, Handle<Name>>:: | |
17342 GetOrderedKeyIndices( | |
17343 Handle<Dictionary<NameDictionary, NameDictionaryShape, Handle<Name>>> | |
17344 dictionary); | |
17334 template void | 17345 template void |
17335 Dictionary<NameDictionary, NameDictionaryShape, Handle<Name>>::CollectKeysTo( | 17346 Dictionary<NameDictionary, NameDictionaryShape, Handle<Name>>::CollectKeysTo( |
17336 Handle<Dictionary<NameDictionary, NameDictionaryShape, Handle<Name>>> | 17347 Handle<Dictionary<NameDictionary, NameDictionaryShape, Handle<Name>>> |
17337 dictionary, | 17348 dictionary, |
17338 KeyAccumulator* keys); | 17349 KeyAccumulator* keys); |
17339 | 17350 |
17340 Handle<Object> JSObject::PrepareSlowElementsForSort( | 17351 Handle<Object> JSObject::PrepareSlowElementsForSort( |
17341 Handle<JSObject> object, uint32_t limit) { | 17352 Handle<JSObject> object, uint32_t limit) { |
17342 DCHECK(object->HasDictionaryElements()); | 17353 DCHECK(object->HasDictionaryElements()); |
17343 Isolate* isolate = object->GetIsolate(); | 17354 Isolate* isolate = object->GetIsolate(); |
(...skipping 1008 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
18352 EnumIndexComparator<Derived> cmp(static_cast<Derived*>(*dictionary)); | 18363 EnumIndexComparator<Derived> cmp(static_cast<Derived*>(*dictionary)); |
18353 Smi** start = reinterpret_cast<Smi**>(storage->GetFirstElementAddress()); | 18364 Smi** start = reinterpret_cast<Smi**>(storage->GetFirstElementAddress()); |
18354 std::sort(start, start + length, cmp); | 18365 std::sort(start, start + length, cmp); |
18355 for (int i = 0; i < length; i++) { | 18366 for (int i = 0; i < length; i++) { |
18356 int index = Smi::cast(raw_storage->get(i))->value(); | 18367 int index = Smi::cast(raw_storage->get(i))->value(); |
18357 raw_storage->set(i, raw_dictionary->KeyAt(index)); | 18368 raw_storage->set(i, raw_dictionary->KeyAt(index)); |
18358 } | 18369 } |
18359 } | 18370 } |
18360 | 18371 |
18361 template <typename Derived, typename Shape, typename Key> | 18372 template <typename Derived, typename Shape, typename Key> |
18373 Handle<FixedArray> Dictionary<Derived, Shape, Key>::GetOrderedKeyIndices( | |
Igor Sheludko
2016/12/05 15:26:06
We already have Dictionary::BuildIterationIndicesA
| |
18374 Handle<Dictionary<Derived, Shape, Key>> dictionary) { | |
18375 Isolate* isolate = dictionary->GetIsolate(); | |
18376 int capacity = dictionary->Capacity(); | |
18377 Handle<FixedArray> array = | |
18378 isolate->factory()->NewFixedArray(dictionary->NumberOfElements()); | |
18379 int array_size = 0; | |
18380 { | |
18381 DisallowHeapAllocation no_gc; | |
18382 Dictionary<Derived, Shape, Key>* raw_dict = *dictionary; | |
18383 for (int i = 0; i < capacity; i++) { | |
18384 Object* k = raw_dict->KeyAt(i); | |
18385 if (!raw_dict->IsKey(isolate, k)) continue; | |
18386 if (raw_dict->IsDeleted(i)) continue; | |
18387 array->set(array_size++, Smi::FromInt(i)); | |
18388 } | |
18389 | |
18390 EnumIndexComparator<Derived> cmp(static_cast<Derived*>(raw_dict)); | |
18391 Smi** start = reinterpret_cast<Smi**>(array->GetFirstElementAddress()); | |
18392 std::sort(start, start + array_size, cmp); | |
18393 } | |
18394 array->Shrink(array_size); | |
18395 return array; | |
18396 } | |
18397 | |
18398 template <typename Derived, typename Shape, typename Key> | |
18362 void Dictionary<Derived, Shape, Key>::CollectKeysTo( | 18399 void Dictionary<Derived, Shape, Key>::CollectKeysTo( |
18363 Handle<Dictionary<Derived, Shape, Key>> dictionary, KeyAccumulator* keys) { | 18400 Handle<Dictionary<Derived, Shape, Key>> dictionary, KeyAccumulator* keys) { |
18364 Isolate* isolate = keys->isolate(); | 18401 Isolate* isolate = keys->isolate(); |
18365 int capacity = dictionary->Capacity(); | 18402 int capacity = dictionary->Capacity(); |
18366 Handle<FixedArray> array = | 18403 Handle<FixedArray> array = |
18367 isolate->factory()->NewFixedArray(dictionary->NumberOfElements()); | 18404 isolate->factory()->NewFixedArray(dictionary->NumberOfElements()); |
18368 int array_size = 0; | 18405 int array_size = 0; |
18369 PropertyFilter filter = keys->filter(); | 18406 PropertyFilter filter = keys->filter(); |
18370 { | 18407 { |
18371 DisallowHeapAllocation no_gc; | 18408 DisallowHeapAllocation no_gc; |
(...skipping 2067 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
20439 // depend on this. | 20476 // depend on this. |
20440 return DICTIONARY_ELEMENTS; | 20477 return DICTIONARY_ELEMENTS; |
20441 } | 20478 } |
20442 DCHECK_LE(kind, LAST_ELEMENTS_KIND); | 20479 DCHECK_LE(kind, LAST_ELEMENTS_KIND); |
20443 return kind; | 20480 return kind; |
20444 } | 20481 } |
20445 } | 20482 } |
20446 | 20483 |
20447 } // namespace internal | 20484 } // namespace internal |
20448 } // namespace v8 | 20485 } // namespace v8 |
OLD | NEW |