v8  6.8.275 (node 10.15.3)
V8 is Google's open source JavaScript engine
SnapshotCreator Class Reference

#include <v8.h>

Public Types

enum class  FunctionCodeHandling { kClear , kKeep }
 

Public Member Functions

 SnapshotCreator (Isolate *isolate, const intptr_t *external_references=nullptr, StartupData *existing_blob=nullptr)
 
 SnapshotCreator (const intptr_t *external_references=nullptr, StartupData *existing_blob=nullptr)
 
 ~SnapshotCreator ()
 
IsolateGetIsolate ()
 
void SetDefaultContext (Local< Context > context, SerializeInternalFieldsCallback callback=SerializeInternalFieldsCallback())
 
size_t AddContext (Local< Context > context, SerializeInternalFieldsCallback callback=SerializeInternalFieldsCallback())
 
size_t AddTemplate (Local< Template > template_obj)
 
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)
 

Detailed Description

Helper class to create a snapshot data blob.

Definition at line 8361 of file v8.h.

Member Enumeration Documentation

◆ FunctionCodeHandling

enum FunctionCodeHandling
strong
Enumerator
kClear 
kKeep 

Definition at line 8363 of file v8.h.

Constructor & Destructor Documentation

◆ SnapshotCreator() [1/3]

SnapshotCreator ( Isolate isolate,
const intptr_t *  external_references = nullptr,
StartupData existing_blob = nullptr 
)

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.

◆ SnapshotCreator() [2/3]

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

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.

◆ ~SnapshotCreator()

◆ SnapshotCreator() [3/3]

SnapshotCreator ( const SnapshotCreator )
delete

Member Function Documentation

◆ AddContext()

size_t AddContext ( Local< Context context,
SerializeInternalFieldsCallback  callback = SerializeInternalFieldsCallback() 
)

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

Parameters
callbackoptional callback to serialize internal fields.
Returns
the index of the context in the snapshot blob.

◆ AddData() [1/4]

V8_INLINE size_t AddData ( Local< Context context,
Local< T >  object 
)

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

Returns
the index for retrieval.

◆ AddData() [2/4]

size_t AddData ( Local< Context context,
Local< T >  object 
)

Definition at line 10505 of file v8.h.

◆ AddData() [3/4]

V8_INLINE size_t AddData ( Local< T >  object)

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

Returns
the index for retrieval.

◆ AddData() [4/4]

size_t AddData ( Local< T >  object)

Definition at line 10512 of file v8.h.

◆ AddTemplate()

size_t AddTemplate ( Local< Template template_obj)

Add a template to be included in the snapshot blob.

Returns
the index of the template in the snapshot blob.

◆ CreateBlob()

StartupData CreateBlob ( 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.

◆ GetIsolate()

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

◆ operator=()

void operator= ( const SnapshotCreator )
delete

◆ SetDefaultContext()

void SetDefaultContext ( Local< Context context,
SerializeInternalFieldsCallback  callback = SerializeInternalFieldsCallback() 
)

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
callbackoptional callback to serialize internal fields.

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