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

Unified Diff: src/objects.cc

Issue 1475633002: Correctly handlify Dictionary::CollectKeysTo. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 1 month 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/objects.h ('k') | test/mjsunit/mjsunit.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index f298711d46da1ef235372d474aaae72012ca350c..c95e4ab58209620adf3546e98a8816c7cd7098ff 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -15254,9 +15254,9 @@ void JSObject::CollectOwnPropertyNames(KeyAccumulator* keys,
keys->AddKey(key);
}
} else if (IsJSGlobalObject()) {
- global_dictionary()->CollectKeysTo(keys, filter);
+ GlobalDictionary::CollectKeysTo(handle(global_dictionary()), keys, filter);
} else {
- property_dictionary()->CollectKeysTo(keys, filter);
+ NameDictionary::CollectKeysTo(handle(property_dictionary()), keys, filter);
}
}
@@ -17201,29 +17201,35 @@ int Dictionary<Derived, Shape, Key>::CopyKeysTo(
template <typename Derived, typename Shape, typename Key>
-void Dictionary<Derived, Shape, Key>::CollectKeysTo(KeyAccumulator* keys,
- PropertyAttributes filter) {
- int capacity = this->Capacity();
+void Dictionary<Derived, Shape, Key>::CollectKeysTo(
+ Handle<Dictionary<Derived, Shape, Key> > dictionary, KeyAccumulator* keys,
+ PropertyAttributes filter) {
+ int capacity = dictionary->Capacity();
Handle<FixedArray> array =
- keys->isolate()->factory()->NewFixedArray(this->NumberOfElements());
+ keys->isolate()->factory()->NewFixedArray(dictionary->NumberOfElements());
int array_size = 0;
- for (int i = 0; i < capacity; i++) {
- Object* k = this->KeyAt(i);
- if (!this->IsKey(k) || k->FilterKey(filter)) continue;
- if (this->IsDeleted(i)) continue;
- PropertyDetails details = this->DetailsAt(i);
- PropertyAttributes attr = details.attributes();
- if ((attr & filter) != 0) continue;
- array->set(array_size++, Smi::FromInt(i));
+ {
+ 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(k) || k->FilterKey(filter)) continue;
+ if (raw_dict->IsDeleted(i)) continue;
+ PropertyDetails details = raw_dict->DetailsAt(i);
+ PropertyAttributes attr = details.attributes();
+ if ((attr & filter) != 0) 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);
}
- EnumIndexComparator<Derived> cmp(static_cast<Derived*>(this));
- Smi** start = reinterpret_cast<Smi**>(array->GetFirstElementAddress());
- std::sort(start, start + array_size, cmp);
for (int i = 0; i < array_size; i++) {
int index = Smi::cast(array->get(i))->value();
- keys->AddKey(this->KeyAt(index));
+ keys->AddKey(dictionary->KeyAt(index));
}
}
« no previous file with comments | « src/objects.h ('k') | test/mjsunit/mjsunit.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698