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

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: 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> indexes =
721 isolate->factory()->NewFixedArray(num_enum);
722 Handle<FixedArray> sort_array_2 =
723 isolate->factory()->NewFixedArray(num_enum);
724
717 Handle<DescriptorArray> descs = 725 Handle<DescriptorArray> descs =
718 Handle<DescriptorArray>(object->map()->instance_descriptors(), isolate); 726 Handle<DescriptorArray>(object->map()->instance_descriptors(), isolate);
727
719 for (int i = 0; i < descs->number_of_descriptors(); i++) { 728 for (int i = 0; i < descs->number_of_descriptors(); i++) {
720 if (descs->IsProperty(i) && !descs->IsDontEnum(i)) { 729 if (descs->IsProperty(i) && !descs->IsDontEnum(i)) {
721 (*storage)->set(index, descs->GetKey(i)); 730 storage->set(index, descs->GetKey(i));
722 PropertyDetails details(descs->GetDetails(i)); 731 PropertyDetails details(descs->GetDetails(i));
723 (*sort_array)->set(index, Smi::FromInt(details.index())); 732 sort_array->set(index, Smi::FromInt(details.index()));
733 if (!indexes.is_null()) {
734 if (details.type() != FIELD) {
735 indexes = Handle<FixedArray>();
736 sort_array_2 = Handle<FixedArray>();
737 } else {
738 int field_index = Descriptor::IndexFromValue(descs->GetValue(i));
739 if (field_index >= map->inobject_properties()) {
740 field_index = -(field_index - map->inobject_properties() + 1);
741 }
742 indexes->set(index, Smi::FromInt(field_index));
743 sort_array_2->set(index, Smi::FromInt(details.index()));
744 }
745 }
724 index++; 746 index++;
725 } 747 }
726 } 748 }
727 (*storage)->SortPairs(*sort_array, sort_array->length()); 749 storage->SortPairs(*sort_array, sort_array->length());
750 if (!indexes.is_null()) {
fschneider 2012/02/20 14:56:06 s/indexes/indices/g
751 indexes->SortPairs(*sort_array_2, sort_array_2->length());
752 }
728 if (cache_result) { 753 if (cache_result) {
729 Handle<FixedArray> bridge_storage = 754 Handle<FixedArray> bridge_storage =
730 isolate->factory()->NewFixedArray( 755 isolate->factory()->NewFixedArray(
731 DescriptorArray::kEnumCacheBridgeLength); 756 DescriptorArray::kEnumCacheBridgeLength);
732 DescriptorArray* desc = object->map()->instance_descriptors(); 757 DescriptorArray* desc = object->map()->instance_descriptors();
733 desc->SetEnumCache(*bridge_storage, *storage); 758 desc->SetEnumCache(*bridge_storage,
759 *storage,
760 indexes.is_null() ? Object::cast(Smi::FromInt(0))
761 : Object::cast(*indexes));
734 } 762 }
735 ASSERT(storage->length() == index); 763 ASSERT(storage->length() == index);
736 return storage; 764 return storage;
737 } else { 765 } else {
738 int num_enum = object->NumberOfLocalProperties(DONT_ENUM); 766 int num_enum = object->NumberOfLocalProperties(DONT_ENUM);
739 Handle<FixedArray> storage = isolate->factory()->NewFixedArray(num_enum); 767 Handle<FixedArray> storage = isolate->factory()->NewFixedArray(num_enum);
740 Handle<FixedArray> sort_array = isolate->factory()->NewFixedArray(num_enum); 768 Handle<FixedArray> sort_array = isolate->factory()->NewFixedArray(num_enum);
741 object->property_dictionary()->CopyEnumKeysTo(*storage, *sort_array); 769 object->property_dictionary()->CopyEnumKeysTo(*storage, *sort_array);
742 return storage; 770 return storage;
743 } 771 }
(...skipping 19 matching lines...) Expand all
763 Handle<ObjectHashTable> PutIntoObjectHashTable(Handle<ObjectHashTable> table, 791 Handle<ObjectHashTable> PutIntoObjectHashTable(Handle<ObjectHashTable> table,
764 Handle<Object> key, 792 Handle<Object> key,
765 Handle<Object> value) { 793 Handle<Object> value) {
766 CALL_HEAP_FUNCTION(table->GetIsolate(), 794 CALL_HEAP_FUNCTION(table->GetIsolate(),
767 table->Put(*key, *value), 795 table->Put(*key, *value),
768 ObjectHashTable); 796 ObjectHashTable);
769 } 797 }
770 798
771 799
772 } } // namespace v8::internal 800 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/full-codegen.h ('k') | src/hydrogen.h » ('j') | src/hydrogen.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698