V8 API Reference, 7.2.502.16 (for Deno 0.2.4)
startup-serializer.h
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 
10 #include "src/snapshot/roots-serializer.h"
11 
12 namespace v8 {
13 namespace internal {
14 
15 class HeapObject;
16 class SnapshotByteSink;
17 class ReadOnlySerializer;
18 
20  public:
21  StartupSerializer(Isolate* isolate, ReadOnlySerializer* read_only_serializer);
22  ~StartupSerializer() override;
23 
24  // Serialize the current state of the heap. The order is:
25  // 1) Strong roots
26  // 2) Builtins and bytecode handlers
27  // 3) Partial snapshot cache
28  // 4) Weak references (e.g. the string table)
29  void SerializeStrongReferences();
30  void SerializeWeakReferencesAndDeferred();
31 
32  // If |obj| can be serialized in the read-only snapshot then add it to the
33  // read-only object cache if not already present and emits a
34  // ReadOnlyObjectCache bytecode into |sink|. Returns whether this was
35  // successful.
36  bool SerializeUsingReadOnlyObjectCache(SnapshotByteSink* sink,
37  HeapObject* obj, HowToCode how_to_code,
38  WhereToPoint where_to_point, int skip);
39 
40  // Adds |obj| to the partial snapshot object cache if not already present and
41  // emits a PartialSnapshotCache bytecode into |sink|.
42  void SerializeUsingPartialSnapshotCache(SnapshotByteSink* sink,
43  HeapObject* obj,
44  HowToCode how_to_code,
45  WhereToPoint where_to_point,
46  int skip);
47 
48  private:
49  void SerializeObject(HeapObject* o, HowToCode how_to_code,
50  WhereToPoint where_to_point, int skip) override;
51 
52  ReadOnlySerializer* read_only_serializer_;
53  std::vector<AccessorInfo*> accessor_infos_;
54  std::vector<CallHandlerInfo*> call_handler_infos_;
55 
56  DISALLOW_COPY_AND_ASSIGN(StartupSerializer);
57 };
58 
60  public:
61  SerializedHandleChecker(Isolate* isolate, std::vector<Context>* contexts);
62  void VisitRootPointers(Root root, const char* description, ObjectSlot start,
63  ObjectSlot end) override;
64  bool CheckGlobalAndEternalHandles();
65 
66  private:
67  void AddToSet(FixedArray serialized);
68 
69  Isolate* isolate_;
70  std::unordered_set<Object*> serialized_;
71  bool ok_ = true;
72 };
73 
74 } // namespace internal
75 } // namespace v8
76 
77 #endif // V8_SNAPSHOT_STARTUP_SERIALIZER_H_
Definition: libplatform.h:13