| 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 && size <= Page::kMaxRegularHeapObjectSize); | 2666 DCHECK(dest != LO_SPACE); |
| 2667 if (dest == OLD_SPACE) { | 2667 if (dest == OLD_SPACE) { |
| 2668 DCHECK_OBJECT_SIZE(size); |
| 2668 DCHECK(evacuation_slots_buffer != nullptr); | 2669 DCHECK(evacuation_slots_buffer != nullptr); |
| 2669 DCHECK(IsAligned(size, kPointerSize)); | 2670 DCHECK(IsAligned(size, kPointerSize)); |
| 2670 switch (src->ContentType()) { | 2671 switch (src->ContentType()) { |
| 2671 case HeapObjectContents::kTaggedValues: | 2672 case HeapObjectContents::kTaggedValues: |
| 2672 MigrateObjectTagged(dst, src, size, evacuation_slots_buffer); | 2673 MigrateObjectTagged(dst, src, size, evacuation_slots_buffer); |
| 2673 break; | 2674 break; |
| 2674 | 2675 |
| 2675 case HeapObjectContents::kMixedValues: | 2676 case HeapObjectContents::kMixedValues: |
| 2676 MigrateObjectMixed(dst, src, size, evacuation_slots_buffer); | 2677 MigrateObjectMixed(dst, src, size, evacuation_slots_buffer); |
| 2677 break; | 2678 break; |
| 2678 | 2679 |
| 2679 case HeapObjectContents::kRawValues: | 2680 case HeapObjectContents::kRawValues: |
| 2680 MigrateObjectRaw(dst, src, size); | 2681 MigrateObjectRaw(dst, src, size); |
| 2681 break; | 2682 break; |
| 2682 } | 2683 } |
| 2683 | 2684 |
| 2684 if (compacting_ && dst->IsJSFunction()) { | 2685 if (compacting_ && dst->IsJSFunction()) { |
| 2685 Address code_entry_slot = dst->address() + JSFunction::kCodeEntryOffset; | 2686 Address code_entry_slot = dst->address() + JSFunction::kCodeEntryOffset; |
| 2686 Address code_entry = Memory::Address_at(code_entry_slot); | 2687 Address code_entry = Memory::Address_at(code_entry_slot); |
| 2687 RecordMigratedCodeEntrySlot(code_entry, code_entry_slot, | 2688 RecordMigratedCodeEntrySlot(code_entry, code_entry_slot, |
| 2688 evacuation_slots_buffer); | 2689 evacuation_slots_buffer); |
| 2689 } | 2690 } |
| 2690 } else if (dest == CODE_SPACE) { | 2691 } else if (dest == CODE_SPACE) { |
| 2692 DCHECK_CODEOBJECT_SIZE(size, heap()->code_space()); |
| 2691 DCHECK(evacuation_slots_buffer != nullptr); | 2693 DCHECK(evacuation_slots_buffer != nullptr); |
| 2692 PROFILE(isolate(), CodeMoveEvent(src_addr, dst_addr)); | 2694 PROFILE(isolate(), CodeMoveEvent(src_addr, dst_addr)); |
| 2693 heap()->MoveBlock(dst_addr, src_addr, size); | 2695 heap()->MoveBlock(dst_addr, src_addr, size); |
| 2694 RecordMigratedCodeObjectSlot(dst_addr, evacuation_slots_buffer); | 2696 RecordMigratedCodeObjectSlot(dst_addr, evacuation_slots_buffer); |
| 2695 Code::cast(dst)->Relocate(dst_addr - src_addr); | 2697 Code::cast(dst)->Relocate(dst_addr - src_addr); |
| 2696 } else { | 2698 } else { |
| 2699 DCHECK_OBJECT_SIZE(size); |
| 2697 DCHECK(evacuation_slots_buffer == nullptr); | 2700 DCHECK(evacuation_slots_buffer == nullptr); |
| 2698 DCHECK(dest == NEW_SPACE); | 2701 DCHECK(dest == NEW_SPACE); |
| 2699 heap()->MoveBlock(dst_addr, src_addr, size); | 2702 heap()->MoveBlock(dst_addr, src_addr, size); |
| 2700 } | 2703 } |
| 2701 heap()->OnMoveEvent(dst, src, size); | 2704 heap()->OnMoveEvent(dst, src, size); |
| 2702 Memory::Address_at(src_addr) = dst_addr; | 2705 Memory::Address_at(src_addr) = dst_addr; |
| 2703 } | 2706 } |
| 2704 | 2707 |
| 2705 | 2708 |
| 2706 void MarkCompactCollector::MigrateObjectTagged( | 2709 void MarkCompactCollector::MigrateObjectTagged( |
| (...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3070 if (map_word.IsForwardingAddress()) { | 3073 if (map_word.IsForwardingAddress()) { |
| 3071 return String::cast(map_word.ToForwardingAddress()); | 3074 return String::cast(map_word.ToForwardingAddress()); |
| 3072 } | 3075 } |
| 3073 | 3076 |
| 3074 return String::cast(*p); | 3077 return String::cast(*p); |
| 3075 } | 3078 } |
| 3076 | 3079 |
| 3077 | 3080 |
| 3078 bool MarkCompactCollector::TryPromoteObject(HeapObject* object, | 3081 bool MarkCompactCollector::TryPromoteObject(HeapObject* object, |
| 3079 int object_size) { | 3082 int object_size) { |
| 3080 DCHECK(object_size <= Page::kMaxRegularHeapObjectSize); | |
| 3081 | |
| 3082 OldSpace* old_space = heap()->old_space(); | 3083 OldSpace* old_space = heap()->old_space(); |
| 3083 | 3084 |
| 3084 HeapObject* target = nullptr; | 3085 HeapObject* target = nullptr; |
| 3085 AllocationAlignment alignment = object->RequiredAlignment(); | 3086 AllocationAlignment alignment = object->RequiredAlignment(); |
| 3086 AllocationResult allocation = old_space->AllocateRaw(object_size, alignment); | 3087 AllocationResult allocation = old_space->AllocateRaw(object_size, alignment); |
| 3087 if (allocation.To(&target)) { | 3088 if (allocation.To(&target)) { |
| 3088 MigrateObject(target, object, object_size, old_space->identity(), | 3089 MigrateObject(target, object, object_size, old_space->identity(), |
| 3089 &migration_slots_buffer_); | 3090 &migration_slots_buffer_); |
| 3090 // If we end up needing more special cases, we should factor this out. | 3091 // If we end up needing more special cases, we should factor this out. |
| 3091 if (V8_UNLIKELY(target->IsJSArrayBuffer())) { | 3092 if (V8_UNLIKELY(target->IsJSArrayBuffer())) { |
| (...skipping 1509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4601 MarkBit mark_bit = Marking::MarkBitFrom(host); | 4602 MarkBit mark_bit = Marking::MarkBitFrom(host); |
| 4602 if (Marking::IsBlack(mark_bit)) { | 4603 if (Marking::IsBlack(mark_bit)) { |
| 4603 RelocInfo rinfo(pc, RelocInfo::CODE_TARGET, 0, host); | 4604 RelocInfo rinfo(pc, RelocInfo::CODE_TARGET, 0, host); |
| 4604 RecordRelocSlot(&rinfo, target); | 4605 RecordRelocSlot(&rinfo, target); |
| 4605 } | 4606 } |
| 4606 } | 4607 } |
| 4607 } | 4608 } |
| 4608 | 4609 |
| 4609 } // namespace internal | 4610 } // namespace internal |
| 4610 } // namespace v8 | 4611 } // namespace v8 |
| OLD | NEW |