#include <v8-wasm.h>
Public Types | |
| using | ModuleCachingCallback = WasmStreaming::ModuleCachingCallback |
Public Member Functions | |
| WasmModuleCompilation () | |
| ~WasmModuleCompilation () | |
| WasmModuleCompilation (const WasmModuleCompilation &)=delete | |
| WasmModuleCompilation & | operator= (const WasmModuleCompilation &)=delete |
| void | OnBytesReceived (const uint8_t *bytes, size_t size) |
| void | Finish (Isolate *, const ModuleCachingCallback &caching_callback, const std::function< void(std::variant< Local< WasmModuleObject >, Local< Value > > module_or_error)> &resolution_callback) |
| void | Abort () |
| void | SetHasCompiledModuleBytes () |
| void | SetMoreFunctionsCanBeSerializedCallback (std::function< void(CompiledWasmModule)>) |
| void | SetUrl (const char *url, size_t length) |
An interface for asynchronous WebAssembly module compilation, to be used e.g. for implementing source phase imports. Note: This interface is experimental and can change or be removed without notice.
| v8::WasmModuleCompilation::WasmModuleCompilation | ( | ) |
Start an asynchronous module compilation. This can be called on any thread. TODO(clemensb): Add some way to pass enabled features. TODO(clemensb): Add some way to pass compile time imports.
| v8::WasmModuleCompilation::~WasmModuleCompilation | ( | ) |
|
delete |
| void v8::WasmModuleCompilation::Abort | ( | ) |
Abort compilation. This can be called from any thread. {Abort} must not be called repeatedly, or after {Finish}.
| void v8::WasmModuleCompilation::Finish | ( | Isolate * | , |
| const ModuleCachingCallback & | caching_callback, | ||
| const std::function< void(std::variant< Local< WasmModuleObject >, Local< Value > > module_or_error)> & | resolution_callback | ||
| ) |
{Finish} must be called on the main thread after all bytes were passed to {OnBytesReceived}. It eventually calls the provided callback to deliver the compiled module or an error. This callback will also be called in foreground, but not necessarily within this call. {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. This callback will happen synchronously within this call; the callback is not stored.
| void v8::WasmModuleCompilation::OnBytesReceived | ( | const uint8_t * | bytes, |
| size_t | size | ||
| ) |
Pass a new chunk of bytes to WebAssembly compilation. The buffer passed into {OnBytesReceived} is owned by the caller and will not be accessed any more after this call returns.
|
delete |
| void v8::WasmModuleCompilation::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.
| void v8::WasmModuleCompilation::SetMoreFunctionsCanBeSerializedCallback | ( | std::function< void(CompiledWasmModule)> | ) |
Sets a callback which is called whenever a significant number of new functions are ready for serialization.
| void v8::WasmModuleCompilation::SetUrl | ( | const char * | url, |
| size_t | length | ||
| ) |