| 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/messages.h" | 10 #include "src/messages.h" |
| (...skipping 2645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2656 } | 2656 } |
| 2657 | 2657 |
| 2658 // If a double array is concatted into a fast elements array, the fast | 2658 // If a double array is concatted into a fast elements array, the fast |
| 2659 // elements array needs to be initialized to contain proper holes, since | 2659 // elements array needs to be initialized to contain proper holes, since |
| 2660 // boxing doubles may cause incremental marking. | 2660 // boxing doubles may cause incremental marking. |
| 2661 ArrayStorageAllocationMode mode = | 2661 ArrayStorageAllocationMode mode = |
| 2662 has_double && IsFastObjectElementsKind(elements_kind) | 2662 has_double && IsFastObjectElementsKind(elements_kind) |
| 2663 ? INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE | 2663 ? INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE |
| 2664 : DONT_INITIALIZE_ARRAY_ELEMENTS; | 2664 : DONT_INITIALIZE_ARRAY_ELEMENTS; |
| 2665 Handle<JSArray> result_array = isolate->factory()->NewJSArray( | 2665 Handle<JSArray> result_array = isolate->factory()->NewJSArray( |
| 2666 elements_kind, result_len, result_len, Strength::WEAK, mode); | 2666 elements_kind, result_len, result_len, mode); |
| 2667 if (result_len == 0) return result_array; | 2667 if (result_len == 0) return result_array; |
| 2668 int j = 0; | 2668 int j = 0; |
| 2669 Handle<FixedArrayBase> storage(result_array->elements(), isolate); | 2669 Handle<FixedArrayBase> storage(result_array->elements(), isolate); |
| 2670 ElementsAccessor* accessor = ElementsAccessor::ForKind(elements_kind); | 2670 ElementsAccessor* accessor = ElementsAccessor::ForKind(elements_kind); |
| 2671 for (uint32_t i = 0; i < concat_size; i++) { | 2671 for (uint32_t i = 0; i < concat_size; i++) { |
| 2672 // It is crucial to keep |array| in a raw pointer form to avoid | 2672 // It is crucial to keep |array| in a raw pointer form to avoid |
| 2673 // performance degradation. | 2673 // performance degradation. |
| 2674 JSArray* array = JSArray::cast((*args)[i]); | 2674 JSArray* array = JSArray::cast((*args)[i]); |
| 2675 int len = Smi::cast(array->length())->value(); | 2675 int len = Smi::cast(array->length())->value(); |
| 2676 if (len > 0) { | 2676 if (len > 0) { |
| 2677 ElementsKind from_kind = array->GetElementsKind(); | 2677 ElementsKind from_kind = array->GetElementsKind(); |
| 2678 accessor->CopyElements(array, 0, from_kind, storage, j, len); | 2678 accessor->CopyElements(array, 0, from_kind, storage, j, len); |
| 2679 j += len; | 2679 j += len; |
| 2680 } | 2680 } |
| 2681 } | 2681 } |
| 2682 | 2682 |
| 2683 DCHECK(j == result_len); | 2683 DCHECK(j == result_len); |
| 2684 return result_array; | 2684 return result_array; |
| 2685 } | 2685 } |
| 2686 | 2686 |
| 2687 ElementsAccessor** ElementsAccessor::elements_accessors_ = NULL; | 2687 ElementsAccessor** ElementsAccessor::elements_accessors_ = NULL; |
| 2688 } // namespace internal | 2688 } // namespace internal |
| 2689 } // namespace v8 | 2689 } // namespace v8 |
| OLD | NEW |