From 4b6403004560b1cef5f1469d884b5b874250a4c7 Mon Sep 17 00:00:00 2001
From: mlippautz <mlippautz@chromium.org>
Date: Mon, 30 May 2016 04:25:37 -0700
Subject: [PATCH] [heap] Fix recording on aborted code pages

R=ulan@chromium.org
BUG=

Review-Url: https://codereview.chromium.org/2021823002
Cr-Commit-Position: refs/heads/master@{#36580}
---
 src/heap/mark-compact.cc | 8 +++++---
 src/heap/spaces.h        | 3 ++-
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/heap/mark-compact.cc b/src/heap/mark-compact.cc
index 7a4e2f2d03..f45ef9f629 100644
--- a/src/heap/mark-compact.cc
+++ b/src/heap/mark-compact.cc
@@ -3138,8 +3138,11 @@ bool MarkCompactCollector::Evacuator::EvacuatePage(Page* page) {
     case kObjectsOldToOld:
       result = EvacuateSinglePage<kClearMarkbits>(page, &old_space_visitor_);
       if (!result) {
-        // Aborted compaction page. We can record slots here to have them
-        // processed in parallel later on.
+        // Aborted compaction page. We have to record slots here, since we might
+        // not have recorded them in first place.
+        // Note: We mark the page as aborted here to be able to record slots
+        // for code objects in |RecordMigratedSlotVisitor|.
+        page->SetFlag(Page::COMPACTION_WAS_ABORTED);
         EvacuateRecordOnlyVisitor record_visitor(collector_->heap());
         result = EvacuateSinglePage<kKeepMarking>(page, &record_visitor);
         DCHECK(result);
@@ -3234,7 +3237,6 @@ class EvacuationJobTraits {
       } else {
         // We have partially compacted the page, i.e., some objects may have
         // moved, others are still in place.
-        p->SetFlag(Page::COMPACTION_WAS_ABORTED);
         p->ClearEvacuationCandidate();
         // Slots have already been recorded so we just need to add it to the
         // sweeper.
diff --git a/src/heap/spaces.h b/src/heap/spaces.h
index 59d8cfb6d9..5d05d29762 100644
--- a/src/heap/spaces.h
+++ b/src/heap/spaces.h
@@ -713,7 +713,8 @@ class MemoryChunk {
   }
 
   bool ShouldSkipEvacuationSlotRecording() {
-    return (flags_ & kSkipEvacuationSlotsRecordingMask) != 0;
+    return ((flags_ & kSkipEvacuationSlotsRecordingMask) != 0) &&
+           !IsFlagSet(COMPACTION_WAS_ABORTED);
   }
 
   Executability executable() {