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

Unified Diff: src/objects.cc

Issue 574753002: Don't use OwnPrototypeChainLength in GetOwnPropertyNames (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix Created 6 years, 3 months 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') | src/runtime.cc » ('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 38b56d2e50c03ea02d30b5b56aff3a2eadc51d4e..eb428aa1860a4410ccb473cb99a2150e16c75b5a 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -13346,23 +13346,24 @@ void FixedArray::SortPairs(FixedArray* numbers, uint32_t len) {
// Fill in the names of own properties into the supplied storage. The main
// purpose of this function is to provide reflection information for the object
// mirrors.
-void JSObject::GetOwnPropertyNames(
- FixedArray* storage, int index, PropertyAttributes filter) {
+int JSObject::GetOwnPropertyNames(FixedArray* storage, int index,
+ PropertyAttributes filter) {
DCHECK(storage->length() >= (NumberOfOwnProperties(filter) - index));
if (HasFastProperties()) {
+ int offset = 0;
int real_size = map()->NumberOfOwnDescriptors();
DescriptorArray* descs = map()->instance_descriptors();
for (int i = 0; i < real_size; i++) {
if ((descs->GetDetails(i).attributes() & filter) == 0 &&
!FilterKey(descs->GetKey(i), filter)) {
- storage->set(index++, descs->GetKey(i));
+ storage->set(index + offset, descs->GetKey(i));
+ offset++;
}
}
+ return offset;
} else {
- property_dictionary()->CopyKeysTo(storage,
- index,
- filter,
- NameDictionary::UNSORTED);
+ return property_dictionary()->CopyKeysTo(storage, index, filter,
+ NameDictionary::UNSORTED);
}
}
@@ -14055,13 +14056,11 @@ template Handle<SeededNumberDictionary>
HashTable<SeededNumberDictionary, SeededNumberDictionaryShape, uint32_t>::
Shrink(Handle<SeededNumberDictionary>, uint32_t);
-template void Dictionary<NameDictionary, NameDictionaryShape, Handle<Name> >::
- CopyKeysTo(
- FixedArray*,
- int,
- PropertyAttributes,
- Dictionary<
- NameDictionary, NameDictionaryShape, Handle<Name> >::SortMode);
+template int
+ Dictionary<NameDictionary, NameDictionaryShape, Handle<Name> >::CopyKeysTo(
+ FixedArray*, int, PropertyAttributes,
+ Dictionary<NameDictionary, NameDictionaryShape,
+ Handle<Name> >::SortMode);
template int
Dictionary<NameDictionary, NameDictionaryShape, Handle<Name> >::
@@ -15208,27 +15207,28 @@ void NameDictionary::CopyEnumKeysTo(FixedArray* storage) {
}
-template<typename Derived, typename Shape, typename Key>
-void Dictionary<Derived, Shape, Key>::CopyKeysTo(
- FixedArray* storage,
- int index,
- PropertyAttributes filter,
+template <typename Derived, typename Shape, typename Key>
+int Dictionary<Derived, Shape, Key>::CopyKeysTo(
+ FixedArray* storage, int index, PropertyAttributes filter,
typename Dictionary<Derived, Shape, Key>::SortMode sort_mode) {
DCHECK(storage->length() >= NumberOfElementsFilterAttributes(filter));
int capacity = DerivedHashTable::Capacity();
+ int offset = 0;
for (int i = 0; i < capacity; i++) {
Object* k = DerivedHashTable::KeyAt(i);
if (DerivedHashTable::IsKey(k) && !FilterKey(k, filter)) {
PropertyDetails details = DetailsAt(i);
if (details.IsDeleted()) continue;
PropertyAttributes attr = details.attributes();
- if ((attr & filter) == 0) storage->set(index++, k);
+ if ((attr & filter) == 0) storage->set(index + offset, k);
+ offset++;
}
}
if (sort_mode == Dictionary::SORTED) {
- storage->SortPairs(storage, index);
+ storage->SortPairs(storage, index + offset);
}
- DCHECK(storage->length() >= index);
+ DCHECK(storage->length() >= index + offset);
+ return offset;
}
« no previous file with comments | « src/objects.h ('k') | src/runtime.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698