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_READ_ONLY_SERIALIZER_H_ |
6 | #define V8_SNAPSHOT_READ_ONLY_SERIALIZER_H_ |
7 | |
8 | #include "src/snapshot/roots-serializer.h" |
9 | |
10 | namespace v8 { |
11 | namespace internal { |
12 | |
13 | class HeapObject; |
14 | class SnapshotByteSink; |
15 | |
16 | class V8_EXPORT_PRIVATE ReadOnlySerializer : public RootsSerializer { |
17 | public: |
18 | explicit ReadOnlySerializer(Isolate* isolate); |
19 | ~ReadOnlySerializer() override; |
20 | |
21 | void SerializeReadOnlyRoots(); |
22 | |
23 | // Completes the serialization of the read-only object cache and serializes |
24 | // any deferred objects. |
25 | void FinalizeSerialization(); |
26 | |
27 | // If |obj| can be serialized in the read-only snapshot then add it to the |
28 | // read-only object cache if not already present and emit a |
29 | // ReadOnlyObjectCache bytecode into |sink|. Returns whether this was |
30 | // successful. |
31 | bool SerializeUsingReadOnlyObjectCache(SnapshotByteSink* sink, |
32 | HeapObject obj); |
33 | |
34 | private: |
35 | void SerializeObject(HeapObject o) override; |
36 | bool MustBeDeferred(HeapObject object) override; |
37 | |
38 | DISALLOW_COPY_AND_ASSIGN(ReadOnlySerializer); |
39 | }; |
40 | |
41 | } // namespace internal |
42 | } // namespace v8 |
43 | |
44 | #endif // V8_SNAPSHOT_READ_ONLY_SERIALIZER_H_ |
45 | |