1 // Copyright 2017 the V8 project authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include "src/heap/invalidated-slots.h" 6 #include "src/heap/spaces.h" 7 8 namespace v8 { 9 namespace internal { 10 InvalidatedSlotsFilter(MemoryChunk * chunk)11InvalidatedSlotsFilter::InvalidatedSlotsFilter(MemoryChunk* chunk) { 12 // Adjust slots_in_free_space_are_valid_ if more spaces are added. 13 DCHECK_IMPLIES(chunk->invalidated_slots() != nullptr, 14 chunk->InOldSpace() || chunk->InLargeObjectSpace()); 15 // The sweeper removes invalid slots and makes free space available for 16 // allocation. Slots for new objects can be recorded in the free space. 17 // Note that we cannot simply check for SweepingDone because pages in large 18 // object space are not swept but have SweepingDone() == true. 19 slots_in_free_space_are_valid_ = chunk->SweepingDone() && chunk->InOldSpace(); 20 21 InvalidatedSlots* invalidated_slots = 22 chunk->invalidated_slots() ? chunk->invalidated_slots() : &empty_; 23 iterator_ = invalidated_slots->begin(); 24 iterator_end_ = invalidated_slots->end(); 25 sentinel_ = chunk->area_end(); 26 if (iterator_ != iterator_end_) { 27 invalidated_start_ = iterator_->first->address(); 28 invalidated_end_ = invalidated_start_ + iterator_->second; 29 } else { 30 invalidated_start_ = sentinel_; 31 invalidated_end_ = sentinel_; 32 } 33 // These values will be lazily set when needed. 34 invalidated_object_ = nullptr; 35 invalidated_object_size_ = 0; 36 #ifdef DEBUG 37 last_slot_ = chunk->area_start(); 38 #endif 39 } 40 41 } // namespace internal 42 } // namespace v8 43