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