// Copyright 2021 the V8 project authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef INCLUDE_V8_SNAPSHOT_H_ #define INCLUDE_V8_SNAPSHOT_H_ #include "v8-internal.h" // NOLINT(build/include_directory) #include "v8-isolate.h" // NOLINT(build/include_directory) #include "v8-local-handle.h" // NOLINT(build/include_directory) #include "v8config.h" // NOLINT(build/include_directory) namespace v8 { class Object; namespace internal { class SnapshotCreatorImpl; } // namespace internal class V8_EXPORT StartupData { … }; /** * Callback and supporting data used in SnapshotCreator to implement embedder * logic to serialize internal fields of v8::Objects. * Internal fields that directly reference V8 objects are serialized without * calling this callback. Internal fields that contain aligned pointers are * serialized by this callback if it returns non-zero result. Otherwise it is * serialized verbatim. */ struct SerializeInternalFieldsCallback { … }; /** * Similar to SerializeInternalFieldsCallback, but works with the embedder data * in a v8::Context. */ struct SerializeContextDataCallback { … }; /** * Similar to `SerializeInternalFieldsCallback`, but is used exclusively to * serialize API wrappers. The pointers for API wrappers always point into the * CppHeap. */ struct SerializeAPIWrapperCallback { … }; /** * Callback and supporting data used to implement embedder logic to deserialize * internal fields of v8::Objects. */ struct DeserializeInternalFieldsCallback { … }; /** * Similar to DeserializeInternalFieldsCallback, but works with the embedder * data in a v8::Context. */ struct DeserializeContextDataCallback { … }; struct DeserializeAPIWrapperCallback { … }; /** * Helper class to create a snapshot data blob. * * The Isolate used by a SnapshotCreator is owned by it, and will be entered * and exited by the constructor and destructor, respectively; The destructor * will also destroy the Isolate. Experimental language features, including * those available by default, are not available while creating a snapshot. */ class V8_EXPORT SnapshotCreator { … }; template <class T> size_t SnapshotCreator::AddData(Local<Context> context, Local<T> object) { … } template <class T> size_t SnapshotCreator::AddData(Local<T> object) { … } } // namespace v8 #endif // INCLUDE_V8_SNAPSHOT_H_