OLD | NEW |
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 757 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
768 CopyElements(heap, &no_gc, result_elms, 0, elms, k, result_len); | 768 CopyElements(heap, &no_gc, result_elms, 0, elms, k, result_len); |
769 | 769 |
770 // Set elements. | 770 // Set elements. |
771 result_array->set_elements(result_elms); | 771 result_array->set_elements(result_elms); |
772 | 772 |
773 // Set the length. | 773 // Set the length. |
774 result_array->set_length(Smi::FromInt(result_len)); | 774 result_array->set_length(Smi::FromInt(result_len)); |
775 | 775 |
776 // Set the ElementsKind. | 776 // Set the ElementsKind. |
777 ElementsKind elements_kind = JSObject::cast(receiver)->GetElementsKind(); | 777 ElementsKind elements_kind = JSObject::cast(receiver)->GetElementsKind(); |
778 if (result_array->GetElementsKind() != elements_kind) { | 778 if (IsMoreGeneralElementsKindTransition(result_array->GetElementsKind(), |
| 779 elements_kind)) { |
779 MaybeObject* maybe = result_array->TransitionElementsKind(elements_kind); | 780 MaybeObject* maybe = result_array->TransitionElementsKind(elements_kind); |
780 if (maybe->IsFailure()) return maybe; | 781 if (maybe->IsFailure()) return maybe; |
781 } | 782 } |
782 return result_array; | 783 return result_array; |
783 } | 784 } |
784 | 785 |
785 | 786 |
786 BUILTIN(ArraySplice) { | 787 BUILTIN(ArraySplice) { |
787 Heap* heap = isolate->heap(); | 788 Heap* heap = isolate->heap(); |
788 Object* receiver = *args.receiver(); | 789 Object* receiver = *args.receiver(); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
868 actual_delete_count); | 869 actual_delete_count); |
869 | 870 |
870 // Set elements. | 871 // Set elements. |
871 result_array->set_elements(result_elms); | 872 result_array->set_elements(result_elms); |
872 | 873 |
873 // Set the length. | 874 // Set the length. |
874 result_array->set_length(Smi::FromInt(actual_delete_count)); | 875 result_array->set_length(Smi::FromInt(actual_delete_count)); |
875 | 876 |
876 // Set the ElementsKind. | 877 // Set the ElementsKind. |
877 ElementsKind elements_kind = array->GetElementsKind(); | 878 ElementsKind elements_kind = array->GetElementsKind(); |
878 if (result_array->GetElementsKind() != elements_kind) { | 879 if (IsMoreGeneralElementsKindTransition(result_array->GetElementsKind(), |
| 880 elements_kind)) { |
879 MaybeObject* maybe = result_array->TransitionElementsKind(elements_kind); | 881 MaybeObject* maybe = result_array->TransitionElementsKind(elements_kind); |
880 if (maybe->IsFailure()) return maybe; | 882 if (maybe->IsFailure()) return maybe; |
881 } | 883 } |
882 } | 884 } |
883 | 885 |
884 int item_count = (n_arguments > 1) ? (n_arguments - 2) : 0; | 886 int item_count = (n_arguments > 1) ? (n_arguments - 2) : 0; |
885 int new_length = len - actual_delete_count + item_count; | 887 int new_length = len - actual_delete_count + item_count; |
886 | 888 |
887 bool elms_changed = false; | 889 bool elms_changed = false; |
888 if (item_count < actual_delete_count) { | 890 if (item_count < actual_delete_count) { |
(...skipping 897 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1786 return Handle<Code>(code_address); \ | 1788 return Handle<Code>(code_address); \ |
1787 } | 1789 } |
1788 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) | 1790 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) |
1789 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) | 1791 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) |
1790 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) | 1792 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) |
1791 #undef DEFINE_BUILTIN_ACCESSOR_C | 1793 #undef DEFINE_BUILTIN_ACCESSOR_C |
1792 #undef DEFINE_BUILTIN_ACCESSOR_A | 1794 #undef DEFINE_BUILTIN_ACCESSOR_A |
1793 | 1795 |
1794 | 1796 |
1795 } } // namespace v8::internal | 1797 } } // namespace v8::internal |
OLD | NEW |