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

Public Member Functions

 Serializer (Isolate *isolate)
 
 Serializer (const Serializer &)=delete
 
Serializeroperator= (const Serializer &)=delete
 
Maybe< bool > WriteValue (Local< Context > context, Local< Value > value, Local< Value > transfer)
 
std::unique_ptr< SerializationDataRelease ()
 
void AppendBackingStoresTo (std::vector< std::shared_ptr< BackingStore > > *to)
 
- Public Member Functions inherited from v8::ValueSerializer::Delegate
virtual ~Delegate ()=default
 
virtual bool HasCustomHostObject (Isolate *isolate)
 
virtual Maybe< bool > IsHostObject (Isolate *isolate, Local< Object > object)
 
virtual Maybe< bool > WriteHostObject (Isolate *isolate, Local< Object > object)
 

Protected Member Functions

void ThrowDataCloneError (Local< String > message) override
 
Maybe< uint32_t > GetSharedArrayBufferId (Isolate *isolate, Local< SharedArrayBuffer > shared_array_buffer) override
 
Maybe< uint32_t > GetWasmModuleTransferId (Isolate *isolate, Local< WasmModuleObject > module) override
 
void * ReallocateBufferMemory (void *old_buffer, size_t size, size_t *actual_size) override
 
void FreeBufferMemory (void *buffer) override
 
bool AdoptSharedValueConveyor (Isolate *isolate, SharedValueConveyor &&conveyor) override
 

Private Member Functions

Maybe< bool > PrepareTransfer (Local< Context > context, Local< Value > transfer)
 
Maybe< bool > FinalizeTransfer ()
 

Private Attributes

Isolateisolate_
 
ValueSerializer serializer_
 
std::unique_ptr< SerializationDatadata_
 
std::vector< Global< ArrayBuffer > > array_buffers_
 
std::vector< Global< SharedArrayBuffer > > shared_array_buffers_
 
std::vector< Global< WasmModuleObject > > wasm_modules_
 
std::vector< std::shared_ptr< v8::BackingStore > > backing_stores_
 
size_t current_memory_usage_
 

Detailed Description

Definition at line 6153 of file d8.cc.

Constructor & Destructor Documentation

◆ Serializer() [1/2]

v8::Serializer::Serializer ( Isolate * isolate)
inlineexplicit

Definition at line 6155 of file d8.cc.

◆ Serializer() [2/2]

v8::Serializer::Serializer ( const Serializer & )
delete

Member Function Documentation

◆ AdoptSharedValueConveyor()

bool v8::Serializer::AdoptSharedValueConveyor ( Isolate * isolate,
SharedValueConveyor && conveyor )
inlineoverrideprotectedvirtual

Called when the first shared value is serialized. All subsequent shared values will use the same conveyor.

The embedder must ensure the lifetime of the conveyor matches the lifetime of the serialized data.

If the embedder supports serializing shared values, this method should return true. Otherwise the embedder should throw an exception and return false.

This method is called at most once per serializer.

Reimplemented from v8::ValueSerializer::Delegate.

Definition at line 6249 of file d8.cc.

◆ AppendBackingStoresTo()

void v8::Serializer::AppendBackingStoresTo ( std::vector< std::shared_ptr< BackingStore > > * to)
inline

Definition at line 6190 of file d8.cc.

◆ FinalizeTransfer()

Maybe< bool > v8::Serializer::FinalizeTransfer ( )
inlineprivate

Definition at line 6294 of file d8.cc.

Here is the call graph for this function:

◆ FreeBufferMemory()

void v8::Serializer::FreeBufferMemory ( void * buffer)
inlineoverrideprotectedvirtual

Frees a buffer allocated with |ReallocateBufferMemory|.

The default implementation uses the stdlib's free() function.

Reimplemented from v8::ValueSerializer::Delegate.

Definition at line 6247 of file d8.cc.

◆ GetSharedArrayBufferId()

Maybe< uint32_t > v8::Serializer::GetSharedArrayBufferId ( Isolate * isolate,
Local< SharedArrayBuffer > shared_array_buffer )
inlineoverrideprotectedvirtual

Called when the ValueSerializer is going to serialize a SharedArrayBuffer object. The embedder must return an ID for the object, using the same ID if this SharedArrayBuffer has already been serialized in this buffer. When deserializing, this ID will be passed to ValueDeserializer::GetSharedArrayBufferFromId as |clone_id|.

If the object cannot be serialized, an exception should be thrown and Nothing<uint32_t>() returned.

Reimplemented from v8::ValueSerializer::Delegate.

Definition at line 6202 of file d8.cc.

◆ GetWasmModuleTransferId()

Maybe< uint32_t > v8::Serializer::GetWasmModuleTransferId ( Isolate * isolate,
Local< WasmModuleObject > module )
inlineoverrideprotectedvirtual

Reimplemented from v8::ValueSerializer::Delegate.

Definition at line 6218 of file d8.cc.

◆ operator=()

Serializer & v8::Serializer::operator= ( const Serializer & )
delete

◆ PrepareTransfer()

Maybe< bool > v8::Serializer::PrepareTransfer ( Local< Context > context,
Local< Value > transfer )
inlineprivate

Definition at line 6256 of file d8.cc.

Here is the call graph for this function:

◆ ReallocateBufferMemory()

void * v8::Serializer::ReallocateBufferMemory ( void * old_buffer,
size_t size,
size_t * actual_size )
inlineoverrideprotectedvirtual

Allocates memory for the buffer of at least the size provided. The actual size (which may be greater or equal) is written to |actual_size|. If no buffer has been allocated yet, nullptr will be provided.

If the memory cannot be allocated, nullptr should be returned. |actual_size| will be ignored. It is assumed that |old_buffer| is still valid in this case and has not been modified.

The default implementation uses the stdlib's realloc() function.

Reimplemented from v8::ValueSerializer::Delegate.

Definition at line 6233 of file d8.cc.

◆ Release()

std::unique_ptr< SerializationData > v8::Serializer::Release ( )
inline

Definition at line 6188 of file d8.cc.

Here is the caller graph for this function:

◆ ThrowDataCloneError()

void v8::Serializer::ThrowDataCloneError ( Local< String > message)
inlineoverrideprotectedvirtual

Handles the case where a DataCloneError would be thrown in the structured clone spec. Other V8 embedders may throw some other appropriate exception type.

Implements v8::ValueSerializer::Delegate.

Definition at line 6198 of file d8.cc.

◆ WriteValue()

Maybe< bool > v8::Serializer::WriteValue ( Local< Context > context,
Local< Value > value,
Local< Value > transfer )
inline

Definition at line 6163 of file d8.cc.

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

Member Data Documentation

◆ array_buffers_

std::vector<Global<ArrayBuffer> > v8::Serializer::array_buffers_
private

Definition at line 6318 of file d8.cc.

◆ backing_stores_

std::vector<std::shared_ptr<v8::BackingStore> > v8::Serializer::backing_stores_
private

Definition at line 6321 of file d8.cc.

◆ current_memory_usage_

size_t v8::Serializer::current_memory_usage_
private

Definition at line 6322 of file d8.cc.

◆ data_

std::unique_ptr<SerializationData> v8::Serializer::data_
private

Definition at line 6317 of file d8.cc.

◆ isolate_

Isolate* v8::Serializer::isolate_
private

Definition at line 6315 of file d8.cc.

◆ serializer_

ValueSerializer v8::Serializer::serializer_
private

Definition at line 6316 of file d8.cc.

◆ shared_array_buffers_

std::vector<Global<SharedArrayBuffer> > v8::Serializer::shared_array_buffers_
private

Definition at line 6319 of file d8.cc.

◆ wasm_modules_

std::vector<Global<WasmModuleObject> > v8::Serializer::wasm_modules_
private

Definition at line 6320 of file d8.cc.


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