Chromium Code Reviews| Index: src/objects.cc |
| diff --git a/src/objects.cc b/src/objects.cc |
| index c1019f06ff7c261b50c0072add8f01760ba7411f..fc7ea479420c30589d434451641374d4f9b47421 100644 |
| --- a/src/objects.cc |
| +++ b/src/objects.cc |
| @@ -16471,6 +16471,11 @@ template Handle<NameDictionary> |
| HashTable<NameDictionary, NameDictionaryShape, Handle<Name> >:: |
| New(Isolate*, int, MinimumCapacity, PretenureFlag); |
| +template Handle<ObjectHashSet> HashTable<ObjectHashSet, ObjectHashSetShape, |
| + Handle<Object>>::New(Isolate*, int n, |
| + MinimumCapacity, |
| + PretenureFlag); |
| + |
| template Handle<NameDictionary> |
| HashTable<NameDictionary, NameDictionaryShape, Handle<Name> >:: |
| Shrink(Handle<NameDictionary>, Handle<Name>); |
| @@ -16541,24 +16546,33 @@ template int Dictionary<GlobalDictionary, GlobalDictionaryShape, Handle<Name>>:: |
| template int Dictionary<NameDictionary, NameDictionaryShape, Handle<Name>>:: |
| NumberOfElementsFilterAttributes(PropertyFilter filter); |
| -template void Dictionary<GlobalDictionary, GlobalDictionaryShape, |
| - Handle<Name>>::CopyEnumKeysTo(FixedArray* storage); |
| +template void |
| +Dictionary<GlobalDictionary, GlobalDictionaryShape, Handle<Name>>:: |
| + CopyEnumKeysTo(Handle<Dictionary<GlobalDictionary, GlobalDictionaryShape, |
| + Handle<Name>>> |
| + dictionary, |
| + Handle<FixedArray> storage, KeyCollectionMode mode, |
| + KeyAccumulator* accumulator); |
| -template void Dictionary<NameDictionary, NameDictionaryShape, |
| - Handle<Name>>::CopyEnumKeysTo(FixedArray* storage); |
| +template void |
| +Dictionary<NameDictionary, NameDictionaryShape, Handle<Name>>::CopyEnumKeysTo( |
| + Handle<Dictionary<NameDictionary, NameDictionaryShape, Handle<Name>>> |
| + dictionary, |
| + Handle<FixedArray> storage, KeyCollectionMode mode, |
| + KeyAccumulator* accumulator); |
| template void |
| Dictionary<GlobalDictionary, GlobalDictionaryShape, Handle<Name>>:: |
| CollectKeysTo(Handle<Dictionary<GlobalDictionary, GlobalDictionaryShape, |
| Handle<Name>>> |
| dictionary, |
| - KeyAccumulator* keys, PropertyFilter filter); |
| + KeyAccumulator* keys); |
| template void |
| Dictionary<NameDictionary, NameDictionaryShape, Handle<Name>>::CollectKeysTo( |
| Handle<Dictionary<NameDictionary, NameDictionaryShape, Handle<Name>>> |
| dictionary, |
| - KeyAccumulator* keys, PropertyFilter filter); |
| + KeyAccumulator* keys); |
| Handle<Object> JSObject::PrepareSlowElementsForSort( |
| Handle<JSObject> object, uint32_t limit) { |
| @@ -17055,6 +17069,20 @@ bool StringSet::Has(Handle<String> name) { |
| return FindEntry(*name) != kNotFound; |
| } |
| +Handle<ObjectHashSet> ObjectHashSet::Add(Handle<ObjectHashSet> set, |
| + Handle<Object> key) { |
| + Isolate* isolate = set->GetIsolate(); |
| + int32_t hash = Object::GetOrCreateHash(isolate, key)->value(); |
| + |
| + if (!set->Has(isolate, key, hash)) { |
| + set = EnsureCapacity(set, 1, key); |
| + int entry = set->FindInsertionEntry(hash); |
| + set->set(EntryToIndex(entry), *key); |
| + set->ElementAdded(); |
| + } |
| + return set; |
| +} |
| + |
| Handle<Object> CompilationCacheTable::Lookup(Handle<String> src, |
| Handle<Context> context, |
| LanguageMode language_mode) { |
| @@ -17510,43 +17538,62 @@ struct EnumIndexComparator { |
| Dictionary* dict; |
| }; |
| - |
| template <typename Derived, typename Shape, typename Key> |
| -void Dictionary<Derived, Shape, Key>::CopyEnumKeysTo(FixedArray* storage) { |
| - Isolate* isolate = this->GetIsolate(); |
| +void Dictionary<Derived, Shape, Key>::CopyEnumKeysTo( |
| + Handle<Dictionary<Derived, Shape, Key>> dictionary, |
| + Handle<FixedArray> storage, KeyCollectionMode mode, |
| + KeyAccumulator* accumulator) { |
| + Isolate* isolate = dictionary->GetIsolate(); |
| int length = storage->length(); |
| - int capacity = this->Capacity(); |
| + int capacity = dictionary->Capacity(); |
| int properties = 0; |
| + bool is_shadowing_key; |
|
adamk
2016/06/27 19:19:33
Again confused as to why this is outside the loop.
|
| for (int i = 0; i < capacity; i++) { |
| - Object* k = this->KeyAt(i); |
| - if (this->IsKey(isolate, k) && !k->IsSymbol()) { |
| - PropertyDetails details = this->DetailsAt(i); |
| - if (details.IsDontEnum() || this->IsDeleted(i)) continue; |
| + Object* key = dictionary->KeyAt(i); |
| + is_shadowing_key = false; |
| + if (!dictionary->IsKey(isolate, key)) continue; |
| + if (key->IsSymbol()) continue; |
| + PropertyDetails details = dictionary->DetailsAt(i); |
| + if (details.IsDontEnum()) { |
| + if (mode == KeyCollectionMode::kIncludePrototypes) { |
| + is_shadowing_key = true; |
| + } else { |
| + continue; |
| + } |
| + } |
| + if (dictionary->IsDeleted(i)) continue; |
| + if (is_shadowing_key) { |
| + accumulator->AddShadowKey(key); |
| + continue; |
| + } else { |
| storage->set(properties, Smi::FromInt(i)); |
| - properties++; |
| - if (properties == length) break; |
| } |
| + properties++; |
| + if (properties == length) break; |
| } |
| + |
| CHECK_EQ(length, properties); |
| - EnumIndexComparator<Derived> cmp(static_cast<Derived*>(this)); |
| + DisallowHeapAllocation no_gc; |
| + Dictionary<Derived, Shape, Key>* raw_dictionary = *dictionary; |
| + FixedArray* raw_storage = *storage; |
| + EnumIndexComparator<Derived> cmp(static_cast<Derived*>(*dictionary)); |
| Smi** start = reinterpret_cast<Smi**>(storage->GetFirstElementAddress()); |
| std::sort(start, start + length, cmp); |
| for (int i = 0; i < length; i++) { |
| - int index = Smi::cast(storage->get(i))->value(); |
| - storage->set(i, this->KeyAt(index)); |
| + int index = Smi::cast(raw_storage->get(i))->value(); |
| + raw_storage->set(i, raw_dictionary->KeyAt(index)); |
| } |
| } |
| template <typename Derived, typename Shape, typename Key> |
| void Dictionary<Derived, Shape, Key>::CollectKeysTo( |
| - Handle<Dictionary<Derived, Shape, Key> > dictionary, KeyAccumulator* keys, |
| - PropertyFilter filter) { |
| + Handle<Dictionary<Derived, Shape, Key>> dictionary, KeyAccumulator* keys) { |
| Isolate* isolate = keys->isolate(); |
| int capacity = dictionary->Capacity(); |
| Handle<FixedArray> array = |
| isolate->factory()->NewFixedArray(dictionary->NumberOfElements()); |
| int array_size = 0; |
| - |
| + PropertyFilter filter = keys->filter(); |
| { |
| DisallowHeapAllocation no_gc; |
| Dictionary<Derived, Shape, Key>* raw_dict = *dictionary; |
| @@ -17555,7 +17602,10 @@ void Dictionary<Derived, Shape, Key>::CollectKeysTo( |
| if (!raw_dict->IsKey(isolate, k) || k->FilterKey(filter)) continue; |
| if (raw_dict->IsDeleted(i)) continue; |
| PropertyDetails details = raw_dict->DetailsAt(i); |
| - if ((details.attributes() & filter) != 0) continue; |
| + if ((details.attributes() & filter) != 0) { |
| + keys->AddShadowKey(k); |
| + continue; |
| + } |
| if (filter & ONLY_ALL_CAN_READ) { |
| if (details.kind() != kAccessor) continue; |
| Object* accessors = raw_dict->ValueAt(i); |