v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
v8::SnapshotCreator Class Reference

#include <v8-snapshot.h>

Collaboration diagram for v8::SnapshotCreator:

Public Types

enum class  FunctionCodeHandling { kClear , kKeep }
 

Public Member Functions

 SnapshotCreator (Isolate *isolate, const intptr_t *external_references=nullptr, const StartupData *existing_blob=nullptr, bool owns_isolate=true)
 
 SnapshotCreator (const intptr_t *external_references=nullptr, const StartupData *existing_blob=nullptr)
 
 SnapshotCreator (const v8::Isolate::CreateParams &params)
 
 SnapshotCreator (v8::Isolate *isolate, const v8::Isolate::CreateParams &params)
 
 ~SnapshotCreator ()
 
IsolateGetIsolate ()
 
void SetDefaultContext (Local< Context > context, SerializeInternalFieldsCallback internal_fields_serializer=SerializeInternalFieldsCallback(), SerializeContextDataCallback context_data_serializer=SerializeContextDataCallback(), SerializeAPIWrapperCallback api_wrapper_serializer=SerializeAPIWrapperCallback())
 
size_t AddContext (Local< Context > context, SerializeInternalFieldsCallback internal_fields_serializer=SerializeInternalFieldsCallback(), SerializeContextDataCallback context_data_serializer=SerializeContextDataCallback(), SerializeAPIWrapperCallback api_wrapper_serializer=SerializeAPIWrapperCallback())
 
template<class T >
V8_INLINE size_t AddData (Local< Context > context, Local< T > object)
 
template<class T >
V8_INLINE size_t AddData (Local< T > object)
 
StartupData CreateBlob (FunctionCodeHandling function_code_handling)
 
 SnapshotCreator (const SnapshotCreator &)=delete
 
void operator= (const SnapshotCreator &)=delete
 
template<class T >
size_t AddData (Local< Context > context, Local< T > object)
 
template<class T >
size_t AddData (Local< T > object)
 

Private Member Functions

size_t AddData (Local< Context > context, internal::Address object)
 
size_t AddData (internal::Address object)
 

Private Attributes

internal::SnapshotCreatorImplimpl_
 

Friends

class internal::SnapshotCreatorImpl
 

Detailed Description

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.

Definition at line 135 of file v8-snapshot.h.

Member Enumeration Documentation

◆ FunctionCodeHandling

Enumerator
kClear 
kKeep 

Definition at line 137 of file v8-snapshot.h.

Constructor & Destructor Documentation

◆ SnapshotCreator() [1/5]

v8::SnapshotCreator::SnapshotCreator ( Isolate * isolate,
const intptr_t * external_references = nullptr,
const StartupData * existing_blob = nullptr,
bool owns_isolate = true )
explicit

Initialize and enter an isolate, and set it up for serialization. The isolate is either created from scratch or from an existing snapshot. The caller keeps ownership of the argument snapshot.

Parameters
existing_blobexisting snapshot from which to create this one.
external_referencesa null-terminated array of external references that must be equivalent to CreateParams::external_references.
owns_isolatewhether this SnapshotCreator should call v8::Isolate::Dispose() during its destructor.

Definition at line 351 of file api.cc.

◆ SnapshotCreator() [2/5]

v8::SnapshotCreator::SnapshotCreator ( const intptr_t * external_references = nullptr,
const StartupData * existing_blob = nullptr )
explicit

Create and enter an isolate, and set it up for serialization. The isolate is either created from scratch or from an existing snapshot. The caller keeps ownership of the argument snapshot.

Parameters
existing_blobexisting snapshot from which to create this one.
external_referencesa null-terminated array of external references that must be equivalent to CreateParams::external_references.

Definition at line 359 of file api.cc.

◆ SnapshotCreator() [3/5]

v8::SnapshotCreator::SnapshotCreator ( const v8::Isolate::CreateParams & params)
explicit

Creates an Isolate for serialization and enters it. The creator fully owns the Isolate and will invoke v8::Isolate::Dispose() during destruction.

Parameters
paramsThe parameters to initialize the Isolate for. Details:
  • params.external_references are expected to be a null-terminated array of external references.
  • params.existing_blob is an optional snapshot blob from which can be used to initialize the new blob.

Definition at line 363 of file api.cc.

◆ SnapshotCreator() [4/5]

v8::SnapshotCreator::SnapshotCreator ( v8::Isolate * isolate,
const v8::Isolate::CreateParams & params )

Initializes an Isolate for serialization and enters it. The creator does not own the Isolate but merely initialize it properly.

Parameters
isolateThe isolate that was allocated by Isolate::Allocate()~. \param params The parameters to initialize the Isolate for. Details: -params.external_referencesare expected to be a null-terminated array of external references. -params.existing_blob` is an optional snapshot blob from which can be used to initialize the new blob.

Definition at line 366 of file api.cc.

◆ ~SnapshotCreator()

v8::SnapshotCreator::~SnapshotCreator ( )

Destroy the snapshot creator, and exit and dispose of the Isolate associated with it.

Definition at line 371 of file api.cc.

◆ SnapshotCreator() [5/5]

v8::SnapshotCreator::SnapshotCreator ( const SnapshotCreator & )
delete

Member Function Documentation

◆ AddContext()

size_t v8::SnapshotCreator::AddContext ( Local< Context > context,
SerializeInternalFieldsCallback internal_fields_serializer = SerializeInternalFieldsCallback(),
SerializeContextDataCallback context_data_serializer = SerializeContextDataCallback(),
SerializeAPIWrapperCallback api_wrapper_serializer = SerializeAPIWrapperCallback() )

Add additional context to be included in the snapshot blob. The snapshot will include the global proxy.

Parameters
internal_fields_serializerSimilar to internal_fields_serializer in SetDefaultContext() but only applies to the context being added.
context_data_serializerSimilar to context_data_serializer in SetDefaultContext() but only applies to the context being added.
api_wrapper_serializerSimilar to api_wrapper_serializer in SetDefaultContext() but only applies to the context being added.

Definition at line 392 of file api.cc.

Here is the call graph for this function:

◆ AddData() [1/6]

size_t v8::SnapshotCreator::AddData ( internal::Address object)
private

◆ AddData() [2/6]

size_t v8::SnapshotCreator::AddData ( Local< Context > context,
internal::Address object )
private

◆ AddData() [3/6]

template<class T >
V8_INLINE size_t v8::SnapshotCreator::AddData ( Local< Context > context,
Local< T > object )

Attach arbitrary V8::Data to the context snapshot, which can be retrieved via Context::GetDataFromSnapshotOnce after deserialization. This data does not survive when a new snapshot is created from an existing snapshot.

Returns
the index for retrieval.

◆ AddData() [4/6]

template<class T >
size_t v8::SnapshotCreator::AddData ( Local< Context > context,
Local< T > object )

Definition at line 291 of file v8-snapshot.h.

◆ AddData() [5/6]

template<class T >
V8_INLINE size_t v8::SnapshotCreator::AddData ( Local< T > object)

Attach arbitrary V8::Data to the isolate snapshot, which can be retrieved via Isolate::GetDataFromSnapshotOnce after deserialization. This data does not survive when a new snapshot is created from an existing snapshot.

Returns
the index for retrieval.

◆ AddData() [6/6]

template<class T >
size_t v8::SnapshotCreator::AddData ( Local< T > object)

Definition at line 296 of file v8-snapshot.h.

◆ CreateBlob()

StartupData v8::SnapshotCreator::CreateBlob ( SnapshotCreator::FunctionCodeHandling function_code_handling)

Created a snapshot data blob. This must not be called from within a handle scope.

Parameters
function_code_handlingwhether to include compiled function code in the snapshot.
Returns
{ nullptr, 0 } on failure, and a startup snapshot on success. The caller acquires ownership of the data array in the return value.

Definition at line 412 of file api.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetIsolate()

Isolate * v8::SnapshotCreator::GetIsolate ( )
Returns
the isolate prepared by the snapshot creator.

Definition at line 376 of file api.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator=()

void v8::SnapshotCreator::operator= ( const SnapshotCreator & )
delete

◆ SetDefaultContext()

void v8::SnapshotCreator::SetDefaultContext ( Local< Context > context,
SerializeInternalFieldsCallback internal_fields_serializer = SerializeInternalFieldsCallback(),
SerializeContextDataCallback context_data_serializer = SerializeContextDataCallback(),
SerializeAPIWrapperCallback api_wrapper_serializer = SerializeAPIWrapperCallback() )

Set the default context to be included in the snapshot blob. The snapshot will not contain the global proxy, and we expect one or a global object template to create one, to be provided upon deserialization.

Parameters
internal_fields_serializerAn optional callback used to serialize internal pointer fields set by v8::Object::SetAlignedPointerInInternalField().
context_data_serializerAn optional callback used to serialize context embedder data set by v8::Context::SetAlignedPointerInEmbedderData().
api_wrapper_serializerAn optional callback used to serialize API wrapper references set via v8::Object::Wrap().

Definition at line 380 of file api.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

Friends And Related Symbol Documentation

◆ internal::SnapshotCreatorImpl

friend class internal::SnapshotCreatorImpl
friend

Definition at line 287 of file v8-snapshot.h.

Member Data Documentation

◆ impl_

internal::SnapshotCreatorImpl* v8::SnapshotCreator::impl_
private

Definition at line 286 of file v8-snapshot.h.


The documentation for this class was generated from the following files: