Reviewers: ulan,

Description:
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.

[email protected]
BUG=chromium:152615,chromium:144230


Please review this at https://codereview.chromium.org/11040021/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files:
  M src/ic-inl.h
  M src/mark-compact.h
  M src/mark-compact.cc


Index: src/ic-inl.h
diff --git a/src/ic-inl.h b/src/ic-inl.h
index 779dfcdf4dcde5ac3ce97d584422af58968e157c..0e41093e5cdc2398f0cf00020012acd6ad8d67ad 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);
   }
Index: src/mark-compact.cc
diff --git a/src/mark-compact.cc b/src/mark-compact.cc
index 2704f51f0adf83ed3d90a1de4dcb14ce0e189c4a..5253c093e2b586538c7adc654ac10e0367f34512 100644
--- a/src/mark-compact.cc
+++ b/src/mark-compact.cc
@@ -4079,6 +4079,21 @@ 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);
+    ASSERT(Marking::IsBlack(mark_bit));
+    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<SlotsBuffer::SlotType>(reinterpret_cast<intptr_t>(slot));
Index: src/mark-compact.h
diff --git a/src/mark-compact.h b/src/mark-compact.h
index ac26ce8230bb6f57d0d11ca2812ab8df2967b458..965204e6acc77f947cbe5b74d877729722b294c1 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));



--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to