v8 12.4.254 (node 22.4.1)
V8 is Google's open source JavaScript engine
Loading...
Searching...
No Matches
v8-snapshot.h
Go to the documentation of this file.
1// Copyright 2021 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 INCLUDE_V8_SNAPSHOT_H_
6#define INCLUDE_V8_SNAPSHOT_H_
7
8#include "v8-internal.h" // NOLINT(build/include_directory)
9#include "v8-isolate.h" // NOLINT(build/include_directory)
10#include "v8-local-handle.h" // NOLINT(build/include_directory)
11#include "v8config.h" // NOLINT(build/include_directory)
12
13namespace v8 {
14
15class Object;
16
17namespace internal {
18class SnapshotCreatorImpl;
19} // namespace internal
20
22 public:
28 bool CanBeRehashed() const;
33 bool IsValid() const;
34
35 const char* data;
37};
38
48 using CallbackFunction = StartupData (*)(Local<Object> holder, int index,
49 void* data);
51 void* data_arg = nullptr)
52 : callback(function), data(data_arg) {}
54 void* data;
55};
56
62 using CallbackFunction = StartupData (*)(Local<Context> holder, int index,
63 void* data);
65 void* data_arg = nullptr)
66 : callback(function), data(data_arg) {}
68 void* data;
69};
70
76 using CallbackFunction = void (*)(Local<Object> holder, int index,
77 StartupData payload, void* data);
79 void* data_arg = nullptr)
80 : callback(function), data(data_arg) {}
81
83 void* data;
84};
85
91 using CallbackFunction = void (*)(Local<Context> holder, int index,
92 StartupData payload, void* data);
94 void* data_arg = nullptr)
95 : callback(function), data(data_arg) {}
97 void* data;
98};
99
109 public:
110 enum class FunctionCodeHandling { kClear, kKeep };
111
122 V8_DEPRECATE_SOON("Use the version that passes CreateParams instead.")
123 explicit SnapshotCreator(Isolate* isolate,
124 const intptr_t* external_references = nullptr,
125 const StartupData* existing_blob = nullptr,
126 bool owns_isolate = true);
127
136 V8_DEPRECATE_SOON("Use the version that passes CreateParams instead.")
137 explicit SnapshotCreator(const intptr_t* external_references = nullptr,
138 const StartupData* existing_blob = nullptr);
139
150 explicit SnapshotCreator(const v8::Isolate::CreateParams& params);
151
164 const v8::Isolate::CreateParams& params);
165
171
175 Isolate* GetIsolate();
176
191 void SetDefaultContext(
192 Local<Context> context,
193 SerializeInternalFieldsCallback internal_fields_serializer =
195 SerializeContextDataCallback context_data_serializer =
197
208 size_t AddContext(Local<Context> context,
209 SerializeInternalFieldsCallback internal_fields_serializer =
211 SerializeContextDataCallback context_data_serializer =
213
220 template <class T>
221 V8_INLINE size_t AddData(Local<Context> context, Local<T> object);
222
229 template <class T>
230 V8_INLINE size_t AddData(Local<T> object);
231
240 StartupData CreateBlob(FunctionCodeHandling function_code_handling);
241
242 // Disallow copying and assigning.
244 void operator=(const SnapshotCreator&) = delete;
245
246 private:
247 size_t AddData(Local<Context> context, internal::Address object);
248 size_t AddData(internal::Address object);
249
250 internal::SnapshotCreatorImpl* impl_;
251 friend class internal::SnapshotCreatorImpl;
252};
253
254template <class T>
255size_t SnapshotCreator::AddData(Local<Context> context, Local<T> object) {
256 return AddData(context, internal::ValueHelper::ValueAsAddress(*object));
257}
258
259template <class T>
260size_t SnapshotCreator::AddData(Local<T> object) {
261 return AddData(internal::ValueHelper::ValueAsAddress(*object));
262}
263
264} // namespace v8
265
266#endif // INCLUDE_V8_SNAPSHOT_H_
bool CanBeRehashed() const
const char * data
Definition v8-snapshot.h:35
bool IsValid() const
DeserializeContextDataCallback(CallbackFunction function=nullptr, void *data_arg=nullptr)
Definition v8-snapshot.h:93
void(*)(Local< Context > holder, int index, StartupData payload, void *data) CallbackFunction
Definition v8-snapshot.h:92
void(*)(Local< Object > holder, int index, StartupData payload, void *data) CallbackFunction
Definition v8-snapshot.h:77
DeserializeInternalFieldsCallback(CallbackFunction function=nullptr, void *data_arg=nullptr)
Definition v8-snapshot.h:78
StartupData(*)(Local< Context > holder, int index, void *data) CallbackFunction
Definition v8-snapshot.h:63
SerializeContextDataCallback(CallbackFunction function=nullptr, void *data_arg=nullptr)
Definition v8-snapshot.h:64
StartupData(*)(Local< Object > holder, int index, void *data) CallbackFunction
Definition v8-snapshot.h:49
SerializeInternalFieldsCallback(CallbackFunction function=nullptr, void *data_arg=nullptr)
Definition v8-snapshot.h:50
#define V8_EXPORT
Definition v8config.h:753
#define V8_INLINE
Definition v8config.h:477
#define V8_DEPRECATE_SOON(message)
Definition v8config.h:571