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 556 matching lines...) Loading... |
567 | 567 |
568 int new_length = len + to_add; | 568 int new_length = len + to_add; |
569 | 569 |
570 if (new_length > elms->length()) { | 570 if (new_length > elms->length()) { |
571 // New backing storage is needed. | 571 // New backing storage is needed. |
572 int capacity = new_length + (new_length >> 1) + 16; | 572 int capacity = new_length + (new_length >> 1) + 16; |
573 FixedArray* new_elms; | 573 FixedArray* new_elms; |
574 MaybeObject* maybe_obj = heap->AllocateUninitializedFixedArray(capacity); | 574 MaybeObject* maybe_obj = heap->AllocateUninitializedFixedArray(capacity); |
575 if (!maybe_obj->To(&new_elms)) return maybe_obj; | 575 if (!maybe_obj->To(&new_elms)) return maybe_obj; |
576 | 576 |
577 if (len > 0) { | 577 ElementsAccessor* accessor = array->GetElementsAccessor(); |
578 ElementsAccessor* accessor = array->GetElementsAccessor(); | 578 MaybeObject* maybe_failure = accessor->CopyElements( |
579 MaybeObject* maybe_failure = | 579 NULL, 0, new_elms, kind, 0, |
580 accessor->CopyElements(NULL, 0, new_elms, kind, 0, len, elms_obj); | 580 ElementsAccessor::kCopyToEndAndInitializeToHole, elms_obj); |
581 ASSERT(!maybe_failure->IsFailure()); | 581 ASSERT(!maybe_failure->IsFailure()); |
582 USE(maybe_failure); | 582 USE(maybe_failure); |
583 } | |
584 FillWithHoles(heap, new_elms, new_length, capacity); | |
585 | 583 |
586 elms = new_elms; | 584 elms = new_elms; |
587 } | 585 } |
588 | 586 |
589 // Add the provided values. | 587 // Add the provided values. |
590 AssertNoAllocation no_gc; | 588 AssertNoAllocation no_gc; |
591 WriteBarrierMode mode = elms->GetWriteBarrierMode(no_gc); | 589 WriteBarrierMode mode = elms->GetWriteBarrierMode(no_gc); |
592 for (int index = 0; index < to_add; index++) { | 590 for (int index = 0; index < to_add; index++) { |
593 elms->set(index + len, args[index + 1], mode); | 591 elms->set(index + len, args[index + 1], mode); |
594 } | 592 } |
(...skipping 21 matching lines...) Loading... |
616 | 614 |
617 FixedDoubleArray* new_elms; | 615 FixedDoubleArray* new_elms; |
618 | 616 |
619 if (new_length > elms_len) { | 617 if (new_length > elms_len) { |
620 // New backing storage is needed. | 618 // New backing storage is needed. |
621 int capacity = new_length + (new_length >> 1) + 16; | 619 int capacity = new_length + (new_length >> 1) + 16; |
622 MaybeObject* maybe_obj = | 620 MaybeObject* maybe_obj = |
623 heap->AllocateUninitializedFixedDoubleArray(capacity); | 621 heap->AllocateUninitializedFixedDoubleArray(capacity); |
624 if (!maybe_obj->To(&new_elms)) return maybe_obj; | 622 if (!maybe_obj->To(&new_elms)) return maybe_obj; |
625 | 623 |
626 if (len > 0) { | 624 ElementsAccessor* accessor = array->GetElementsAccessor(); |
627 ElementsAccessor* accessor = array->GetElementsAccessor(); | 625 MaybeObject* maybe_failure = accessor->CopyElements( |
628 MaybeObject* maybe_failure = | 626 NULL, 0, new_elms, kind, 0, |
629 accessor->CopyElements(NULL, 0, new_elms, kind, 0, len, elms_obj); | 627 ElementsAccessor::kCopyToEndAndInitializeToHole, elms_obj); |
630 ASSERT(!maybe_failure->IsFailure()); | 628 ASSERT(!maybe_failure->IsFailure()); |
631 USE(maybe_failure); | 629 USE(maybe_failure); |
632 } | |
633 | |
634 FillWithHoles(new_elms, len + to_add, new_elms->length()); | |
635 } else { | 630 } else { |
636 // to_add is > 0 and new_length <= elms_len, so elms_obj cannot be the | 631 // to_add is > 0 and new_length <= elms_len, so elms_obj cannot be the |
637 // empty_fixed_array. | 632 // empty_fixed_array. |
638 new_elms = FixedDoubleArray::cast(elms_obj); | 633 new_elms = FixedDoubleArray::cast(elms_obj); |
639 } | 634 } |
640 | 635 |
641 // Add the provided values. | 636 // Add the provided values. |
642 AssertNoAllocation no_gc; | 637 AssertNoAllocation no_gc; |
643 int index; | 638 int index; |
644 for (index = 0; index < to_add; index++) { | 639 for (index = 0; index < to_add; index++) { |
(...skipping 135 matching lines...) Loading... |
780 DONT_ALLOW_DOUBLE_ELEMENTS); | 775 DONT_ALLOW_DOUBLE_ELEMENTS); |
781 if (maybe_object->IsFailure()) return maybe_object; | 776 if (maybe_object->IsFailure()) return maybe_object; |
782 | 777 |
783 if (new_length > elms->length()) { | 778 if (new_length > elms->length()) { |
784 // New backing storage is needed. | 779 // New backing storage is needed. |
785 int capacity = new_length + (new_length >> 1) + 16; | 780 int capacity = new_length + (new_length >> 1) + 16; |
786 FixedArray* new_elms; | 781 FixedArray* new_elms; |
787 MaybeObject* maybe_elms = heap->AllocateUninitializedFixedArray(capacity); | 782 MaybeObject* maybe_elms = heap->AllocateUninitializedFixedArray(capacity); |
788 if (!maybe_elms->To(&new_elms)) return maybe_elms; | 783 if (!maybe_elms->To(&new_elms)) return maybe_elms; |
789 | 784 |
790 if (len > 0) { | 785 ElementsKind kind = array->GetElementsKind(); |
791 ElementsKind kind = array->GetElementsKind(); | 786 ElementsAccessor* accessor = array->GetElementsAccessor(); |
792 ElementsAccessor* accessor = array->GetElementsAccessor(); | 787 MaybeObject* maybe_failure = accessor->CopyElements( |
793 MaybeObject* maybe_failure = | 788 NULL, 0, new_elms, kind, to_add, |
794 accessor->CopyElements(NULL, 0, new_elms, kind, to_add, len, elms); | 789 ElementsAccessor::kCopyToEndAndInitializeToHole, elms); |
795 ASSERT(!maybe_failure->IsFailure()); | 790 ASSERT(!maybe_failure->IsFailure()); |
796 USE(maybe_failure); | 791 USE(maybe_failure); |
797 } | |
798 | 792 |
799 FillWithHoles(heap, new_elms, new_length, capacity); | |
800 elms = new_elms; | 793 elms = new_elms; |
801 array->set_elements(elms); | 794 array->set_elements(elms); |
802 } else { | 795 } else { |
803 AssertNoAllocation no_gc; | 796 AssertNoAllocation no_gc; |
804 MoveElements(heap, &no_gc, elms, to_add, elms, 0, len); | 797 MoveElements(heap, &no_gc, elms, to_add, elms, 0, len); |
805 } | 798 } |
806 | 799 |
807 // Add the provided values. | 800 // Add the provided values. |
808 AssertNoAllocation no_gc; | 801 AssertNoAllocation no_gc; |
809 WriteBarrierMode mode = elms->GetWriteBarrierMode(no_gc); | 802 WriteBarrierMode mode = elms->GetWriteBarrierMode(no_gc); |
(...skipping 299 matching lines...) Loading... |
1109 | 1102 |
1110 ElementsKind kind = array->GetElementsKind(); | 1103 ElementsKind kind = array->GetElementsKind(); |
1111 ElementsAccessor* accessor = array->GetElementsAccessor(); | 1104 ElementsAccessor* accessor = array->GetElementsAccessor(); |
1112 if (actual_start > 0) { | 1105 if (actual_start > 0) { |
1113 // Copy the part before actual_start as is. | 1106 // Copy the part before actual_start as is. |
1114 MaybeObject* maybe_failure = accessor->CopyElements( | 1107 MaybeObject* maybe_failure = accessor->CopyElements( |
1115 NULL, 0, new_elms, kind, 0, actual_start, elms); | 1108 NULL, 0, new_elms, kind, 0, actual_start, elms); |
1116 ASSERT(!maybe_failure->IsFailure()); | 1109 ASSERT(!maybe_failure->IsFailure()); |
1117 USE(maybe_failure); | 1110 USE(maybe_failure); |
1118 } | 1111 } |
1119 const int to_copy = len - actual_delete_count - actual_start; | 1112 MaybeObject* maybe_failure = accessor->CopyElements( |
1120 if (to_copy > 0) { | 1113 NULL, actual_start + actual_delete_count, new_elms, kind, |
1121 MaybeObject* maybe_failure = accessor->CopyElements( | 1114 actual_start + item_count, |
1122 NULL, actual_start + actual_delete_count, new_elms, kind, | 1115 ElementsAccessor::kCopyToEndAndInitializeToHole, elms); |
1123 actual_start + item_count, to_copy, elms); | 1116 ASSERT(!maybe_failure->IsFailure()); |
1124 ASSERT(!maybe_failure->IsFailure()); | 1117 USE(maybe_failure); |
1125 USE(maybe_failure); | |
1126 } | |
1127 | |
1128 FillWithHoles(heap, new_elms, new_length, capacity); | |
1129 | 1118 |
1130 elms_obj = new_elms; | 1119 elms_obj = new_elms; |
1131 elms_changed = true; | 1120 elms_changed = true; |
1132 } else { | 1121 } else { |
1133 AssertNoAllocation no_gc; | 1122 AssertNoAllocation no_gc; |
1134 MoveElements(heap, &no_gc, | 1123 MoveElements(heap, &no_gc, |
1135 elms, actual_start + item_count, | 1124 elms, actual_start + item_count, |
1136 elms, actual_start + actual_delete_count, | 1125 elms, actual_start + actual_delete_count, |
1137 (len - actual_delete_count - actual_start)); | 1126 (len - actual_delete_count - actual_start)); |
1138 } | 1127 } |
(...skipping 807 matching lines...) Loading... |
1946 return Handle<Code>(code_address); \ | 1935 return Handle<Code>(code_address); \ |
1947 } | 1936 } |
1948 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) | 1937 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) |
1949 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) | 1938 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) |
1950 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) | 1939 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) |
1951 #undef DEFINE_BUILTIN_ACCESSOR_C | 1940 #undef DEFINE_BUILTIN_ACCESSOR_C |
1952 #undef DEFINE_BUILTIN_ACCESSOR_A | 1941 #undef DEFINE_BUILTIN_ACCESSOR_A |
1953 | 1942 |
1954 | 1943 |
1955 } } // namespace v8::internal | 1944 } } // namespace v8::internal |
OLD | NEW |