v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
startup-serializer.h
Go to the documentation of this file.
1// Copyright 2016 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_STARTUP_SERIALIZER_H_
6#define V8_SNAPSHOT_STARTUP_SERIALIZER_H_
7
8#include <unordered_set>
9
12
13namespace v8 {
14namespace internal {
15
16class HeapObject;
17class SnapshotByteSink;
18class SharedHeapSerializer;
19
21 public:
23 SharedHeapSerializer* shared_heap_serializer);
24 ~StartupSerializer() override;
27
28 // Serialize the current state of the heap. The order is:
29 // 1) Strong roots
30 // 2) Builtins and bytecode handlers
31 // 3) Startup object cache
32 // 4) Weak references (e.g. the string table)
33 void SerializeStrongReferences(const DisallowGarbageCollection& no_gc);
34 void SerializeWeakReferencesAndDeferred();
35
36 // If |obj| can be serialized in the shared heap snapshot then add it to the
37 // shareable object cache if not already present and emits a
38 // SharedHeapObjectCache bytecode into |sink|. Returns whether this was
39 // successful.
40 bool SerializeUsingSharedHeapObjectCache(SnapshotByteSink* sink,
42
43 // Adds |obj| to the startup object object cache if not already present and
44 // emits a StartupObjectCache bytecode into |sink|.
45 void SerializeUsingStartupObjectCache(SnapshotByteSink* sink,
47
48 // The per-heap dirty FinalizationRegistry list is weak and not serialized. No
49 // JSFinalizationRegistries should be used during startup.
50 void CheckNoDirtyFinalizationRegistries();
51
52 private:
53 void SerializeObjectImpl(Handle<HeapObject> o, SlotType slot_type) override;
54
58};
59
61 public:
63 std::vector<Tagged<Context>>* contexts);
64 void VisitRootPointers(Root root, const char* description,
67
68 private:
69 void AddToSet(Tagged<FixedArray> serialized);
70
72 std::unordered_set<Tagged<Object>, Object::Hasher> serialized_;
73 bool ok_ = true;
74};
75
76} // namespace internal
77} // namespace v8
78
79#endif // V8_SNAPSHOT_STARTUP_SERIALIZER_H_
std::unordered_set< Tagged< Object >, Object::Hasher > serialized_
SerializedHandleChecker(Isolate *isolate, std::vector< Tagged< Context > > *contexts)
void VisitRootPointers(Root root, const char *description, FullObjectSlot start, FullObjectSlot end) override
void AddToSet(Tagged< FixedArray > serialized)
SharedHeapSerializer *const shared_heap_serializer_
GlobalHandleVector< FunctionTemplateInfo > function_template_infos_
StartupSerializer & operator=(const StartupSerializer &)=delete
StartupSerializer(const StartupSerializer &)=delete
GlobalHandleVector< AccessorInfo > accessor_infos_
int start
int end
#define V8_EXPORT_PRIVATE
Definition macros.h:460