From 739c9f6f01d3076a5431c305672ef69e9adfca50 Mon Sep 17 00:00:00 2001 From: "mstarzinger@chromium.org" Date: Tue, 2 Oct 2012 15:46:55 +0000 Subject: [PATCH] Fix slot recording of code target patches. This makes sure that we only record relocation slots for code target patches that happen in marked objects. Unmarked ones might be visited again, whereas marked ones are alive and will not be visited again. R=ulan@chromium.org BUG=chromium:152615,chromium:144230 Review URL: https://codereview.chromium.org/11040021 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@12655 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/ic-inl.h | 8 ++------ src/mark-compact.cc | 14 ++++++++++++++ src/mark-compact.h | 1 + 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/ic-inl.h b/src/ic-inl.h index 779dfcd..0e41093 100644 --- a/src/ic-inl.h +++ b/src/ic-inl.h @@ -91,12 +91,8 @@ void IC::SetTargetAtAddress(Address address, Code* target) { } #endif Assembler::set_target_address_at(address, target->instruction_start()); - if (heap->gc_state() == Heap::MARK_COMPACT && - heap->mark_compact_collector()->is_compacting()) { - Code* host = heap->isolate()->inner_pointer_to_code_cache()-> - GcSafeFindCodeForInnerPointer(address); - RelocInfo rinfo(address, RelocInfo::CODE_TARGET, 0, host); - heap->mark_compact_collector()->RecordRelocSlot(&rinfo, target); + if (heap->gc_state() == Heap::MARK_COMPACT) { + heap->mark_compact_collector()->RecordCodeTargetPatch(address, target); } else { heap->incremental_marking()->RecordCodeTargetPatch(address, target); } diff --git a/src/mark-compact.cc b/src/mark-compact.cc index 2704f51..015f506 100644 --- a/src/mark-compact.cc +++ b/src/mark-compact.cc @@ -4079,6 +4079,20 @@ void MarkCompactCollector::RecordCodeEntrySlot(Address slot, Code* target) { } +void MarkCompactCollector::RecordCodeTargetPatch(Address pc, Code* target) { + ASSERT(heap()->gc_state() == Heap::MARK_COMPACT); + if (is_compacting()) { + Code* host = heap()->isolate()->inner_pointer_to_code_cache()-> + GcSafeFindCodeForInnerPointer(pc); + MarkBit mark_bit = Marking::MarkBitFrom(host); + if (Marking::IsBlack(mark_bit)) { + RelocInfo rinfo(pc, RelocInfo::CODE_TARGET, 0, host); + RecordRelocSlot(&rinfo, target); + } + } +} + + static inline SlotsBuffer::SlotType DecodeSlotType( SlotsBuffer::ObjectSlot slot) { return static_cast(reinterpret_cast(slot)); diff --git a/src/mark-compact.h b/src/mark-compact.h index ac26ce8..965204e 100644 --- a/src/mark-compact.h +++ b/src/mark-compact.h @@ -574,6 +574,7 @@ class MarkCompactCollector { void RecordRelocSlot(RelocInfo* rinfo, Object* target); void RecordCodeEntrySlot(Address slot, Code* target); + void RecordCodeTargetPatch(Address pc, Code* target); INLINE(void RecordSlot(Object** anchor_slot, Object** slot, Object* object)); -- 2.7.4