v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
roots-serializer.cc
Go to the documentation of this file.
1// Copyright 2018 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
6
8#include "src/heap/heap.h"
9#include "src/objects/slots.h"
10
11namespace v8 {
12namespace internal {
13
16 RootIndex first_root_to_be_serialized)
17 : Serializer(isolate, flags),
18 first_root_to_be_serialized_(first_root_to_be_serialized),
19 object_cache_index_map_(isolate->heap()),
20 can_be_rehashed_(true) {
21 for (size_t i = 0; i < static_cast<size_t>(first_root_to_be_serialized);
22 ++i) {
24 }
25}
26
28 int index;
29 if (!object_cache_index_map_.LookupOrInsert(*heap_object, &index)) {
30 // This object is not part of the object cache yet. Add it to the cache so
31 // we can refer to it via cache index from the delegating snapshot.
33 }
34 return index;
35}
36
40
41void RootsSerializer::VisitRootPointers(Root root, const char* description,
44 RootsTable& roots_table = isolate()->roots_table();
45 if (start ==
46 roots_table.begin() + static_cast<int>(first_root_to_be_serialized_)) {
47 // Serializing the root list needs special handling:
48 // - Only root list elements that have been fully serialized can be
49 // referenced using kRootArray bytecodes.
50 for (FullObjectSlot current = start; current < end; ++current) {
51 SerializeRootObject(current);
52 size_t root_index = current - roots_table.begin();
53 root_has_been_serialized_.set(root_index);
54 }
55 } else {
56 Serializer::VisitRootPointers(root, description, start, end);
57 }
58}
59
61 if (!can_be_rehashed_) return;
62 if (!obj->NeedsRehashing(cage_base())) return;
63 if (obj->CanBeRehashed(cage_base())) return;
64 can_be_rehashed_ = false;
65}
66
67} // namespace internal
68} // namespace v8
RootsTable & roots_table()
Definition isolate.h:1250
bool LookupOrInsert(Tagged< HeapObject > obj, int *index_out)
Definition serializer.h:152
RootsSerializer(Isolate *isolate, Snapshot::SerializerFlags flags, RootIndex first_root_to_be_serialized)
std::bitset< RootsTable::kEntriesCount > root_has_been_serialized_
const RootIndex first_root_to_be_serialized_
void CheckRehashability(Tagged< HeapObject > obj)
void Synchronize(VisitorSynchronization::SyncTag tag) override
ObjectCacheIndexMap object_cache_index_map_
void VisitRootPointers(Root root, const char *description, FullObjectSlot start, FullObjectSlot end) override
int SerializeInObjectCache(Handle< HeapObject > object)
FullObjectSlot begin()
Definition roots.h:639
PtrComprCageBase cage_base() const
Definition serializer.h:199
Isolate * isolate() const
Definition serializer.h:195
void VisitRootPointers(Root root, const char *description, FullObjectSlot start, FullObjectSlot end) override
SnapshotByteSink sink_
Definition serializer.h:323
void SerializeRootObject(FullObjectSlot slot)
void SerializeObject(Handle< HeapObject > o, SlotType slot_type)
void Put(uint8_t b, const char *description)
int start
int end
LineAndColumn current