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 592 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
603 | 603 |
604 // Get first element | 604 // Get first element |
605 ElementsAccessor* accessor = array->GetElementsAccessor(); | 605 ElementsAccessor* accessor = array->GetElementsAccessor(); |
606 Object* first; | 606 Object* first; |
607 MaybeObject* maybe_first = accessor->Get(receiver, array, 0, elms_obj); | 607 MaybeObject* maybe_first = accessor->Get(receiver, array, 0, elms_obj); |
608 if (!maybe_first->To(&first)) return maybe_first; | 608 if (!maybe_first->To(&first)) return maybe_first; |
609 if (first->IsTheHole()) { | 609 if (first->IsTheHole()) { |
610 first = heap->undefined_value(); | 610 first = heap->undefined_value(); |
611 } | 611 } |
612 | 612 |
613 if (!heap->lo_space()->Contains(elms_obj)) { | 613 if (!heap->CanMoveObjectStart(elms_obj)) { |
614 array->set_elements(LeftTrimFixedArray(heap, elms_obj, 1)); | 614 array->set_elements(LeftTrimFixedArray(heap, elms_obj, 1)); |
615 } else { | 615 } else { |
616 // Shift the elements. | 616 // Shift the elements. |
617 if (elms_obj->IsFixedArray()) { | 617 if (elms_obj->IsFixedArray()) { |
618 FixedArray* elms = FixedArray::cast(elms_obj); | 618 FixedArray* elms = FixedArray::cast(elms_obj); |
619 DisallowHeapAllocation no_gc; | 619 DisallowHeapAllocation no_gc; |
620 heap->MoveElements(elms, 0, 1, len - 1); | 620 heap->MoveElements(elms, 0, 1, len - 1); |
621 elms->set(len - 1, heap->the_hole_value()); | 621 elms->set(len - 1, heap->the_hole_value()); |
622 } else { | 622 } else { |
623 FixedDoubleArray* elms = FixedDoubleArray::cast(elms_obj); | 623 FixedDoubleArray* elms = FixedDoubleArray::cast(elms_obj); |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
943 | 943 |
944 if (elms_obj->IsFixedDoubleArray()) { | 944 if (elms_obj->IsFixedDoubleArray()) { |
945 FixedDoubleArray* elms = FixedDoubleArray::cast(elms_obj); | 945 FixedDoubleArray* elms = FixedDoubleArray::cast(elms_obj); |
946 MoveDoubleElements(elms, delta, elms, 0, actual_start); | 946 MoveDoubleElements(elms, delta, elms, 0, actual_start); |
947 } else { | 947 } else { |
948 FixedArray* elms = FixedArray::cast(elms_obj); | 948 FixedArray* elms = FixedArray::cast(elms_obj); |
949 DisallowHeapAllocation no_gc; | 949 DisallowHeapAllocation no_gc; |
950 heap->MoveElements(elms, delta, 0, actual_start); | 950 heap->MoveElements(elms, delta, 0, actual_start); |
951 } | 951 } |
952 | 952 |
953 elms_obj = LeftTrimFixedArray(heap, elms_obj, delta); | 953 if (heap->CanMoveObjectStart(elms_obj)) { |
954 | 954 // On the fast path we move the start of the object in memory. |
| 955 elms_obj = LeftTrimFixedArray(heap, elms_obj, delta); |
| 956 } else { |
| 957 // This is the slow path. We are going to move the elements to the left |
| 958 // by copying them. For trimmed values we store the hole. |
| 959 if (elms_obj->IsFixedDoubleArray()) { |
| 960 FixedDoubleArray* elms = FixedDoubleArray::cast(elms_obj); |
| 961 MoveDoubleElements(elms, 0, elms, delta, len - delta); |
| 962 FillWithHoles(elms, len - delta, len); |
| 963 } else { |
| 964 FixedArray* elms = FixedArray::cast(elms_obj); |
| 965 DisallowHeapAllocation no_gc; |
| 966 heap->MoveElements(elms, 0, delta, len - delta); |
| 967 FillWithHoles(heap, elms, len - delta, len); |
| 968 } |
| 969 } |
955 elms_changed = true; | 970 elms_changed = true; |
956 } else { | 971 } else { |
957 if (elms_obj->IsFixedDoubleArray()) { | 972 if (elms_obj->IsFixedDoubleArray()) { |
958 FixedDoubleArray* elms = FixedDoubleArray::cast(elms_obj); | 973 FixedDoubleArray* elms = FixedDoubleArray::cast(elms_obj); |
959 MoveDoubleElements(elms, actual_start + item_count, | 974 MoveDoubleElements(elms, actual_start + item_count, |
960 elms, actual_start + actual_delete_count, | 975 elms, actual_start + actual_delete_count, |
961 (len - actual_delete_count - actual_start)); | 976 (len - actual_delete_count - actual_start)); |
962 FillWithHoles(elms, new_length, len); | 977 FillWithHoles(elms, new_length, len); |
963 } else { | 978 } else { |
964 FixedArray* elms = FixedArray::cast(elms_obj); | 979 FixedArray* elms = FixedArray::cast(elms_obj); |
(...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1782 } | 1797 } |
1783 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) | 1798 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) |
1784 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) | 1799 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) |
1785 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) | 1800 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) |
1786 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) | 1801 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) |
1787 #undef DEFINE_BUILTIN_ACCESSOR_C | 1802 #undef DEFINE_BUILTIN_ACCESSOR_C |
1788 #undef DEFINE_BUILTIN_ACCESSOR_A | 1803 #undef DEFINE_BUILTIN_ACCESSOR_A |
1789 | 1804 |
1790 | 1805 |
1791 } } // namespace v8::internal | 1806 } } // namespace v8::internal |
OLD | NEW |