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

Unified Diff: src/objects.cc

Issue 1515473003: [cleanup] Drop JSObject::GetOwnPropertyNames(). (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebased Created 5 years 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/property-details.h » ('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 eb27233ce57f99659556e4183361ae58ffda73d0..47f8e6b3794b60d9804b75623b739f45c9ff2c53 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -7797,20 +7797,18 @@ MaybeHandle<JSObject> JSObjectWalkVisitor<ContextObject>::StructureWalk(
}
}
} else {
- Handle<FixedArray> names =
- isolate->factory()->NewFixedArray(copy->NumberOfOwnProperties());
- copy->GetOwnPropertyNames(*names, 0);
+ // Only deep copy fields from the object literal expression.
+ // In particular, don't try to copy the length attribute of
+ // an array.
+ PropertyFilter filter = static_cast<PropertyFilter>(
+ ONLY_WRITABLE | ONLY_ENUMERABLE | ONLY_CONFIGURABLE);
+ KeyAccumulator accumulator(isolate, filter);
+ accumulator.NextPrototype();
+ copy->CollectOwnPropertyNames(&accumulator, filter);
+ Handle<FixedArray> names = accumulator.GetKeys();
for (int i = 0; i < names->length(); i++) {
DCHECK(names->get(i)->IsName());
Handle<Name> name(Name::cast(names->get(i)));
- Maybe<PropertyAttributes> maybe =
- JSReceiver::GetOwnPropertyAttributes(copy, name);
- DCHECK(maybe.IsJust());
- PropertyAttributes attributes = maybe.FromJust();
- // Only deep copy fields from the object literal expression.
- // In particular, don't try to copy the length attribute of
- // an array.
- if (attributes != NONE) continue;
Handle<Object> value =
Object::GetProperty(copy, name).ToHandleChecked();
if (value->IsJSObject()) {
@@ -15841,25 +15839,6 @@ Maybe<bool> JSObject::HasRealNamedCallbackProperty(Handle<JSObject> object,
}
-// Private symbols are always filtered out.
-int JSObject::NumberOfOwnProperties(PropertyFilter filter) {
- if (HasFastProperties()) {
- Map* map = this->map();
- if (filter == ENUMERABLE_STRINGS) {
- // The cached enum length was computed with filter == ENUMERABLE_STRING,
- // so that's the only filter for which it's valid to retrieve it.
- int result = map->EnumLength();
- if (result != kInvalidEnumCacheSentinel) return result;
- }
- return map->NumberOfDescribedProperties(OWN_DESCRIPTORS, filter);
- } else if (IsJSGlobalObject()) {
- return global_dictionary()->NumberOfElementsFilterAttributes(filter);
- } else {
- return property_dictionary()->NumberOfElementsFilterAttributes(filter);
- }
-}
-
-
void FixedArray::SwapPairs(FixedArray* numbers, int i, int j) {
Object* temp = get(i);
set(i, get(j));
@@ -15973,33 +15952,6 @@ 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.
-int JSObject::GetOwnPropertyNames(FixedArray* storage, int index,
- PropertyFilter filter) {
- DCHECK(storage->length() >= (NumberOfOwnProperties(filter) - index));
- if (HasFastProperties()) {
- int start_index = index;
- 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 &&
- !descs->GetKey(i)->FilterKey(filter)) {
- storage->set(index++, descs->GetKey(i));
- }
- }
- return index - start_index;
- } else if (IsJSGlobalObject()) {
- return global_dictionary()->CopyKeysTo(storage, index, filter,
- GlobalDictionary::UNSORTED);
- } else {
- return property_dictionary()->CopyKeysTo(storage, index, filter,
- NameDictionary::UNSORTED);
- }
-}
-
-
void JSObject::CollectOwnPropertyNames(KeyAccumulator* keys,
PropertyFilter filter) {
if (HasFastProperties()) {
« no previous file with comments | « src/objects.h ('k') | src/property-details.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698