v8 10.2.154 (node 18.16.0)
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-local-handle.h" // NOLINT(build/include_directory)
10#include "v8config.h" // NOLINT(build/include_directory)
11
12namespace v8 {
13
14class Object;
15
17 public:
23 bool CanBeRehashed() const;
28 bool IsValid() const;
29
30 const char* data;
32};
33
43 using CallbackFunction = StartupData (*)(Local<Object> holder, int index,
44 void* data);
46 void* data_arg = nullptr)
47 : callback(function), data(data_arg) {}
49 void* data;
50};
51// Note that these fields are called "internal fields" in the API and called
52// "embedder fields" within V8.
54
60 using CallbackFunction = void (*)(Local<Object> holder, int index,
61 StartupData payload, void* data);
63 void* data_arg = nullptr)
64 : callback(function), data(data_arg) {}
65 void (*callback)(Local<Object> holder, int index, StartupData payload,
66 void* data);
67 void* data;
68};
69
71
81 public:
82 enum class FunctionCodeHandling { kClear, kKeep };
83
93 const intptr_t* external_references = nullptr,
94 StartupData* existing_blob = nullptr);
95
104 SnapshotCreator(const intptr_t* external_references = nullptr,
105 StartupData* existing_blob = nullptr);
106
112
117
128
140
147 template <class T>
148 V8_INLINE size_t AddData(Local<Context> context, Local<T> object);
149
156 template <class T>
157 V8_INLINE size_t AddData(Local<T> object);
158
168
169 // Disallow copying and assigning.
171 void operator=(const SnapshotCreator&) = delete;
172
173 private:
174 size_t AddData(Local<Context> context, internal::Address object);
175 size_t AddData(internal::Address object);
176
177 void* data_;
178};
179
180template <class T>
182 T* object_ptr = *object;
183 internal::Address* p = reinterpret_cast<internal::Address*>(object_ptr);
184 return AddData(context, *p);
185}
186
187template <class T>
189 T* object_ptr = *object;
190 internal::Address* p = reinterpret_cast<internal::Address*>(object_ptr);
191 return AddData(*p);
192}
193
194} // namespace v8
195
196#endif // INCLUDE_V8_SNAPSHOT_H_
void operator=(const SnapshotCreator &)=delete
V8_INLINE size_t AddData(Local< Context > context, Local< T > object)
Isolate * GetIsolate()
StartupData CreateBlob(FunctionCodeHandling function_code_handling)
size_t AddContext(Local< Context > context, SerializeInternalFieldsCallback callback=SerializeInternalFieldsCallback())
V8_INLINE size_t AddData(Local< T > object)
SnapshotCreator(const SnapshotCreator &)=delete
void SetDefaultContext(Local< Context > context, SerializeInternalFieldsCallback callback=SerializeInternalFieldsCallback())
SnapshotCreator(const intptr_t *external_references=nullptr, StartupData *existing_blob=nullptr)
SnapshotCreator(Isolate *isolate, const intptr_t *external_references=nullptr, StartupData *existing_blob=nullptr)
bool CanBeRehashed() const
const char * data
Definition v8-snapshot.h:30
bool IsValid() const
uintptr_t Address
Definition v8-internal.h:29
void(*)(Local< Object > holder, int index, StartupData payload, void *data) CallbackFunction
Definition v8-snapshot.h:61
void(* callback)(Local< Object > holder, int index, StartupData payload, void *data)
Definition v8-snapshot.h:65
DeserializeInternalFieldsCallback(CallbackFunction function=nullptr, void *data_arg=nullptr)
Definition v8-snapshot.h:62
StartupData(*)(Local< Object > holder, int index, void *data) CallbackFunction
Definition v8-snapshot.h:44
SerializeInternalFieldsCallback(CallbackFunction function=nullptr, void *data_arg=nullptr)
Definition v8-snapshot.h:45
#define V8_EXPORT
Definition v8config.h:578
#define V8_INLINE
Definition v8config.h:425