 Chromium Code Reviews
 Chromium Code Reviews Issue 9425045:
  Support fast case for-in in Crankshaft.  (Closed) 
  Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
    
  
    Issue 9425045:
  Support fast case for-in in Crankshaft.  (Closed) 
  Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge| Index: src/handles.cc | 
| diff --git a/src/handles.cc b/src/handles.cc | 
| index 943a1c0b6ac833e1a0a5e614857e8bfd45a2e7ed..a02b36ca121d01cec7a06d49a0453f5d277f80fe 100644 | 
| --- a/src/handles.cc | 
| +++ b/src/handles.cc | 
| @@ -711,26 +711,54 @@ Handle<FixedArray> GetEnumPropertyKeys(Handle<JSObject> object, | 
| isolate); | 
| } | 
| isolate->counters()->enum_cache_misses()->Increment(); | 
| + Handle<Map> map(object->map()); | 
| int num_enum = object->NumberOfLocalProperties(DONT_ENUM); | 
| + | 
| Handle<FixedArray> storage = isolate->factory()->NewFixedArray(num_enum); | 
| Handle<FixedArray> sort_array = isolate->factory()->NewFixedArray(num_enum); | 
| + | 
| + Handle<FixedArray> indexes = | 
| + isolate->factory()->NewFixedArray(num_enum); | 
| + Handle<FixedArray> sort_array_2 = | 
| + isolate->factory()->NewFixedArray(num_enum); | 
| + | 
| Handle<DescriptorArray> descs = | 
| Handle<DescriptorArray>(object->map()->instance_descriptors(), isolate); | 
| + | 
| for (int i = 0; i < descs->number_of_descriptors(); i++) { | 
| if (descs->IsProperty(i) && !descs->IsDontEnum(i)) { | 
| - (*storage)->set(index, descs->GetKey(i)); | 
| + storage->set(index, descs->GetKey(i)); | 
| PropertyDetails details(descs->GetDetails(i)); | 
| - (*sort_array)->set(index, Smi::FromInt(details.index())); | 
| + sort_array->set(index, Smi::FromInt(details.index())); | 
| + if (!indexes.is_null()) { | 
| + if (details.type() != FIELD) { | 
| + indexes = Handle<FixedArray>(); | 
| + sort_array_2 = Handle<FixedArray>(); | 
| + } else { | 
| + int field_index = Descriptor::IndexFromValue(descs->GetValue(i)); | 
| + if (field_index >= map->inobject_properties()) { | 
| + field_index = -(field_index - map->inobject_properties() + 1); | 
| + } | 
| + indexes->set(index, Smi::FromInt(field_index)); | 
| + sort_array_2->set(index, Smi::FromInt(details.index())); | 
| + } | 
| + } | 
| index++; | 
| } | 
| } | 
| - (*storage)->SortPairs(*sort_array, sort_array->length()); | 
| + storage->SortPairs(*sort_array, sort_array->length()); | 
| + if (!indexes.is_null()) { | 
| 
fschneider
2012/02/20 14:56:06
s/indexes/indices/g
 | 
| + indexes->SortPairs(*sort_array_2, sort_array_2->length()); | 
| + } | 
| if (cache_result) { | 
| Handle<FixedArray> bridge_storage = | 
| isolate->factory()->NewFixedArray( | 
| DescriptorArray::kEnumCacheBridgeLength); | 
| DescriptorArray* desc = object->map()->instance_descriptors(); | 
| - desc->SetEnumCache(*bridge_storage, *storage); | 
| + desc->SetEnumCache(*bridge_storage, | 
| + *storage, | 
| + indexes.is_null() ? Object::cast(Smi::FromInt(0)) | 
| + : Object::cast(*indexes)); | 
| } | 
| ASSERT(storage->length() == index); | 
| return storage; |