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 2706 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2717 // pointer iteration. This is an issue if the store buffer overflows and we | 2717 // pointer iteration. This is an issue if the store buffer overflows and we |
2718 // have to scan the entire old space, including dead objects, looking for | 2718 // have to scan the entire old space, including dead objects, looking for |
2719 // pointers to new space. | 2719 // pointers to new space. |
2720 void MarkCompactCollector::MigrateObject(Address dst, | 2720 void MarkCompactCollector::MigrateObject(Address dst, |
2721 Address src, | 2721 Address src, |
2722 int size, | 2722 int size, |
2723 AllocationSpace dest) { | 2723 AllocationSpace dest) { |
2724 HEAP_PROFILE(heap(), ObjectMoveEvent(src, dst)); | 2724 HEAP_PROFILE(heap(), ObjectMoveEvent(src, dst)); |
2725 // TODO(hpayer): Replace that check with an assert. | 2725 // TODO(hpayer): Replace that check with an assert. |
2726 CHECK(dest != LO_SPACE && size <= Page::kMaxNonCodeHeapObjectSize); | 2726 CHECK(dest != LO_SPACE && size <= Page::kMaxNonCodeHeapObjectSize); |
2727 // Objects in old pointer space and old data space can just be moved by | |
2728 // compaction to a different page in the same space. | |
2729 // TODO(hpayer): Replace that following checks with asserts. | |
2730 CHECK(!heap_->old_pointer_space()->Contains(src) || | |
2731 (heap_->old_pointer_space()->Contains(dst) && | |
2732 heap_->TargetSpace(HeapObject::FromAddress(src)) == | |
2733 heap_->old_pointer_space())); | |
2734 CHECK(!heap_->old_data_space()->Contains(src) || | |
2735 (heap_->old_data_space()->Contains(dst) && | |
2736 heap_->TargetSpace(HeapObject::FromAddress(src)) == | |
2737 heap_->old_data_space())); | |
2738 if (dest == OLD_POINTER_SPACE) { | 2727 if (dest == OLD_POINTER_SPACE) { |
2739 // TODO(hpayer): Replace this check with an assert. | 2728 // TODO(hpayer): Replace this check with an assert. |
2740 CHECK(heap_->TargetSpace(HeapObject::FromAddress(src)) == | 2729 HeapObject* heap_object = HeapObject::FromAddress(src); |
2741 heap_->old_pointer_space()); | 2730 CHECK(heap_object->IsExternalString() || |
| 2731 heap_->TargetSpace(heap_object) == heap_->old_pointer_space()); |
2742 Address src_slot = src; | 2732 Address src_slot = src; |
2743 Address dst_slot = dst; | 2733 Address dst_slot = dst; |
2744 ASSERT(IsAligned(size, kPointerSize)); | 2734 ASSERT(IsAligned(size, kPointerSize)); |
2745 | 2735 |
2746 for (int remaining = size / kPointerSize; remaining > 0; remaining--) { | 2736 for (int remaining = size / kPointerSize; remaining > 0; remaining--) { |
2747 Object* value = Memory::Object_at(src_slot); | 2737 Object* value = Memory::Object_at(src_slot); |
2748 | 2738 |
2749 Memory::Object_at(dst_slot) = value; | 2739 Memory::Object_at(dst_slot) = value; |
2750 | 2740 |
2751 if (heap_->InNewSpace(value)) { | 2741 if (heap_->InNewSpace(value)) { |
(...skipping 25 matching lines...) Expand all Loading... |
2777 PROFILE(isolate(), CodeMoveEvent(src, dst)); | 2767 PROFILE(isolate(), CodeMoveEvent(src, dst)); |
2778 heap()->MoveBlock(dst, src, size); | 2768 heap()->MoveBlock(dst, src, size); |
2779 SlotsBuffer::AddTo(&slots_buffer_allocator_, | 2769 SlotsBuffer::AddTo(&slots_buffer_allocator_, |
2780 &migration_slots_buffer_, | 2770 &migration_slots_buffer_, |
2781 SlotsBuffer::RELOCATED_CODE_OBJECT, | 2771 SlotsBuffer::RELOCATED_CODE_OBJECT, |
2782 dst, | 2772 dst, |
2783 SlotsBuffer::IGNORE_OVERFLOW); | 2773 SlotsBuffer::IGNORE_OVERFLOW); |
2784 Code::cast(HeapObject::FromAddress(dst))->Relocate(dst - src); | 2774 Code::cast(HeapObject::FromAddress(dst))->Relocate(dst - src); |
2785 } else { | 2775 } else { |
2786 ASSERT(dest == OLD_DATA_SPACE || dest == NEW_SPACE); | 2776 ASSERT(dest == OLD_DATA_SPACE || dest == NEW_SPACE); |
| 2777 // Objects in old data space can just be moved by compaction to a different |
| 2778 // page in old data space. |
| 2779 // TODO(hpayer): Replace the following check with an assert. |
| 2780 CHECK(!heap_->old_data_space()->Contains(src) || |
| 2781 (heap_->old_data_space()->Contains(dst) && |
| 2782 heap_->TargetSpace(HeapObject::FromAddress(src)) == |
| 2783 heap_->old_data_space())); |
2787 heap()->MoveBlock(dst, src, size); | 2784 heap()->MoveBlock(dst, src, size); |
2788 } | 2785 } |
2789 Memory::Address_at(src) = dst; | 2786 Memory::Address_at(src) = dst; |
2790 } | 2787 } |
2791 | 2788 |
2792 | 2789 |
2793 // Visitor for updating pointers from live objects in old spaces to new space. | 2790 // Visitor for updating pointers from live objects in old spaces to new space. |
2794 // It does not expect to encounter pointers to dead objects. | 2791 // It does not expect to encounter pointers to dead objects. |
2795 class PointersUpdatingVisitor: public ObjectVisitor { | 2792 class PointersUpdatingVisitor: public ObjectVisitor { |
2796 public: | 2793 public: |
(...skipping 1517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4314 while (buffer != NULL) { | 4311 while (buffer != NULL) { |
4315 SlotsBuffer* next_buffer = buffer->next(); | 4312 SlotsBuffer* next_buffer = buffer->next(); |
4316 DeallocateBuffer(buffer); | 4313 DeallocateBuffer(buffer); |
4317 buffer = next_buffer; | 4314 buffer = next_buffer; |
4318 } | 4315 } |
4319 *buffer_address = NULL; | 4316 *buffer_address = NULL; |
4320 } | 4317 } |
4321 | 4318 |
4322 | 4319 |
4323 } } // namespace v8::internal | 4320 } } // namespace v8::internal |
OLD | NEW |