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

Side by Side Diff: src/handles.cc

Issue 9425045: Support fast case for-in in Crankshaft. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: port to x64&arm, cleanup 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
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 Handle<Map> map(object->map());
714 int num_enum = object->NumberOfLocalProperties(DONT_ENUM); 715 int num_enum = object->NumberOfLocalProperties(DONT_ENUM);
716
715 Handle<FixedArray> storage = isolate->factory()->NewFixedArray(num_enum); 717 Handle<FixedArray> storage = isolate->factory()->NewFixedArray(num_enum);
716 Handle<FixedArray> sort_array = isolate->factory()->NewFixedArray(num_enum); 718 Handle<FixedArray> sort_array = isolate->factory()->NewFixedArray(num_enum);
719
720 Handle<FixedArray> indices;
721 Handle<FixedArray> sort_array2;
722
723 if (cache_result) {
724 indices = isolate->factory()->NewFixedArray(num_enum);
725 sort_array2 = isolate->factory()->NewFixedArray(num_enum);
726 }
727
717 Handle<DescriptorArray> descs = 728 Handle<DescriptorArray> descs =
718 Handle<DescriptorArray>(object->map()->instance_descriptors(), isolate); 729 Handle<DescriptorArray>(object->map()->instance_descriptors(), isolate);
730
719 for (int i = 0; i < descs->number_of_descriptors(); i++) { 731 for (int i = 0; i < descs->number_of_descriptors(); i++) {
720 if (descs->IsProperty(i) && !descs->IsDontEnum(i)) { 732 if (descs->IsProperty(i) && !descs->IsDontEnum(i)) {
721 (*storage)->set(index, descs->GetKey(i)); 733 storage->set(index, descs->GetKey(i));
722 PropertyDetails details(descs->GetDetails(i)); 734 PropertyDetails details(descs->GetDetails(i));
723 (*sort_array)->set(index, Smi::FromInt(details.index())); 735 sort_array->set(index, Smi::FromInt(details.index()));
736 if (!indices.is_null()) {
737 if (details.type() != FIELD) {
738 indices = Handle<FixedArray>();
739 sort_array2 = Handle<FixedArray>();
740 } else {
741 int field_index = Descriptor::IndexFromValue(descs->GetValue(i));
742 if (field_index >= map->inobject_properties()) {
743 field_index = -(field_index - map->inobject_properties() + 1);
744 }
745 indices->set(index, Smi::FromInt(field_index));
746 sort_array2->set(index, Smi::FromInt(details.index()));
747 }
748 }
724 index++; 749 index++;
725 } 750 }
726 } 751 }
727 (*storage)->SortPairs(*sort_array, sort_array->length()); 752 storage->SortPairs(*sort_array, sort_array->length());
753 if (!indices.is_null()) {
754 indices->SortPairs(*sort_array2, sort_array2->length());
755 }
728 if (cache_result) { 756 if (cache_result) {
729 Handle<FixedArray> bridge_storage = 757 Handle<FixedArray> bridge_storage =
730 isolate->factory()->NewFixedArray( 758 isolate->factory()->NewFixedArray(
731 DescriptorArray::kEnumCacheBridgeLength); 759 DescriptorArray::kEnumCacheBridgeLength);
732 DescriptorArray* desc = object->map()->instance_descriptors(); 760 DescriptorArray* desc = object->map()->instance_descriptors();
733 desc->SetEnumCache(*bridge_storage, *storage); 761 desc->SetEnumCache(*bridge_storage,
762 *storage,
763 indices.is_null() ? Object::cast(Smi::FromInt(0))
764 : Object::cast(*indices));
734 } 765 }
735 ASSERT(storage->length() == index); 766 ASSERT(storage->length() == index);
736 return storage; 767 return storage;
737 } else { 768 } else {
738 int num_enum = object->NumberOfLocalProperties(DONT_ENUM); 769 int num_enum = object->NumberOfLocalProperties(DONT_ENUM);
739 Handle<FixedArray> storage = isolate->factory()->NewFixedArray(num_enum); 770 Handle<FixedArray> storage = isolate->factory()->NewFixedArray(num_enum);
740 Handle<FixedArray> sort_array = isolate->factory()->NewFixedArray(num_enum); 771 Handle<FixedArray> sort_array = isolate->factory()->NewFixedArray(num_enum);
741 object->property_dictionary()->CopyEnumKeysTo(*storage, *sort_array); 772 object->property_dictionary()->CopyEnumKeysTo(*storage, *sort_array);
742 return storage; 773 return storage;
743 } 774 }
(...skipping 19 matching lines...) Expand all
763 Handle<ObjectHashTable> PutIntoObjectHashTable(Handle<ObjectHashTable> table, 794 Handle<ObjectHashTable> PutIntoObjectHashTable(Handle<ObjectHashTable> table,
764 Handle<Object> key, 795 Handle<Object> key,
765 Handle<Object> value) { 796 Handle<Object> value) {
766 CALL_HEAP_FUNCTION(table->GetIsolate(), 797 CALL_HEAP_FUNCTION(table->GetIsolate(),
767 table->Put(*key, *value), 798 table->Put(*key, *value),
768 ObjectHashTable); 799 ObjectHashTable);
769 } 800 }
770 801
771 802
772 } } // namespace v8::internal 803 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698