Consolidated property counting methods a bit.

Review URL: https://chromiumcodereview.appspot.com/9317119

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@10611 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent ba682501
...@@ -711,7 +711,7 @@ Handle<FixedArray> GetEnumPropertyKeys(Handle<JSObject> object, ...@@ -711,7 +711,7 @@ Handle<FixedArray> GetEnumPropertyKeys(Handle<JSObject> object,
isolate); isolate);
} }
isolate->counters()->enum_cache_misses()->Increment(); 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> storage = isolate->factory()->NewFixedArray(num_enum);
Handle<FixedArray> sort_array = isolate->factory()->NewFixedArray(num_enum); Handle<FixedArray> sort_array = isolate->factory()->NewFixedArray(num_enum);
Handle<DescriptorArray> descs = Handle<DescriptorArray> descs =
...@@ -735,7 +735,7 @@ Handle<FixedArray> GetEnumPropertyKeys(Handle<JSObject> object, ...@@ -735,7 +735,7 @@ Handle<FixedArray> GetEnumPropertyKeys(Handle<JSObject> object,
ASSERT(storage->length() == index); ASSERT(storage->length() == index);
return storage; return storage;
} else { } else {
int num_enum = object->NumberOfEnumProperties(); int num_enum = object->NumberOfLocalProperties(DONT_ENUM);
Handle<FixedArray> storage = isolate->factory()->NewFixedArray(num_enum); Handle<FixedArray> storage = isolate->factory()->NewFixedArray(num_enum);
Handle<FixedArray> sort_array = isolate->factory()->NewFixedArray(num_enum); Handle<FixedArray> sort_array = isolate->factory()->NewFixedArray(num_enum);
object->property_dictionary()->CopyEnumKeysTo(*storage, *sort_array); object->property_dictionary()->CopyEnumKeysTo(*storage, *sort_array);
......
...@@ -4247,11 +4247,14 @@ bool JSReceiver::IsSimpleEnum() { ...@@ -4247,11 +4247,14 @@ bool JSReceiver::IsSimpleEnum() {
} }
int Map::NumberOfDescribedProperties() { int Map::NumberOfDescribedProperties(PropertyAttributes filter) {
int result = 0; int result = 0;
DescriptorArray* descs = instance_descriptors(); DescriptorArray* descs = instance_descriptors();
for (int i = 0; i < descs->number_of_descriptors(); i++) { 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; return result;
} }
...@@ -10355,24 +10358,9 @@ bool JSObject::HasRealNamedCallbackProperty(String* key) { ...@@ -10355,24 +10358,9 @@ bool JSObject::HasRealNamedCallbackProperty(String* key) {
int JSObject::NumberOfLocalProperties(PropertyAttributes filter) { int JSObject::NumberOfLocalProperties(PropertyAttributes filter) {
if (HasFastProperties()) { return HasFastProperties() ?
DescriptorArray* descs = map()->instance_descriptors(); map()->NumberOfDescribedProperties(filter) :
int result = 0; property_dictionary()->NumberOfElementsFilterAttributes(filter);
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));
} }
...@@ -10493,7 +10481,7 @@ void FixedArray::SortPairs(FixedArray* numbers, uint32_t len) { ...@@ -10493,7 +10481,7 @@ void FixedArray::SortPairs(FixedArray* numbers, uint32_t len) {
// purpose of this function is to provide reflection information for the object // purpose of this function is to provide reflection information for the object
// mirrors. // mirrors.
void JSObject::GetLocalPropertyNames(FixedArray* storage, int index) { void JSObject::GetLocalPropertyNames(FixedArray* storage, int index) {
ASSERT(storage->length() >= (NumberOfLocalProperties(NONE) - index)); ASSERT(storage->length() >= (NumberOfLocalProperties() - index));
if (HasFastProperties()) { if (HasFastProperties()) {
DescriptorArray* descs = map()->instance_descriptors(); DescriptorArray* descs = map()->instance_descriptors();
for (int i = 0; i < descs->number_of_descriptors(); i++) { for (int i = 0; i < descs->number_of_descriptors(); i++) {
......
...@@ -1807,9 +1807,7 @@ class JSObject: public JSReceiver { ...@@ -1807,9 +1807,7 @@ class JSObject: public JSReceiver {
// Returns the number of properties on this object filtering out properties // Returns the number of properties on this object filtering out properties
// with the specified attributes (ignoring interceptors). // with the specified attributes (ignoring interceptors).
int NumberOfLocalProperties(PropertyAttributes filter); int NumberOfLocalProperties(PropertyAttributes filter = NONE);
// Returns the number of enumerable properties (ignoring interceptors).
int NumberOfEnumProperties();
// Fill in details for properties into storage starting at the specified // Fill in details for properties into storage starting at the specified
// index. // index.
void GetLocalPropertyNames(FixedArray* storage, int index); void GetLocalPropertyNames(FixedArray* storage, int index);
...@@ -4638,8 +4636,9 @@ class Map: public HeapObject { ...@@ -4638,8 +4636,9 @@ class Map: public HeapObject {
// Returns the next free property index (only valid for FAST MODE). // Returns the next free property index (only valid for FAST MODE).
int NextFreePropertyIndex(); int NextFreePropertyIndex();
// Returns the number of properties described in instance_descriptors. // Returns the number of properties described in instance_descriptors
int NumberOfDescribedProperties(); // filtering out properties with the specified attributes.
int NumberOfDescribedProperties(PropertyAttributes filter = NONE);
// Casting. // Casting.
static inline Map* cast(Object* obj); static inline Map* cast(Object* obj);
......
...@@ -165,7 +165,7 @@ MUST_USE_RESULT static MaybeObject* DeepCopyBoilerplate(Isolate* isolate, ...@@ -165,7 +165,7 @@ MUST_USE_RESULT static MaybeObject* DeepCopyBoilerplate(Isolate* isolate,
} }
} else { } else {
{ MaybeObject* maybe_result = { MaybeObject* maybe_result =
heap->AllocateFixedArray(copy->NumberOfLocalProperties(NONE)); heap->AllocateFixedArray(copy->NumberOfLocalProperties());
if (!maybe_result->ToObject(&result)) return maybe_result; if (!maybe_result->ToObject(&result)) return maybe_result;
} }
FixedArray* names = FixedArray::cast(result); FixedArray* names = FixedArray::cast(result);
...@@ -5010,7 +5010,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_GetLocalPropertyNames) { ...@@ -5010,7 +5010,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_GetLocalPropertyNames) {
return *isolate->factory()->NewJSArray(0); return *isolate->factory()->NewJSArray(0);
} }
int n; int n;
n = jsproto->NumberOfLocalProperties(static_cast<PropertyAttributes>(NONE)); n = jsproto->NumberOfLocalProperties();
local_property_count[i] = n; local_property_count[i] = n;
total_property_count += n; total_property_count += n;
if (i < length - 1) { if (i < length - 1) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment