Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
v8::WasmStreaming Class Referencefinal

#include <v8-wasm.h>

Classes

class  ModuleCachingInterface
 

Public Types

using ModuleCachingCallback = std::function< void(ModuleCachingInterface &)>
 

Public Member Functions

 WasmStreaming (std::unique_ptr< WasmStreamingImpl > impl)
 
 ~WasmStreaming ()
 
void OnBytesReceived (const uint8_t *bytes, size_t size)
 
void Finish (bool can_use_compiled_module=true)
 
void Finish (const ModuleCachingCallback &caching_callback)
 
void Abort (MaybeLocal< Value > exception)
 
bool SetCompiledModuleBytes (const uint8_t *bytes, size_t size)
 
void SetHasCompiledModuleBytes ()
 
void SetMoreFunctionsCanBeSerializedCallback (std::function< void(CompiledWasmModule)>)
 
void SetUrl (const char *url, size_t length)
 

Static Public Member Functions

static std::shared_ptr< WasmStreamingUnpack (Isolate *isolate, Local< Value > value)
 

Static Public Attributes

static constexpr internal::ExternalPointerTag kManagedTag
 

Detailed Description

The V8 interface for WebAssembly streaming compilation. When streaming compilation is initiated, V8 passes a {WasmStreaming} object to the embedder such that the embedder can pass the input bytes for streaming compilation to V8.

Member Typedef Documentation

◆ ModuleCachingCallback

Constructor & Destructor Documentation

◆ WasmStreaming()

v8::WasmStreaming::WasmStreaming ( std::unique_ptr< WasmStreamingImpl >  impl)
explicit

◆ ~WasmStreaming()

v8::WasmStreaming::~WasmStreaming ( )

Member Function Documentation

◆ Abort()

void v8::WasmStreaming::Abort ( MaybeLocal< Value exception)

Abort streaming compilation. If {exception} has a value, then the promise associated with streaming compilation is rejected with that value. If {exception} does not have value, the promise does not get rejected. {Abort} must not be called repeatedly, or after {Finish}.

◆ Finish() [1/2]

void v8::WasmStreaming::Finish ( bool  can_use_compiled_module = true)
inline

{Finish} should be called after all received bytes where passed to {OnBytesReceived} to tell V8 that there will be no more bytes. {Finish} must not be called after {Abort} has been called already. If {can_use_compiled_module} is true and {SetCompiledModuleBytes} was previously called, the compiled module bytes can be used. If {can_use_compiled_module} is false, the compiled module bytes previously set by {SetCompiledModuleBytes} should not be used.

◆ Finish() [2/2]

void v8::WasmStreaming::Finish ( const ModuleCachingCallback caching_callback)

{Finish} should be called after all received bytes where passed to {OnBytesReceived} to tell V8 that there will be no more bytes. {Finish} must not be called after {Abort} has been called already. If {SetHasCompiledModuleBytes()} was called before, a {caching_callback} can be passed which can inspect the full received wire bytes and set cached module bytes which will be deserialized then.

◆ OnBytesReceived()

void v8::WasmStreaming::OnBytesReceived ( const uint8_t *  bytes,
size_t  size 
)

Pass a new chunk of bytes to WebAssembly streaming compilation. The buffer passed into {OnBytesReceived} is owned by the caller.

◆ SetCompiledModuleBytes()

bool v8::WasmStreaming::SetCompiledModuleBytes ( const uint8_t *  bytes,
size_t  size 
)
inline

Passes previously compiled module bytes. This must be called before {OnBytesReceived}, {Finish}, or {Abort}. Returns true if the module bytes can be used, false otherwise. The buffer passed via {bytes} and {size} is owned by the caller. If {SetCompiledModuleBytes} returns true, the buffer must remain valid until either {Finish} or {Abort} completes. The compiled module bytes should not be used until {Finish(true)} is called, because they can be invalidated later by {Finish(false)}.

◆ SetHasCompiledModuleBytes()

void v8::WasmStreaming::SetHasCompiledModuleBytes ( )

Mark that the embedder has (potentially) cached compiled module bytes (i.e. a serialized {CompiledWasmModule}) that could match this streaming request. This will cause V8 to skip streaming compilation. The embedder should then pass a callback to the {Finish} method to pass the serialized bytes, after potentially checking their validity against the full received wire bytes.

◆ SetMoreFunctionsCanBeSerializedCallback()

void v8::WasmStreaming::SetMoreFunctionsCanBeSerializedCallback ( std::function< void(CompiledWasmModule)>  )

Sets a callback which is called whenever a significant number of new functions are ready for serialization.

◆ SetUrl()

void v8::WasmStreaming::SetUrl ( const char *  url,
size_t  length 
)

◆ Unpack()

static std::shared_ptr< WasmStreaming > v8::WasmStreaming::Unpack ( Isolate isolate,
Local< Value value 
)
static

Unpacks a {WasmStreaming} object wrapped in a {Managed} for the embedder. Since the embedder is on the other side of the API, it cannot unpack the {Managed} itself.

Member Data Documentation

◆ kManagedTag

constexpr internal::ExternalPointerTag v8::WasmStreaming::kManagedTag
staticconstexpr
Initial value:
=
@ kWasmWasmStreamingTag
Definition: v8-internal.h:628

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