5 #include "src/snapshot/roots-serializer.h" 7 #include "src/heap/heap.h" 8 #include "src/isolate.h" 9 #include "src/objects-inl.h" 10 #include "src/objects/slots.h" 15 RootsSerializer::RootsSerializer(Isolate* isolate,
16 RootIndex first_root_to_be_serialized)
17 : Serializer(isolate),
18 first_root_to_be_serialized_(first_root_to_be_serialized),
19 can_be_rehashed_(true) {
20 for (
size_t i = 0; i < static_cast<size_t>(first_root_to_be_serialized);
22 root_has_been_serialized_[
i] =
true;
26 int RootsSerializer::SerializeInObjectCache(HeapObject* heap_object) {
28 if (!object_cache_index_map_.LookupOrInsert(heap_object, &index)) {
31 SerializeObject(heap_object, kPlain, kStartOfObject, 0);
36 void RootsSerializer::Synchronize(VisitorSynchronization::SyncTag tag) {
37 sink_.Put(kSynchronize,
"Synchronize");
40 void RootsSerializer::VisitRootPointers(Root root,
const char* description,
41 ObjectSlot start, ObjectSlot end) {
42 RootsTable& roots_table = isolate()->heap()->roots_table();
44 roots_table.begin() +
static_cast<int>(first_root_to_be_serialized_)) {
48 for (ObjectSlot current = start; current < end; ++current) {
49 SerializeRootObject(*current);
50 size_t root_index = current - roots_table.begin();
51 root_has_been_serialized_.set(root_index);
54 Serializer::VisitRootPointers(root, description, start, end);
58 void RootsSerializer::CheckRehashability(HeapObject* obj) {
59 if (!can_be_rehashed_)
return;
60 if (!obj->NeedsRehashing())
return;
61 if (obj->CanBeRehashed())
return;
62 can_be_rehashed_ =
false;