OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/heap/mark-compact.h" | 5 #include "src/heap/mark-compact.h" |
6 | 6 |
7 #include "src/base/atomicops.h" | 7 #include "src/base/atomicops.h" |
8 #include "src/base/bits.h" | 8 #include "src/base/bits.h" |
9 #include "src/base/sys-info.h" | 9 #include "src/base/sys-info.h" |
10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
(...skipping 2645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2656 // to new space. We should clear them to avoid encountering them during next | 2656 // to new space. We should clear them to avoid encountering them during next |
2657 // pointer iteration. This is an issue if the store buffer overflows and we | 2657 // pointer iteration. This is an issue if the store buffer overflows and we |
2658 // have to scan the entire old space, including dead objects, looking for | 2658 // have to scan the entire old space, including dead objects, looking for |
2659 // pointers to new space. | 2659 // pointers to new space. |
2660 void MarkCompactCollector::MigrateObject( | 2660 void MarkCompactCollector::MigrateObject( |
2661 HeapObject* dst, HeapObject* src, int size, AllocationSpace dest, | 2661 HeapObject* dst, HeapObject* src, int size, AllocationSpace dest, |
2662 SlotsBuffer** evacuation_slots_buffer) { | 2662 SlotsBuffer** evacuation_slots_buffer) { |
2663 Address dst_addr = dst->address(); | 2663 Address dst_addr = dst->address(); |
2664 Address src_addr = src->address(); | 2664 Address src_addr = src->address(); |
2665 DCHECK(heap()->AllowedToBeMigrated(src, dest)); | 2665 DCHECK(heap()->AllowedToBeMigrated(src, dest)); |
2666 DCHECK(dest != LO_SPACE); | 2666 DCHECK(dest != LO_SPACE && size <= Page::kMaxRegularHeapObjectSize); |
2667 if (dest == OLD_SPACE) { | 2667 if (dest == OLD_SPACE) { |
2668 DCHECK_OBJECT_SIZE(size); | |
2669 DCHECK(evacuation_slots_buffer != nullptr); | 2668 DCHECK(evacuation_slots_buffer != nullptr); |
2670 DCHECK(IsAligned(size, kPointerSize)); | 2669 DCHECK(IsAligned(size, kPointerSize)); |
2671 switch (src->ContentType()) { | 2670 switch (src->ContentType()) { |
2672 case HeapObjectContents::kTaggedValues: | 2671 case HeapObjectContents::kTaggedValues: |
2673 MigrateObjectTagged(dst, src, size, evacuation_slots_buffer); | 2672 MigrateObjectTagged(dst, src, size, evacuation_slots_buffer); |
2674 break; | 2673 break; |
2675 | 2674 |
2676 case HeapObjectContents::kMixedValues: | 2675 case HeapObjectContents::kMixedValues: |
2677 MigrateObjectMixed(dst, src, size, evacuation_slots_buffer); | 2676 MigrateObjectMixed(dst, src, size, evacuation_slots_buffer); |
2678 break; | 2677 break; |
2679 | 2678 |
2680 case HeapObjectContents::kRawValues: | 2679 case HeapObjectContents::kRawValues: |
2681 MigrateObjectRaw(dst, src, size); | 2680 MigrateObjectRaw(dst, src, size); |
2682 break; | 2681 break; |
2683 } | 2682 } |
2684 | 2683 |
2685 if (compacting_ && dst->IsJSFunction()) { | 2684 if (compacting_ && dst->IsJSFunction()) { |
2686 Address code_entry_slot = dst->address() + JSFunction::kCodeEntryOffset; | 2685 Address code_entry_slot = dst->address() + JSFunction::kCodeEntryOffset; |
2687 Address code_entry = Memory::Address_at(code_entry_slot); | 2686 Address code_entry = Memory::Address_at(code_entry_slot); |
2688 RecordMigratedCodeEntrySlot(code_entry, code_entry_slot, | 2687 RecordMigratedCodeEntrySlot(code_entry, code_entry_slot, |
2689 evacuation_slots_buffer); | 2688 evacuation_slots_buffer); |
2690 } | 2689 } |
2691 } else if (dest == CODE_SPACE) { | 2690 } else if (dest == CODE_SPACE) { |
2692 DCHECK_CODEOBJECT_SIZE(size, heap()->code_space()); | |
2693 DCHECK(evacuation_slots_buffer != nullptr); | 2691 DCHECK(evacuation_slots_buffer != nullptr); |
2694 PROFILE(isolate(), CodeMoveEvent(src_addr, dst_addr)); | 2692 PROFILE(isolate(), CodeMoveEvent(src_addr, dst_addr)); |
2695 heap()->MoveBlock(dst_addr, src_addr, size); | 2693 heap()->MoveBlock(dst_addr, src_addr, size); |
2696 RecordMigratedCodeObjectSlot(dst_addr, evacuation_slots_buffer); | 2694 RecordMigratedCodeObjectSlot(dst_addr, evacuation_slots_buffer); |
2697 Code::cast(dst)->Relocate(dst_addr - src_addr); | 2695 Code::cast(dst)->Relocate(dst_addr - src_addr); |
2698 } else { | 2696 } else { |
2699 DCHECK_OBJECT_SIZE(size); | |
2700 DCHECK(evacuation_slots_buffer == nullptr); | 2697 DCHECK(evacuation_slots_buffer == nullptr); |
2701 DCHECK(dest == NEW_SPACE); | 2698 DCHECK(dest == NEW_SPACE); |
2702 heap()->MoveBlock(dst_addr, src_addr, size); | 2699 heap()->MoveBlock(dst_addr, src_addr, size); |
2703 } | 2700 } |
2704 heap()->OnMoveEvent(dst, src, size); | 2701 heap()->OnMoveEvent(dst, src, size); |
2705 Memory::Address_at(src_addr) = dst_addr; | 2702 Memory::Address_at(src_addr) = dst_addr; |
2706 } | 2703 } |
2707 | 2704 |
2708 | 2705 |
2709 void MarkCompactCollector::MigrateObjectTagged( | 2706 void MarkCompactCollector::MigrateObjectTagged( |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3073 if (map_word.IsForwardingAddress()) { | 3070 if (map_word.IsForwardingAddress()) { |
3074 return String::cast(map_word.ToForwardingAddress()); | 3071 return String::cast(map_word.ToForwardingAddress()); |
3075 } | 3072 } |
3076 | 3073 |
3077 return String::cast(*p); | 3074 return String::cast(*p); |
3078 } | 3075 } |
3079 | 3076 |
3080 | 3077 |
3081 bool MarkCompactCollector::TryPromoteObject(HeapObject* object, | 3078 bool MarkCompactCollector::TryPromoteObject(HeapObject* object, |
3082 int object_size) { | 3079 int object_size) { |
| 3080 DCHECK(object_size <= Page::kMaxRegularHeapObjectSize); |
| 3081 |
3083 OldSpace* old_space = heap()->old_space(); | 3082 OldSpace* old_space = heap()->old_space(); |
3084 | 3083 |
3085 HeapObject* target = nullptr; | 3084 HeapObject* target = nullptr; |
3086 AllocationAlignment alignment = object->RequiredAlignment(); | 3085 AllocationAlignment alignment = object->RequiredAlignment(); |
3087 AllocationResult allocation = old_space->AllocateRaw(object_size, alignment); | 3086 AllocationResult allocation = old_space->AllocateRaw(object_size, alignment); |
3088 if (allocation.To(&target)) { | 3087 if (allocation.To(&target)) { |
3089 MigrateObject(target, object, object_size, old_space->identity(), | 3088 MigrateObject(target, object, object_size, old_space->identity(), |
3090 &migration_slots_buffer_); | 3089 &migration_slots_buffer_); |
3091 // If we end up needing more special cases, we should factor this out. | 3090 // If we end up needing more special cases, we should factor this out. |
3092 if (V8_UNLIKELY(target->IsJSArrayBuffer())) { | 3091 if (V8_UNLIKELY(target->IsJSArrayBuffer())) { |
(...skipping 1509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4602 MarkBit mark_bit = Marking::MarkBitFrom(host); | 4601 MarkBit mark_bit = Marking::MarkBitFrom(host); |
4603 if (Marking::IsBlack(mark_bit)) { | 4602 if (Marking::IsBlack(mark_bit)) { |
4604 RelocInfo rinfo(pc, RelocInfo::CODE_TARGET, 0, host); | 4603 RelocInfo rinfo(pc, RelocInfo::CODE_TARGET, 0, host); |
4605 RecordRelocSlot(&rinfo, target); | 4604 RecordRelocSlot(&rinfo, target); |
4606 } | 4605 } |
4607 } | 4606 } |
4608 } | 4607 } |
4609 | 4608 |
4610 } // namespace internal | 4609 } // namespace internal |
4611 } // namespace v8 | 4610 } // namespace v8 |
OLD | NEW |