Revision: 10611
Author: [email protected]
Date: Mon Feb 6 05:54:46 2012
Log: Consolidated property counting methods a bit.
Review URL: https://chromiumcodereview.appspot.com/9317119
http://code.google.com/p/v8/source/detail?r=10611
Modified:
/branches/bleeding_edge/src/handles.cc
/branches/bleeding_edge/src/objects.cc
/branches/bleeding_edge/src/objects.h
/branches/bleeding_edge/src/runtime.cc
=======================================
--- /branches/bleeding_edge/src/handles.cc Thu Jan 5 09:16:19 2012
+++ /branches/bleeding_edge/src/handles.cc Mon Feb 6 05:54:46 2012
@@ -711,7 +711,7 @@
isolate);
}
isolate->counters()->enum_cache_misses()->Increment();
- int num_enum = object->NumberOfEnumProperties();
+ int num_enum = object->NumberOfLocalProperties(DONT_ENUM);
Handle<FixedArray> storage =
isolate->factory()->NewFixedArray(num_enum);
Handle<FixedArray> sort_array =
isolate->factory()->NewFixedArray(num_enum);
Handle<DescriptorArray> descs =
@@ -735,7 +735,7 @@
ASSERT(storage->length() == index);
return storage;
} else {
- int num_enum = object->NumberOfEnumProperties();
+ int num_enum = object->NumberOfLocalProperties(DONT_ENUM);
Handle<FixedArray> storage =
isolate->factory()->NewFixedArray(num_enum);
Handle<FixedArray> sort_array =
isolate->factory()->NewFixedArray(num_enum);
object->property_dictionary()->CopyEnumKeysTo(*storage, *sort_array);
=======================================
--- /branches/bleeding_edge/src/objects.cc Mon Feb 6 04:11:40 2012
+++ /branches/bleeding_edge/src/objects.cc Mon Feb 6 05:54:46 2012
@@ -4247,11 +4247,14 @@
}
-int Map::NumberOfDescribedProperties() {
+int Map::NumberOfDescribedProperties(PropertyAttributes filter) {
int result = 0;
DescriptorArray* descs = instance_descriptors();
for (int i = 0; i < descs->number_of_descriptors(); i++) {
- if (descs->IsProperty(i)) result++;
+ PropertyDetails details(descs->GetDetails(i));
+ if (descs->IsProperty(i) && (details.attributes() & filter) == 0) {
+ result++;
+ }
}
return result;
}
@@ -10355,24 +10358,9 @@
int JSObject::NumberOfLocalProperties(PropertyAttributes filter) {
- if (HasFastProperties()) {
- DescriptorArray* descs = map()->instance_descriptors();
- int result = 0;
- for (int i = 0; i < descs->number_of_descriptors(); i++) {
- PropertyDetails details(descs->GetDetails(i));
- if (descs->IsProperty(i) && (details.attributes() & filter) == 0) {
- result++;
- }
- }
- return result;
- } else {
- return property_dictionary()->NumberOfElementsFilterAttributes(filter);
- }
-}
-
-
-int JSObject::NumberOfEnumProperties() {
- return
NumberOfLocalProperties(static_cast<PropertyAttributes>(DONT_ENUM));
+ return HasFastProperties() ?
+ map()->NumberOfDescribedProperties(filter) :
+ property_dictionary()->NumberOfElementsFilterAttributes(filter);
}
@@ -10493,7 +10481,7 @@
// purpose of this function is to provide reflection information for the
object
// mirrors.
void JSObject::GetLocalPropertyNames(FixedArray* storage, int index) {
- ASSERT(storage->length() >= (NumberOfLocalProperties(NONE) - index));
+ ASSERT(storage->length() >= (NumberOfLocalProperties() - index));
if (HasFastProperties()) {
DescriptorArray* descs = map()->instance_descriptors();
for (int i = 0; i < descs->number_of_descriptors(); i++) {
=======================================
--- /branches/bleeding_edge/src/objects.h Fri Feb 3 05:37:13 2012
+++ /branches/bleeding_edge/src/objects.h Mon Feb 6 05:54:46 2012
@@ -1807,9 +1807,7 @@
// Returns the number of properties on this object filtering out
properties
// with the specified attributes (ignoring interceptors).
- int NumberOfLocalProperties(PropertyAttributes filter);
- // Returns the number of enumerable properties (ignoring interceptors).
- int NumberOfEnumProperties();
+ int NumberOfLocalProperties(PropertyAttributes filter = NONE);
// Fill in details for properties into storage starting at the specified
// index.
void GetLocalPropertyNames(FixedArray* storage, int index);
@@ -4638,8 +4636,9 @@
// Returns the next free property index (only valid for FAST MODE).
int NextFreePropertyIndex();
- // Returns the number of properties described in instance_descriptors.
- int NumberOfDescribedProperties();
+ // Returns the number of properties described in instance_descriptors
+ // filtering out properties with the specified attributes.
+ int NumberOfDescribedProperties(PropertyAttributes filter = NONE);
// Casting.
static inline Map* cast(Object* obj);
=======================================
--- /branches/bleeding_edge/src/runtime.cc Fri Feb 3 06:16:40 2012
+++ /branches/bleeding_edge/src/runtime.cc Mon Feb 6 05:54:46 2012
@@ -165,7 +165,7 @@
}
} else {
{ MaybeObject* maybe_result =
- heap->AllocateFixedArray(copy->NumberOfLocalProperties(NONE));
+ heap->AllocateFixedArray(copy->NumberOfLocalProperties());
if (!maybe_result->ToObject(&result)) return maybe_result;
}
FixedArray* names = FixedArray::cast(result);
@@ -5010,7 +5010,7 @@
return *isolate->factory()->NewJSArray(0);
}
int n;
- n =
jsproto->NumberOfLocalProperties(static_cast<PropertyAttributes>(NONE));
+ n = jsproto->NumberOfLocalProperties();
local_property_count[i] = n;
total_property_count += n;
if (i < length - 1) {
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev