Reviewers: Hannes Payer,

Description:
Mark pages created during bootstrapping as never-evacuate.

This is to ensure that immutable immortal objects created during
bootstrapping are not relocated.

[email protected]

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

Base URL: https://chromium.googlesource.com/v8/v8.git@master

Affected files (+25, -4 lines):
  M src/heap/heap.cc
  M src/heap/mark-compact.cc
  M src/heap/spaces.h
  M src/heap/spaces.cc


Index: src/heap/heap.cc
diff --git a/src/heap/heap.cc b/src/heap/heap.cc
index 8feec8f3b59e5ce8c0d3e37a141a896e74909c4c..b3b6278dd3a72713c1b089e67bfb172d2a2f6128 100644
--- a/src/heap/heap.cc
+++ b/src/heap/heap.cc
@@ -5559,7 +5559,17 @@ void Heap::SetStackLimits() {
 }


-void Heap::NotifyDeserializationComplete() { deserialization_complete_ = true; }
+void Heap::NotifyDeserializationComplete() {
+  deserialization_complete_ = true;
+#ifdef DEBUG
+  // All pages right after bootstrapping must be marked as never-evacuate.
+  PagedSpaces spaces(this);
+  for (PagedSpace* s = spaces.next(); s != NULL; s = spaces.next()) {
+    PageIterator it(s);
+    while (it.has_next()) CHECK(it.next()->NeverEvacuate());
+  }
+#endif  // DEBUG
+}


 void Heap::TearDown() {
Index: src/heap/mark-compact.cc
diff --git a/src/heap/mark-compact.cc b/src/heap/mark-compact.cc
index a9ea707a9bff90a5fe4e56c9ca3f24a889a87a45..e5ca53ee167f5e0972b078012073d17d87e10a1e 100644
--- a/src/heap/mark-compact.cc
+++ b/src/heap/mark-compact.cc
@@ -242,6 +242,7 @@ void MarkCompactCollector::TearDown() {


 void MarkCompactCollector::AddEvacuationCandidate(Page* p) {
+  if (p->NeverEvacuate()) return;
   p->MarkEvacuationCandidate();
   evacuation_candidates_.Add(p);
 }
@@ -718,8 +719,6 @@ void MarkCompactCollector::CollectEvacuationCandidates(PagedSpace* space) {
   Candidate* least = NULL;

   PageIterator it(space);
-  if (it.has_next()) it.next();  // Never compact the first page.
-
   while (it.has_next()) {
     Page* p = it.next();
     p->ClearEvacuationCandidate();
Index: src/heap/spaces.cc
diff --git a/src/heap/spaces.cc b/src/heap/spaces.cc
index 1a0d0bbecc622e3eb595cbf3442fdd7727d6b520..de752f3b780b5173be0aac9049c6b66a3414988d 100644
--- a/src/heap/spaces.cc
+++ b/src/heap/spaces.cc
@@ -1032,6 +1032,9 @@ bool PagedSpace::Expand() {
executable());
   if (p == NULL) return false;

+ // Pages created during bootstrapping may contain immortal immovable objects.
+  if (!heap()->deserialization_complete()) p->MarkNeverEvacuate();
+
   DCHECK(Capacity() <= max_capacity_);

   p->InsertAfter(anchor_.prev_page());
Index: src/heap/spaces.h
diff --git a/src/heap/spaces.h b/src/heap/spaces.h
index efb784ca69cc977259d82a3b74977847270cafc5..3a6bd307af5bf85e032f29e1aec10001472e81d9 100644
--- a/src/heap/spaces.h
+++ b/src/heap/spaces.h
@@ -373,6 +373,7 @@ class MemoryChunk {
     CONTAINS_ONLY_DATA,
     EVACUATION_CANDIDATE,
     RESCAN_ON_EVACUATION,
+    NEVER_EVACUATE,  // May contain immortal immutables.

// WAS_SWEPT indicates that marking bits have been cleared by the sweeper,
     // otherwise marking bits are still intact.
@@ -604,7 +605,14 @@ class MemoryChunk {

   static const int kFlagsOffset = kPointerSize;

-  bool IsEvacuationCandidate() { return IsFlagSet(EVACUATION_CANDIDATE); }
+  bool NeverEvacuate() { return IsFlagSet(NEVER_EVACUATE); }
+
+  void MarkNeverEvacuate() { SetFlag(NEVER_EVACUATE); }
+
+  bool IsEvacuationCandidate() {
+ DCHECK(!(IsFlagSet(NEVER_EVACUATE) && IsFlagSet(EVACUATION_CANDIDATE)));
+    return IsFlagSet(EVACUATION_CANDIDATE);
+  }

   bool ShouldSkipEvacuationSlotRecording() {
     return (flags_ & kSkipEvacuationSlotsRecordingMask) != 0;
@@ -619,6 +627,7 @@ class MemoryChunk {
   inline SlotsBuffer** slots_buffer_address() { return &slots_buffer_; }

   void MarkEvacuationCandidate() {
+    DCHECK(!IsFlagSet(NEVER_EVACUATE));
     DCHECK(slots_buffer_ == NULL);
     SetFlag(EVACUATION_CANDIDATE);
   }


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to