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

Side by Side Diff: src/handles.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 | « no previous file | src/objects.h » ('j') | src/objects.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 693 matching lines...) Expand 10 before | Expand all | Expand 10 after
704 int index = 0; 704 int index = 0;
705 Isolate* isolate = object->GetIsolate(); 705 Isolate* isolate = object->GetIsolate();
706 if (object->HasFastProperties()) { 706 if (object->HasFastProperties()) {
707 if (object->map()->instance_descriptors()->HasEnumCache()) { 707 if (object->map()->instance_descriptors()->HasEnumCache()) {
708 isolate->counters()->enum_cache_hits()->Increment(); 708 isolate->counters()->enum_cache_hits()->Increment();
709 DescriptorArray* desc = object->map()->instance_descriptors(); 709 DescriptorArray* desc = object->map()->instance_descriptors();
710 return Handle<FixedArray>(FixedArray::cast(desc->GetEnumCache()), 710 return Handle<FixedArray>(FixedArray::cast(desc->GetEnumCache()),
711 isolate); 711 isolate);
712 } 712 }
713 isolate->counters()->enum_cache_misses()->Increment(); 713 isolate->counters()->enum_cache_misses()->Increment();
714 int num_enum = object->NumberOfEnumProperties(); 714 int num_enum = object->NumberOfLocalProperties(DONT_ENUM);
715 Handle<FixedArray> storage = isolate->factory()->NewFixedArray(num_enum); 715 Handle<FixedArray> storage = isolate->factory()->NewFixedArray(num_enum);
716 Handle<FixedArray> sort_array = isolate->factory()->NewFixedArray(num_enum); 716 Handle<FixedArray> sort_array = isolate->factory()->NewFixedArray(num_enum);
717 Handle<DescriptorArray> descs = 717 Handle<DescriptorArray> descs =
718 Handle<DescriptorArray>(object->map()->instance_descriptors(), isolate); 718 Handle<DescriptorArray>(object->map()->instance_descriptors(), isolate);
719 for (int i = 0; i < descs->number_of_descriptors(); i++) { 719 for (int i = 0; i < descs->number_of_descriptors(); i++) {
720 if (descs->IsProperty(i) && !descs->IsDontEnum(i)) { 720 if (descs->IsProperty(i) && !descs->IsDontEnum(i)) {
721 (*storage)->set(index, descs->GetKey(i)); 721 (*storage)->set(index, descs->GetKey(i));
722 PropertyDetails details(descs->GetDetails(i)); 722 PropertyDetails details(descs->GetDetails(i));
723 (*sort_array)->set(index, Smi::FromInt(details.index())); 723 (*sort_array)->set(index, Smi::FromInt(details.index()));
724 index++; 724 index++;
725 } 725 }
726 } 726 }
727 (*storage)->SortPairs(*sort_array, sort_array->length()); 727 (*storage)->SortPairs(*sort_array, sort_array->length());
728 if (cache_result) { 728 if (cache_result) {
729 Handle<FixedArray> bridge_storage = 729 Handle<FixedArray> bridge_storage =
730 isolate->factory()->NewFixedArray( 730 isolate->factory()->NewFixedArray(
731 DescriptorArray::kEnumCacheBridgeLength); 731 DescriptorArray::kEnumCacheBridgeLength);
732 DescriptorArray* desc = object->map()->instance_descriptors(); 732 DescriptorArray* desc = object->map()->instance_descriptors();
733 desc->SetEnumCache(*bridge_storage, *storage); 733 desc->SetEnumCache(*bridge_storage, *storage);
734 } 734 }
735 ASSERT(storage->length() == index); 735 ASSERT(storage->length() == index);
736 return storage; 736 return storage;
737 } else { 737 } else {
738 int num_enum = object->NumberOfEnumProperties(); 738 int num_enum = object->NumberOfLocalProperties(DONT_ENUM);
739 Handle<FixedArray> storage = isolate->factory()->NewFixedArray(num_enum); 739 Handle<FixedArray> storage = isolate->factory()->NewFixedArray(num_enum);
740 Handle<FixedArray> sort_array = isolate->factory()->NewFixedArray(num_enum); 740 Handle<FixedArray> sort_array = isolate->factory()->NewFixedArray(num_enum);
741 object->property_dictionary()->CopyEnumKeysTo(*storage, *sort_array); 741 object->property_dictionary()->CopyEnumKeysTo(*storage, *sort_array);
742 return storage; 742 return storage;
743 } 743 }
744 } 744 }
745 745
746 746
747 Handle<ObjectHashSet> ObjectHashSetAdd(Handle<ObjectHashSet> table, 747 Handle<ObjectHashSet> ObjectHashSetAdd(Handle<ObjectHashSet> table,
748 Handle<Object> key) { 748 Handle<Object> key) {
(...skipping 14 matching lines...) Expand all
763 Handle<ObjectHashTable> PutIntoObjectHashTable(Handle<ObjectHashTable> table, 763 Handle<ObjectHashTable> PutIntoObjectHashTable(Handle<ObjectHashTable> table,
764 Handle<Object> key, 764 Handle<Object> key,
765 Handle<Object> value) { 765 Handle<Object> value) {
766 CALL_HEAP_FUNCTION(table->GetIsolate(), 766 CALL_HEAP_FUNCTION(table->GetIsolate(),
767 table->Put(*key, *value), 767 table->Put(*key, *value),
768 ObjectHashTable); 768 ObjectHashTable);
769 } 769 }
770 770
771 771
772 } } // namespace v8::internal 772 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/objects.h » ('j') | src/objects.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698