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

Side by Side Diff: src/objects.cc

Issue 9317119: Consolidated property counting methods a bit. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 10 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/objects.h ('k') | src/runtime.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 4229 matching lines...) Expand 10 before | Expand all | Expand 10 after
4240 if (curr != this) { 4240 if (curr != this) {
4241 FixedArray* curr_fixed_array = 4241 FixedArray* curr_fixed_array =
4242 FixedArray::cast(curr->map()->instance_descriptors()->GetEnumCache()); 4242 FixedArray::cast(curr->map()->instance_descriptors()->GetEnumCache());
4243 if (curr_fixed_array->length() > 0) return false; 4243 if (curr_fixed_array->length() > 0) return false;
4244 } 4244 }
4245 } 4245 }
4246 return true; 4246 return true;
4247 } 4247 }
4248 4248
4249 4249
4250 int Map::NumberOfDescribedProperties() { 4250 int Map::NumberOfDescribedProperties(PropertyAttributes filter) {
4251 int result = 0; 4251 int result = 0;
4252 DescriptorArray* descs = instance_descriptors(); 4252 DescriptorArray* descs = instance_descriptors();
4253 for (int i = 0; i < descs->number_of_descriptors(); i++) { 4253 for (int i = 0; i < descs->number_of_descriptors(); i++) {
4254 if (descs->IsProperty(i)) result++; 4254 PropertyDetails details(descs->GetDetails(i));
Jakob Kummerow 2012/02/06 13:18:35 nit: indentation
Sven Panne 2012/02/06 13:37:29 Done.
4255 if (descs->IsProperty(i) && (details.attributes() & filter) == 0) {
4256 result++;
4257 }
4255 } 4258 }
4256 return result; 4259 return result;
4257 } 4260 }
4258 4261
4259 4262
4260 int Map::PropertyIndexFor(String* name) { 4263 int Map::PropertyIndexFor(String* name) {
4261 DescriptorArray* descs = instance_descriptors(); 4264 DescriptorArray* descs = instance_descriptors();
4262 for (int i = 0; i < descs->number_of_descriptors(); i++) { 4265 for (int i = 0; i < descs->number_of_descriptors(); i++) {
4263 if (name->Equals(descs->GetKey(i)) && !descs->IsNullDescriptor(i)) { 4266 if (name->Equals(descs->GetKey(i)) && !descs->IsNullDescriptor(i)) {
4264 return descs->GetFieldIndex(i); 4267 return descs->GetFieldIndex(i);
(...skipping 6083 matching lines...) Expand 10 before | Expand all | Expand 10 after
10348 } 10351 }
10349 } 10352 }
10350 10353
10351 LookupResult result(isolate); 10354 LookupResult result(isolate);
10352 LocalLookupRealNamedProperty(key, &result); 10355 LocalLookupRealNamedProperty(key, &result);
10353 return result.IsFound() && (result.type() == CALLBACKS); 10356 return result.IsFound() && (result.type() == CALLBACKS);
10354 } 10357 }
10355 10358
10356 10359
10357 int JSObject::NumberOfLocalProperties(PropertyAttributes filter) { 10360 int JSObject::NumberOfLocalProperties(PropertyAttributes filter) {
10358 if (HasFastProperties()) { 10361 return HasFastProperties() ?
10359 DescriptorArray* descs = map()->instance_descriptors(); 10362 map()->NumberOfDescribedProperties(filter) :
10360 int result = 0; 10363 property_dictionary()->NumberOfElementsFilterAttributes(filter);
10361 for (int i = 0; i < descs->number_of_descriptors(); i++) {
10362 PropertyDetails details(descs->GetDetails(i));
10363 if (descs->IsProperty(i) && (details.attributes() & filter) == 0) {
10364 result++;
10365 }
10366 }
10367 return result;
10368 } else {
10369 return property_dictionary()->NumberOfElementsFilterAttributes(filter);
10370 }
10371 } 10364 }
10372 10365
10373 10366
10374 int JSObject::NumberOfEnumProperties() {
10375 return NumberOfLocalProperties(static_cast<PropertyAttributes>(DONT_ENUM));
10376 }
10377
10378
10379 void FixedArray::SwapPairs(FixedArray* numbers, int i, int j) { 10367 void FixedArray::SwapPairs(FixedArray* numbers, int i, int j) {
10380 Object* temp = get(i); 10368 Object* temp = get(i);
10381 set(i, get(j)); 10369 set(i, get(j));
10382 set(j, temp); 10370 set(j, temp);
10383 if (this != numbers) { 10371 if (this != numbers) {
10384 temp = numbers->get(i); 10372 temp = numbers->get(i);
10385 numbers->set(i, Smi::cast(numbers->get(j))); 10373 numbers->set(i, Smi::cast(numbers->get(j)));
10386 numbers->set(j, Smi::cast(temp)); 10374 numbers->set(j, Smi::cast(temp));
10387 } 10375 }
10388 } 10376 }
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
10486 HeapSortPairs(this, numbers, len); 10474 HeapSortPairs(this, numbers, len);
10487 return; 10475 return;
10488 } 10476 }
10489 } 10477 }
10490 10478
10491 10479
10492 // Fill in the names of local properties into the supplied storage. The main 10480 // Fill in the names of local properties into the supplied storage. The main
10493 // purpose of this function is to provide reflection information for the object 10481 // purpose of this function is to provide reflection information for the object
10494 // mirrors. 10482 // mirrors.
10495 void JSObject::GetLocalPropertyNames(FixedArray* storage, int index) { 10483 void JSObject::GetLocalPropertyNames(FixedArray* storage, int index) {
10496 ASSERT(storage->length() >= (NumberOfLocalProperties(NONE) - index)); 10484 ASSERT(storage->length() >= (NumberOfLocalProperties() - index));
10497 if (HasFastProperties()) { 10485 if (HasFastProperties()) {
10498 DescriptorArray* descs = map()->instance_descriptors(); 10486 DescriptorArray* descs = map()->instance_descriptors();
10499 for (int i = 0; i < descs->number_of_descriptors(); i++) { 10487 for (int i = 0; i < descs->number_of_descriptors(); i++) {
10500 if (descs->IsProperty(i)) storage->set(index++, descs->GetKey(i)); 10488 if (descs->IsProperty(i)) storage->set(index++, descs->GetKey(i));
10501 } 10489 }
10502 ASSERT(storage->length() >= index); 10490 ASSERT(storage->length() >= index);
10503 } else { 10491 } else {
10504 property_dictionary()->CopyKeysTo(storage, 10492 property_dictionary()->CopyKeysTo(storage,
10505 index, 10493 index,
10506 StringDictionary::UNSORTED); 10494 StringDictionary::UNSORTED);
(...skipping 2532 matching lines...) Expand 10 before | Expand all | Expand 10 after
13039 if (break_point_objects()->IsUndefined()) return 0; 13027 if (break_point_objects()->IsUndefined()) return 0;
13040 // Single break point. 13028 // Single break point.
13041 if (!break_point_objects()->IsFixedArray()) return 1; 13029 if (!break_point_objects()->IsFixedArray()) return 1;
13042 // Multiple break points. 13030 // Multiple break points.
13043 return FixedArray::cast(break_point_objects())->length(); 13031 return FixedArray::cast(break_point_objects())->length();
13044 } 13032 }
13045 #endif // ENABLE_DEBUGGER_SUPPORT 13033 #endif // ENABLE_DEBUGGER_SUPPORT
13046 13034
13047 13035
13048 } } // namespace v8::internal 13036 } } // namespace v8::internal
OLDNEW
« 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