Filter out recorded slots of deoptimized code objects directly after deoptimization.
authorhpayer <hpayer@chromium.org>
Mon, 10 Aug 2015 12:31:00 +0000 (05:31 -0700)
committerCommit bot <commit-bot@chromium.org>
Mon, 10 Aug 2015 12:31:09 +0000 (12:31 +0000)
BUG=chromium:507211
LOG=n

Review URL: https://codereview.chromium.org/1257653011

Cr-Commit-Position: refs/heads/master@{#30089}

src/heap/mark-compact.cc
src/heap/mark-compact.h

index f9eeaad..72fcf12 100644 (file)
@@ -294,8 +294,6 @@ void MarkCompactCollector::ClearInvalidSlotsBufferEntries(PagedSpace* space) {
 void MarkCompactCollector::ClearInvalidStoreAndSlotsBufferEntries() {
   heap_->store_buffer()->ClearInvalidStoreBufferEntries();
 
-  RemoveDeoptimizedCodeSlots();
-
   ClearInvalidSlotsBufferEntries(heap_->old_space());
   ClearInvalidSlotsBufferEntries(heap_->code_space());
   ClearInvalidSlotsBufferEntries(heap_->map_space());
@@ -780,7 +778,6 @@ void MarkCompactCollector::AbortCompaction() {
     }
     compacting_ = false;
     evacuation_candidates_.Rewind(0);
-    invalidated_code_.Rewind(0);
   }
   DCHECK_EQ(0, evacuation_candidates_.length());
 }
@@ -3569,7 +3566,11 @@ void MarkCompactCollector::InvalidateCode(Code* code) {
     MarkBit mark_bit = Marking::MarkBitFrom(code);
     if (Marking::IsWhite(mark_bit)) return;
 
-    invalidated_code_.Add(code);
+    // Ignore all slots that might have been recorded in the body of the
+    // deoptimized code object. Assumption: no slots will be recorded for
+    // this object after invalidating it.
+    RemoveObjectSlots(code->instruction_start(),
+                      code->address() + code->Size());
   }
 }
 
@@ -3580,42 +3581,6 @@ bool MarkCompactCollector::WillBeDeoptimized(Code* code) {
 }
 
 
-void MarkCompactCollector::RemoveDeoptimizedCodeSlots() {
-  int length = invalidated_code_.length();
-  for (int i = 0; i < length; i++) {
-    Code* code = invalidated_code_[i];
-    Page* p = Page::FromAddress(code->address());
-    if (!p->IsEvacuationCandidate() &&
-        !p->IsFlagSet(Page::RESCAN_ON_EVACUATION)) {
-      // Ignore all slots that might have been recorded in the body of the
-      // deoptimized code object.
-      RemoveObjectSlots(code->instruction_start(),
-                        code->address() + code->Size());
-    }
-  }
-}
-
-
-void MarkCompactCollector::RemoveDeadInvalidatedCode() {
-  int length = invalidated_code_.length();
-  for (int i = 0; i < length; i++) {
-    if (!IsMarked(invalidated_code_[i])) invalidated_code_[i] = NULL;
-  }
-}
-
-
-void MarkCompactCollector::ProcessInvalidatedCode(ObjectVisitor* visitor) {
-  int length = invalidated_code_.length();
-  for (int i = 0; i < length; i++) {
-    Code* code = invalidated_code_[i];
-    if (code != NULL) {
-      code->Iterate(visitor);
-    }
-  }
-  invalidated_code_.Rewind(0);
-}
-
-
 void MarkCompactCollector::RemoveObjectSlots(Address start_slot,
                                              Address end_slot) {
   // Remove entries by replacing them with an old-space slot containing a smi
@@ -3777,10 +3742,6 @@ void MarkCompactCollector::EvacuateNewSpaceAndCandidates() {
   EvacuationWeakObjectRetainer evacuation_object_retainer;
   heap()->ProcessAllWeakReferences(&evacuation_object_retainer);
 
-  // Visit invalidated code (we ignored all slots on it) and clear mark-bits
-  // under it.
-  ProcessInvalidatedCode(&updating_visitor);
-
   heap_->isolate()->inner_pointer_to_code_cache()->Flush();
 
   slots_buffer_allocator_.DeallocateChain(&migration_slots_buffer_);
@@ -4416,8 +4377,6 @@ void MarkCompactCollector::SweepSpaces() {
     }
   }
 
-  RemoveDeadInvalidatedCode();
-
   EvacuateNewSpaceAndCandidates();
 
   heap()->FreeDeadArrayBuffers(false);
index 9ae01fb..2610cfb 100644 (file)
@@ -751,10 +751,7 @@ class MarkCompactCollector {
   explicit MarkCompactCollector(Heap* heap);
   ~MarkCompactCollector();
 
-  void RemoveDeoptimizedCodeSlots();
   bool WillBeDeoptimized(Code* code);
-  void RemoveDeadInvalidatedCode();
-  void ProcessInvalidatedCode(ObjectVisitor* visitor);
   void EvictPopularEvacuationCandidate(Page* page);
   void ClearInvalidSlotsBufferEntries(PagedSpace* space);
   void ClearInvalidStoreAndSlotsBufferEntries();
@@ -971,7 +968,6 @@ class MarkCompactCollector {
   bool have_code_to_deoptimize_;
 
   List<Page*> evacuation_candidates_;
-  List<Code*> invalidated_code_;
 
   base::SmartPointer<FreeList> free_list_old_space_;
   base::SmartPointer<FreeList> free_list_code_space_;