invalidated-slots.cc 3.07 KB
Newer Older
1 2 3 4 5
// Copyright 2017 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "src/heap/invalidated-slots.h"
6

7
#include "src/base/logging.h"
8
#include "src/heap/invalidated-slots-inl.h"
9
#include "src/heap/memory-chunk.h"
10
#include "src/heap/spaces.h"
11
#include "src/objects/objects-inl.h"
12 13 14 15

namespace v8 {
namespace internal {

16 17
InvalidatedSlotsFilter InvalidatedSlotsFilter::OldToOld(
    MemoryChunk* chunk, LivenessCheck liveness_check) {
18
  return InvalidatedSlotsFilter(chunk, chunk->invalidated_slots<OLD_TO_OLD>(),
19
                                OLD_TO_OLD, liveness_check);
20 21
}

22 23
InvalidatedSlotsFilter InvalidatedSlotsFilter::OldToNew(
    MemoryChunk* chunk, LivenessCheck liveness_check) {
24
  return InvalidatedSlotsFilter(chunk, chunk->invalidated_slots<OLD_TO_NEW>(),
25
                                OLD_TO_NEW, liveness_check);
26 27
}

28 29 30 31 32
InvalidatedSlotsFilter InvalidatedSlotsFilter::OldToShared(
    MemoryChunk* chunk, LivenessCheck liveness_check) {
  return InvalidatedSlotsFilter(chunk,
                                chunk->invalidated_slots<OLD_TO_SHARED>(),
                                OLD_TO_SHARED, liveness_check);
33 34
}

35
InvalidatedSlotsFilter::InvalidatedSlotsFilter(
36
    MemoryChunk* chunk, InvalidatedSlots* invalidated_slots,
37
    RememberedSetType remembered_set_type, LivenessCheck liveness_check) {
38
  USE(remembered_set_type);
39
  invalidated_slots = invalidated_slots ? invalidated_slots : &empty_;
40

41 42 43
  iterator_ = invalidated_slots->begin();
  iterator_end_ = invalidated_slots->end();
  sentinel_ = chunk->area_end();
44

45 46 47 48 49 50 51 52
  if (liveness_check == LivenessCheck::kYes) {
    marking_state_ =
        chunk->heap()->mark_compact_collector()->non_atomic_marking_state();
  } else {
    DCHECK_EQ(LivenessCheck::kNo, liveness_check);
    marking_state_ = nullptr;
  }

53 54 55 56 57 58
  // Invoke NextInvalidatedObject twice, to initialize
  // invalidated_start_ to the first invalidated object and
  // next_invalidated_object_ to the second one.
  NextInvalidatedObject();
  NextInvalidatedObject();

59 60
#ifdef DEBUG
  last_slot_ = chunk->area_start();
61
  remembered_set_type_ = remembered_set_type;
62 63 64
#endif
}

65 66 67 68
InvalidatedSlotsCleanup InvalidatedSlotsCleanup::OldToNew(MemoryChunk* chunk) {
  return InvalidatedSlotsCleanup(chunk, chunk->invalidated_slots<OLD_TO_NEW>());
}

69 70 71 72 73 74
InvalidatedSlotsCleanup InvalidatedSlotsCleanup::OldToShared(
    MemoryChunk* chunk) {
  return InvalidatedSlotsCleanup(chunk,
                                 chunk->invalidated_slots<OLD_TO_SHARED>());
}

75 76 77 78 79 80 81 82 83 84 85
InvalidatedSlotsCleanup InvalidatedSlotsCleanup::NoCleanup(MemoryChunk* chunk) {
  return InvalidatedSlotsCleanup(chunk, nullptr);
}

InvalidatedSlotsCleanup::InvalidatedSlotsCleanup(
    MemoryChunk* chunk, InvalidatedSlots* invalidated_slots) {
  invalidated_slots_ = invalidated_slots ? invalidated_slots : &empty_;
  iterator_ = invalidated_slots_->begin();
  iterator_end_ = invalidated_slots_->end();
  sentinel_ = chunk->area_end();

86
  NextInvalidatedObject();
87 88 89 90 91 92

#ifdef DEBUG
  last_free_ = chunk->area_start();
#endif
}

93 94
}  // namespace internal
}  // namespace v8