v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
roots-serializer.h
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
5#ifndef V8_SNAPSHOT_ROOTS_SERIALIZER_H_
6#define V8_SNAPSHOT_ROOTS_SERIALIZER_H_
7
8#include <bitset>
9
12
13namespace v8 {
14namespace internal {
15
16class HeapObject;
17class Object;
18class Isolate;
19enum class RootIndex : uint16_t;
20
21// Base class for serializer that iterate over roots. Also maintains a cache
22// that can be used to share non-root objects with other serializers.
24 public:
25 // The serializer expects that all roots before |first_root_to_be_serialized|
26 // are already serialized.
28 RootIndex first_root_to_be_serialized);
31
32 bool can_be_rehashed() const { return can_be_rehashed_; }
33 bool root_has_been_serialized(RootIndex root_index) const {
34 return root_has_been_serialized_.test(static_cast<size_t>(root_index));
35 }
36
38 RootIndex root_index;
39 return root_index_map()->Lookup(obj, &root_index) &&
40 root_has_been_serialized(root_index);
41 }
42
43 protected:
45
46 // Serializes |object| if not previously seen and returns its cache index.
48
50
51 private:
52 void VisitRootPointers(Root root, const char* description,
55
57 std::bitset<RootsTable::kEntriesCount> root_has_been_serialized_;
59 // Indicates whether we only serialized hash tables that we can rehash.
60 // TODO(yangguo): generalize rehashing, and remove this flag.
62};
63
64} // namespace internal
65} // namespace v8
66
67#endif // V8_SNAPSHOT_ROOTS_SERIALIZER_H_
RootsSerializer(Isolate *isolate, Snapshot::SerializerFlags flags, RootIndex first_root_to_be_serialized)
RootsSerializer(const RootsSerializer &)=delete
std::bitset< RootsTable::kEntriesCount > root_has_been_serialized_
bool root_has_been_serialized(RootIndex root_index) const
const RootIndex first_root_to_be_serialized_
RootsSerializer & operator=(const RootsSerializer &)=delete
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)
bool IsRootAndHasBeenSerialized(Tagged< HeapObject > obj) const
const RootIndexMap * root_index_map() const
Definition serializer.h:321
int start
int end
unsigned short uint16_t
Definition unicode.cc:39