| OLD | NEW |
| 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 683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 694 Isolate* isolate = object->GetIsolate(); | 694 Isolate* isolate = object->GetIsolate(); |
| 695 isolate->counters()->for_in()->Increment(); | 695 isolate->counters()->for_in()->Increment(); |
| 696 Handle<FixedArray> elements = | 696 Handle<FixedArray> elements = |
| 697 GetKeysInFixedArrayFor(object, INCLUDE_PROTOS, threw); | 697 GetKeysInFixedArrayFor(object, INCLUDE_PROTOS, threw); |
| 698 return isolate->factory()->NewJSArrayWithElements(elements); | 698 return isolate->factory()->NewJSArrayWithElements(elements); |
| 699 } | 699 } |
| 700 | 700 |
| 701 | 701 |
| 702 Handle<FixedArray> GetEnumPropertyKeys(Handle<JSObject> object, | 702 Handle<FixedArray> GetEnumPropertyKeys(Handle<JSObject> object, |
| 703 bool cache_result) { | 703 bool cache_result) { |
| 704 int index = 0; | |
| 705 Isolate* isolate = object->GetIsolate(); | 704 Isolate* isolate = object->GetIsolate(); |
| 706 if (object->HasFastProperties()) { | 705 if (object->HasFastProperties()) { |
| 707 if (object->map()->instance_descriptors()->HasEnumCache()) { | 706 if (object->map()->instance_descriptors()->HasEnumCache()) { |
| 708 isolate->counters()->enum_cache_hits()->Increment(); | 707 isolate->counters()->enum_cache_hits()->Increment(); |
| 709 DescriptorArray* desc = object->map()->instance_descriptors(); | 708 DescriptorArray* desc = object->map()->instance_descriptors(); |
| 710 return Handle<FixedArray>(FixedArray::cast(desc->GetEnumCache()), | 709 return Handle<FixedArray>(FixedArray::cast(desc->GetEnumCache()), |
| 711 isolate); | 710 isolate); |
| 712 } | 711 } |
| 713 isolate->counters()->enum_cache_misses()->Increment(); | 712 isolate->counters()->enum_cache_misses()->Increment(); |
| 714 Handle<Map> map(object->map()); | 713 Handle<Map> map(object->map()); |
| 715 int num_enum = object->NumberOfLocalProperties(DONT_ENUM); | 714 int num_enum = object->NumberOfLocalProperties(DONT_ENUM); |
| 716 | 715 |
| 717 Handle<FixedArray> storage = isolate->factory()->NewFixedArray(num_enum); | 716 Handle<FixedArray> storage = isolate->factory()->NewFixedArray(num_enum); |
| 718 Handle<FixedArray> sort_array = isolate->factory()->NewFixedArray(num_enum); | |
| 719 | |
| 720 Handle<FixedArray> indices; | 717 Handle<FixedArray> indices; |
| 721 Handle<FixedArray> sort_array2; | |
| 722 | 718 |
| 723 if (cache_result) { | 719 if (cache_result) { |
| 724 indices = isolate->factory()->NewFixedArray(num_enum); | 720 indices = isolate->factory()->NewFixedArray(num_enum); |
| 725 sort_array2 = isolate->factory()->NewFixedArray(num_enum); | |
| 726 } | 721 } |
| 727 | 722 |
| 728 Handle<DescriptorArray> descs = | 723 Handle<DescriptorArray> descs = |
| 729 Handle<DescriptorArray>(object->map()->instance_descriptors(), isolate); | 724 Handle<DescriptorArray>(object->map()->instance_descriptors(), isolate); |
| 730 | 725 |
| 726 int index = 0; |
| 731 for (int i = 0; i < descs->number_of_descriptors(); i++) { | 727 for (int i = 0; i < descs->number_of_descriptors(); i++) { |
| 732 if (!descs->GetDetails(i).IsDontEnum()) { | 728 if (!descs->GetDetails(i).IsDontEnum()) { |
| 733 storage->set(index, descs->GetKey(i)); | 729 storage->set(index, descs->GetKey(i)); |
| 734 PropertyDetails details = descs->GetDetails(i); | 730 PropertyDetails details = descs->GetDetails(i); |
| 735 sort_array->set(index, Smi::FromInt(details.index())); | |
| 736 if (!indices.is_null()) { | 731 if (!indices.is_null()) { |
| 737 if (details.type() != FIELD) { | 732 if (details.type() != FIELD) { |
| 738 indices = Handle<FixedArray>(); | 733 indices = Handle<FixedArray>(); |
| 739 sort_array2 = Handle<FixedArray>(); | |
| 740 } else { | 734 } else { |
| 741 int field_index = Descriptor::IndexFromValue(descs->GetValue(i)); | 735 int field_index = Descriptor::IndexFromValue(descs->GetValue(i)); |
| 742 if (field_index >= map->inobject_properties()) { | 736 if (field_index >= map->inobject_properties()) { |
| 743 field_index = -(field_index - map->inobject_properties() + 1); | 737 field_index = -(field_index - map->inobject_properties() + 1); |
| 744 } | 738 } |
| 745 indices->set(index, Smi::FromInt(field_index)); | 739 indices->set(index, Smi::FromInt(field_index)); |
| 746 sort_array2->set(index, Smi::FromInt(details.index())); | |
| 747 } | 740 } |
| 748 } | 741 } |
| 749 index++; | 742 index++; |
| 750 } | 743 } |
| 751 } | 744 } |
| 752 storage->SortPairs(*sort_array, sort_array->length()); | |
| 753 if (!indices.is_null()) { | |
| 754 indices->SortPairs(*sort_array2, sort_array2->length()); | |
| 755 } | |
| 756 if (cache_result) { | 745 if (cache_result) { |
| 757 Handle<FixedArray> bridge_storage = | 746 Handle<FixedArray> bridge_storage = |
| 758 isolate->factory()->NewFixedArray( | 747 isolate->factory()->NewFixedArray( |
| 759 DescriptorArray::kEnumCacheBridgeLength); | 748 DescriptorArray::kEnumCacheBridgeLength); |
| 760 DescriptorArray* desc = object->map()->instance_descriptors(); | 749 DescriptorArray* desc = object->map()->instance_descriptors(); |
| 761 desc->SetEnumCache(*bridge_storage, | 750 desc->SetEnumCache(*bridge_storage, |
| 762 *storage, | 751 *storage, |
| 763 indices.is_null() ? Object::cast(Smi::FromInt(0)) | 752 indices.is_null() ? Object::cast(Smi::FromInt(0)) |
| 764 : Object::cast(*indices)); | 753 : Object::cast(*indices)); |
| 765 } | 754 } |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 995 data->next = prev_next_; | 984 data->next = prev_next_; |
| 996 data->limit = prev_limit_; | 985 data->limit = prev_limit_; |
| 997 #ifdef DEBUG | 986 #ifdef DEBUG |
| 998 handles_detached_ = true; | 987 handles_detached_ = true; |
| 999 #endif | 988 #endif |
| 1000 return deferred; | 989 return deferred; |
| 1001 } | 990 } |
| 1002 | 991 |
| 1003 | 992 |
| 1004 } } // namespace v8::internal | 993 } } // namespace v8::internal |
| OLD | NEW |