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 2722 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2733 // pointer iteration. This is an issue if the store buffer overflows and we | 2733 // pointer iteration. This is an issue if the store buffer overflows and we |
2734 // have to scan the entire old space, including dead objects, looking for | 2734 // have to scan the entire old space, including dead objects, looking for |
2735 // pointers to new space. | 2735 // pointers to new space. |
2736 void MarkCompactCollector::MigrateObject(Address dst, | 2736 void MarkCompactCollector::MigrateObject(Address dst, |
2737 Address src, | 2737 Address src, |
2738 int size, | 2738 int size, |
2739 AllocationSpace dest) { | 2739 AllocationSpace dest) { |
2740 HEAP_PROFILE(heap(), ObjectMoveEvent(src, dst)); | 2740 HEAP_PROFILE(heap(), ObjectMoveEvent(src, dst)); |
2741 // TODO(hpayer): Replace that check with an assert. | 2741 // TODO(hpayer): Replace that check with an assert. |
2742 CHECK(dest != LO_SPACE && size <= Page::kMaxNonCodeHeapObjectSize); | 2742 CHECK(dest != LO_SPACE && size <= Page::kMaxNonCodeHeapObjectSize); |
2743 // Objects in old pointer space and old data space can just be moved by | |
2744 // compaction to a different page in the same space. | |
2745 // TODO(hpayer): Replace that following checks with asserts. | |
2746 CHECK(!heap_->old_pointer_space()->Contains(src) || | |
2747 (heap_->old_pointer_space()->Contains(dst) && | |
2748 heap_->TargetSpace(HeapObject::FromAddress(src)) == | |
2749 heap_->old_pointer_space())); | |
2750 CHECK(!heap_->old_data_space()->Contains(src) || | |
2751 (heap_->old_data_space()->Contains(dst) && | |
2752 heap_->TargetSpace(HeapObject::FromAddress(src)) == | |
2753 heap_->old_data_space())); | |
2754 if (dest == OLD_POINTER_SPACE) { | 2743 if (dest == OLD_POINTER_SPACE) { |
2755 // TODO(hpayer): Replace this check with an assert. | 2744 // TODO(hpayer): Replace this check with an assert. |
2756 CHECK(heap_->TargetSpace(HeapObject::FromAddress(src)) == | 2745 CHECK(heap_->TargetSpace(HeapObject::FromAddress(src)) == |
2757 heap_->old_pointer_space()); | 2746 heap_->old_pointer_space()); |
2758 Address src_slot = src; | 2747 Address src_slot = src; |
2759 Address dst_slot = dst; | 2748 Address dst_slot = dst; |
2760 ASSERT(IsAligned(size, kPointerSize)); | 2749 ASSERT(IsAligned(size, kPointerSize)); |
2761 | 2750 |
2762 for (int remaining = size / kPointerSize; remaining > 0; remaining--) { | 2751 for (int remaining = size / kPointerSize; remaining > 0; remaining--) { |
2763 Object* value = Memory::Object_at(src_slot); | 2752 Object* value = Memory::Object_at(src_slot); |
(...skipping 29 matching lines...) Expand all Loading... |
2793 PROFILE(isolate(), CodeMoveEvent(src, dst)); | 2782 PROFILE(isolate(), CodeMoveEvent(src, dst)); |
2794 heap()->MoveBlock(dst, src, size); | 2783 heap()->MoveBlock(dst, src, size); |
2795 SlotsBuffer::AddTo(&slots_buffer_allocator_, | 2784 SlotsBuffer::AddTo(&slots_buffer_allocator_, |
2796 &migration_slots_buffer_, | 2785 &migration_slots_buffer_, |
2797 SlotsBuffer::RELOCATED_CODE_OBJECT, | 2786 SlotsBuffer::RELOCATED_CODE_OBJECT, |
2798 dst, | 2787 dst, |
2799 SlotsBuffer::IGNORE_OVERFLOW); | 2788 SlotsBuffer::IGNORE_OVERFLOW); |
2800 Code::cast(HeapObject::FromAddress(dst))->Relocate(dst - src); | 2789 Code::cast(HeapObject::FromAddress(dst))->Relocate(dst - src); |
2801 } else { | 2790 } else { |
2802 ASSERT(dest == OLD_DATA_SPACE || dest == NEW_SPACE); | 2791 ASSERT(dest == OLD_DATA_SPACE || dest == NEW_SPACE); |
| 2792 // Objects in old data space can just be moved by compaction to a different |
| 2793 // page in old data space. |
| 2794 // TODO(hpayer): Replace the following check with an assert. |
| 2795 CHECK(!heap_->old_data_space()->Contains(src) || |
| 2796 (heap_->old_data_space()->Contains(dst) && |
| 2797 heap_->TargetSpace(HeapObject::FromAddress(src)) == |
| 2798 heap_->old_data_space())); |
2803 heap()->MoveBlock(dst, src, size); | 2799 heap()->MoveBlock(dst, src, size); |
2804 } | 2800 } |
2805 Memory::Address_at(src) = dst; | 2801 Memory::Address_at(src) = dst; |
2806 } | 2802 } |
2807 | 2803 |
2808 | 2804 |
2809 // Visitor for updating pointers from live objects in old spaces to new space. | 2805 // Visitor for updating pointers from live objects in old spaces to new space. |
2810 // It does not expect to encounter pointers to dead objects. | 2806 // It does not expect to encounter pointers to dead objects. |
2811 class PointersUpdatingVisitor: public ObjectVisitor { | 2807 class PointersUpdatingVisitor: public ObjectVisitor { |
2812 public: | 2808 public: |
(...skipping 1528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4341 while (buffer != NULL) { | 4337 while (buffer != NULL) { |
4342 SlotsBuffer* next_buffer = buffer->next(); | 4338 SlotsBuffer* next_buffer = buffer->next(); |
4343 DeallocateBuffer(buffer); | 4339 DeallocateBuffer(buffer); |
4344 buffer = next_buffer; | 4340 buffer = next_buffer; |
4345 } | 4341 } |
4346 *buffer_address = NULL; | 4342 *buffer_address = NULL; |
4347 } | 4343 } |
4348 | 4344 |
4349 | 4345 |
4350 } } // namespace v8::internal | 4346 } } // namespace v8::internal |
OLD | NEW |