Line data Source code
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 :
11 11397 : InvalidatedSlotsFilter::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 11397 : slots_in_free_space_are_valid_ = chunk->SweepingDone() && chunk->InOldSpace();
20 :
21 : InvalidatedSlots* invalidated_slots =
22 11398 : chunk->invalidated_slots() ? chunk->invalidated_slots() : &empty_;
23 11398 : iterator_ = invalidated_slots->begin();
24 11398 : iterator_end_ = invalidated_slots->end();
25 11398 : sentinel_ = chunk->area_end();
26 11398 : if (iterator_ != iterator_end_) {
27 88 : invalidated_start_ = iterator_->first->address();
28 88 : invalidated_end_ = invalidated_start_ + iterator_->second;
29 : } else {
30 11310 : invalidated_start_ = sentinel_;
31 11310 : invalidated_end_ = sentinel_;
32 : }
33 : // These values will be lazily set when needed.
34 11398 : invalidated_object_size_ = 0;
35 : #ifdef DEBUG
36 : last_slot_ = chunk->area_start();
37 : #endif
38 11398 : }
39 :
40 : } // namespace internal
41 120216 : } // namespace v8
|