| OLD | NEW | 
|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. | 
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be | 
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. | 
| 4 | 4 | 
| 5 #include "src/elements.h" | 5 #include "src/elements.h" | 
| 6 | 6 | 
| 7 #include "src/arguments.h" | 7 #include "src/arguments.h" | 
| 8 #include "src/conversions.h" | 8 #include "src/conversions.h" | 
| 9 #include "src/factory.h" | 9 #include "src/factory.h" | 
| 10 #include "src/isolate-inl.h" | 10 #include "src/isolate-inl.h" | 
| (...skipping 1023 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1034     // Collect the element indices into a new list. | 1034     // Collect the element indices into a new list. | 
| 1035     uint32_t nof_indices = 0; | 1035     uint32_t nof_indices = 0; | 
| 1036     Handle<FixedArray> combined_keys = | 1036     Handle<FixedArray> combined_keys = | 
| 1037         isolate->factory()->NewFixedArray(initial_list_length); | 1037         isolate->factory()->NewFixedArray(initial_list_length); | 
| 1038     combined_keys = Subclass::DirectCollectElementIndicesImpl( | 1038     combined_keys = Subclass::DirectCollectElementIndicesImpl( | 
| 1039         isolate, object, backing_store, | 1039         isolate, object, backing_store, | 
| 1040         needs_sorting ? GetKeysConversion::kKeepNumbers : convert, filter, | 1040         needs_sorting ? GetKeysConversion::kKeepNumbers : convert, filter, | 
| 1041         combined_keys, &nof_indices); | 1041         combined_keys, &nof_indices); | 
| 1042 | 1042 | 
| 1043     if (needs_sorting) { | 1043     if (needs_sorting) { | 
| 1044       SortIndices(combined_keys, nof_indices, SKIP_WRITE_BARRIER); | 1044       SortIndices(combined_keys, nof_indices); | 
| 1045       uint32_t array_length = 0; |  | 
| 1046       // Indices from dictionary elements should only be converted after | 1045       // Indices from dictionary elements should only be converted after | 
| 1047       // sorting. | 1046       // sorting. | 
| 1048       if (convert == GetKeysConversion::kConvertToString) { | 1047       if (convert == GetKeysConversion::kConvertToString) { | 
| 1049         for (uint32_t i = 0; i < nof_indices; i++) { | 1048         for (uint32_t i = 0; i < nof_indices; i++) { | 
| 1050           Handle<Object> index_string = isolate->factory()->Uint32ToString( | 1049           Handle<Object> index_string = isolate->factory()->Uint32ToString( | 
| 1051                   combined_keys->get(i)->Number()); | 1050               combined_keys->get(i)->Number()); | 
| 1052           combined_keys->set(i, *index_string); | 1051           combined_keys->set(i, *index_string); | 
| 1053         } | 1052         } | 
| 1054       } else if (!(object->IsJSArray() && |  | 
| 1055                    JSArray::cast(*object)->length()->ToArrayLength( |  | 
| 1056                        &array_length) && |  | 
| 1057                    array_length <= Smi::kMaxValue)) { |  | 
| 1058         // Since we use std::sort above, the GC will no longer know where the |  | 
| 1059         // HeapNumbers are.  For Arrays with valid Smi length, we are sure to |  | 
| 1060         // have no HeapNumber indices and thus we can skip this step. |  | 
| 1061         FIXED_ARRAY_ELEMENTS_WRITE_BARRIER(isolate->heap(), *combined_keys, 0, |  | 
| 1062                                            nof_indices); |  | 
| 1063       } | 1053       } | 
| 1064     } | 1054     } | 
| 1065 | 1055 | 
| 1066     // Copy over the passed-in property keys. | 1056     // Copy over the passed-in property keys. | 
| 1067     CopyObjectToObjectElements(*keys, FAST_ELEMENTS, 0, *combined_keys, | 1057     CopyObjectToObjectElements(*keys, FAST_ELEMENTS, 0, *combined_keys, | 
| 1068                                FAST_ELEMENTS, nof_indices, nof_property_keys); | 1058                                FAST_ELEMENTS, nof_indices, nof_property_keys); | 
| 1069 | 1059 | 
| 1070     // For holey elements and arguments we might have to shrink the collected | 1060     // For holey elements and arguments we might have to shrink the collected | 
| 1071     // keys since the estimates might be off. | 1061     // keys since the estimates might be off. | 
| 1072     if (IsHoleyElementsKind(kind()) || IsSloppyArgumentsElements(kind())) { | 1062     if (IsHoleyElementsKind(kind()) || IsSloppyArgumentsElements(kind())) { | 
| (...skipping 2018 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 3091     insertion_index += len; | 3081     insertion_index += len; | 
| 3092   } | 3082   } | 
| 3093 | 3083 | 
| 3094   DCHECK_EQ(insertion_index, result_len); | 3084   DCHECK_EQ(insertion_index, result_len); | 
| 3095   return result_array; | 3085   return result_array; | 
| 3096 } | 3086 } | 
| 3097 | 3087 | 
| 3098 ElementsAccessor** ElementsAccessor::elements_accessors_ = NULL; | 3088 ElementsAccessor** ElementsAccessor::elements_accessors_ = NULL; | 
| 3099 }  // namespace internal | 3089 }  // namespace internal | 
| 3100 }  // namespace v8 | 3090 }  // namespace v8 | 
| OLD | NEW | 
|---|