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