• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
7 #include "src/heap/invalidated-slots-inl.h"
8 #include "src/heap/memory-chunk.h"
9 #include "src/heap/spaces.h"
10 #include "src/objects/objects-inl.h"
11 
12 namespace v8 {
13 namespace internal {
14 
OldToOld(MemoryChunk * chunk)15 InvalidatedSlotsFilter InvalidatedSlotsFilter::OldToOld(MemoryChunk* chunk) {
16   return InvalidatedSlotsFilter(chunk, chunk->invalidated_slots<OLD_TO_OLD>());
17 }
18 
OldToNew(MemoryChunk * chunk)19 InvalidatedSlotsFilter InvalidatedSlotsFilter::OldToNew(MemoryChunk* chunk) {
20   return InvalidatedSlotsFilter(chunk, chunk->invalidated_slots<OLD_TO_NEW>());
21 }
22 
InvalidatedSlotsFilter(MemoryChunk * chunk,InvalidatedSlots * invalidated_slots)23 InvalidatedSlotsFilter::InvalidatedSlotsFilter(
24     MemoryChunk* chunk, InvalidatedSlots* invalidated_slots) {
25   invalidated_slots = invalidated_slots ? invalidated_slots : &empty_;
26 
27   iterator_ = invalidated_slots->begin();
28   iterator_end_ = invalidated_slots->end();
29   sentinel_ = chunk->area_end();
30 
31   // Invoke NextInvalidatedObject twice, to initialize
32   // invalidated_start_ to the first invalidated object and
33   // next_invalidated_object_ to the second one.
34   NextInvalidatedObject();
35   NextInvalidatedObject();
36 
37 #ifdef DEBUG
38   last_slot_ = chunk->area_start();
39 #endif
40 }
41 
OldToNew(MemoryChunk * chunk)42 InvalidatedSlotsCleanup InvalidatedSlotsCleanup::OldToNew(MemoryChunk* chunk) {
43   return InvalidatedSlotsCleanup(chunk, chunk->invalidated_slots<OLD_TO_NEW>());
44 }
45 
NoCleanup(MemoryChunk * chunk)46 InvalidatedSlotsCleanup InvalidatedSlotsCleanup::NoCleanup(MemoryChunk* chunk) {
47   return InvalidatedSlotsCleanup(chunk, nullptr);
48 }
49 
InvalidatedSlotsCleanup(MemoryChunk * chunk,InvalidatedSlots * invalidated_slots)50 InvalidatedSlotsCleanup::InvalidatedSlotsCleanup(
51     MemoryChunk* chunk, InvalidatedSlots* invalidated_slots) {
52   invalidated_slots_ = invalidated_slots ? invalidated_slots : &empty_;
53   iterator_ = invalidated_slots_->begin();
54   iterator_end_ = invalidated_slots_->end();
55   sentinel_ = chunk->area_end();
56 
57   NextInvalidatedObject();
58 
59 #ifdef DEBUG
60   last_free_ = chunk->area_start();
61 #endif
62 }
63 
64 }  // namespace internal
65 }  // namespace v8
66