Skip to Content
V8-wasm
API Reference

V8 Scripts, Modules & Wasm

V8 Script, UnboundScript, Module, ScriptCompiler, ScriptOrigin, Extensions, and WebAssembly module/memory handles

Generated TypeScript bindings for compiling and running classic scripts, ES modules, compile hints, extensions, and WebAssembly objects inside V8.

Contains 30 classes and 82 bound methods. Inherited WasmHandle base methods (ptr, isNull(), as()) are documented on Core Runtime & Realms.

CompiledWasmModule

class CompiledWasmModule extends WasmHandle

Wrapper around a compiled WebAssembly module, which is potentially shared by different WasmModuleObjects.

Upstream C++: v8::CompiledWasmModule (v8-wasm.h)

CompileHintsCollector

class CompileHintsCollector extends Data

Upstream V8 C++ class v8::CompileHintsCollector (v8-script.h).

Static Methods

  • static fromPtr(ptr: number): CompileHintsCollector

    Wraps a raw V8-wasm handle pointer as a CompileHintsCollector.

Extension

class Extension extends WasmHandle

Ignore

Upstream C++: v8::Extension (v8-extension.h)

Methods

  • auto_enable(): boolean

    Binds upstream V8 C++ v8::Extension::auto_enable.

  • dependency_count(): number

    Binds upstream V8 C++ v8::Extension::dependency_count.

  • getNativeFunctionTemplate(isolate: Isolate, name: V8String): FunctionTemplate

    Binds upstream V8 C++ v8::Extension::GetNativeFunctionTemplate.

  • name(): string | null

    Binds upstream V8 C++ v8::Extension::name.

  • set_auto_enable(value: boolean): void

    Binds upstream V8 C++ v8::Extension::set_auto_enable.

  • source(): StringExternalOneByteStringResource | null

    Binds upstream V8 C++ v8::Extension::source.

Location

class Location extends WasmHandle

A location in JavaScript source.

Upstream C++: v8::Location (v8-script.h)

Methods

  • getColumnNumber(): number

    Binds upstream V8 C++ v8::Location::GetColumnNumber.

  • getLineNumber(): number

    Binds upstream V8 C++ v8::Location::GetLineNumber.

Module

class Module extends Data

A compiled JavaScript module.

Upstream C++: v8::Module (v8-script.h)

Static Methods

  • static fromPtr(ptr: number): Module

    Wraps a raw V8-wasm handle pointer as a Module.

Methods

  • evaluate(context: Context): MaybeLocal<V8Promise>

    Evaluates the module and its dependencies.

    If status is kInstantiated, run the module's code and return a Promise object. On success, set status to kEvaluated and resolve the Promise with the completion value; on failure, set status to kErrored and reject the Promise with the error.

    If IsGraphAsync() is false, the returned Promise is settled.

    Upstream C++: v8::Module::Evaluate

  • evaluateForImportDefer(context: Context): MaybeLocal<V8Promise>

    Evaluates async dependencies of a module and defer its evaluation

    It implements 13.3.10.4.1 ContinueDynamicImport, Step 6.e. (https://tc39.es/proposal-defer-import-eval/#sec-ContinueDynamicImport). This will gather all async dependencies of this module and trigger their evaluation. It returns a Promise that is similar to a Promise.all for all modules that are going to be evaluated. This module and its sync dependencies are not going to be evaluated.

    Upstream C++: v8::Module::EvaluateForImportDefer

  • getException(): Value

    For a module in kErrored status, this returns the corresponding exception.

    Upstream C++: v8::Module::GetException

  • getIdentityHash(): number

    Returns the identity hash for this object.

    Upstream C++: v8::Module::GetIdentityHash

  • getModuleNamespace(phase: ModuleImportPhase): Value

    Returns the namespace object of this module.

    The module's status must be at least kInstantiated.

    Upstream C++: v8::Module::GetModuleNamespace

  • getModuleRequests(): FixedArray

    Returns the ModuleRequests for this module.

    Upstream C++: v8::Module::GetModuleRequests

  • getResourceName(): Value

    If the module is a Source Text Module, returns the name that was passed by the embedder as resource_name to the ScriptOrigin. If it's a Synthetic Module, returns the module_name passed to CreateSyntheticModule().

    Upstream C++: v8::Module::GetResourceName

  • getStatus(): ModuleStatus

    Returns the module's current status.

    Upstream C++: v8::Module::GetStatus

  • getSyntheticModuleHostDefinedOptions(): Data

    Returns the host defined options set during CreateSyntheticModule(). Must only be called on SyntheticModules.

    Upstream C++: v8::Module::GetSyntheticModuleHostDefinedOptions

  • getUnboundModuleScript(): UnboundModuleScript

    Returns the corresponding context-unbound module script.

    The module must be unevaluated, i.e. its status must not be kEvaluating, kEvaluated or kErrored.

    Upstream C++: v8::Module::GetUnboundModuleScript

  • hasTopLevelAwait(): boolean

    Returns whether this module is individually asynchronous (for example, if it's a Source Text Module Record containing a top-level await). See [[HasTLA]] in https://tc39.es/ecma262/#sec-cyclic-module-records

    Upstream C++: v8::Module::HasTopLevelAwait

  • isGraphAsync(): boolean

    Returns whether this module or any of its requested modules is async, i.e. contains top-level await.

    The module's status must be at least kInstantiated.

    Upstream C++: v8::Module::IsGraphAsync

  • isSourceTextModule(): boolean

    Returns whether the module is a SourceTextModule.

    Upstream C++: v8::Module::IsSourceTextModule

  • isSyntheticModule(): boolean

    Returns whether the module is a SyntheticModule.

    Upstream C++: v8::Module::IsSyntheticModule

  • scriptId(): number

    Returns the underlying script's id.

    The module must be a SourceTextModule and must not have a kErrored status.

    Upstream C++: v8::Module::ScriptId

  • setSyntheticModuleExport(isolate: Isolate, export_name: V8String, export_value: Value): Maybe<boolean>

    Set this module's exported value for the name export_name to the specified export_value. This method must be called only on Modules created via CreateSyntheticModule. An error will be thrown if export_name is not one of the export_names that were passed in that CreateSyntheticModule call. Returns Just(true) on success, Nothing<bool>() if an error was thrown.

    Upstream C++: v8::Module::SetSyntheticModuleExport

ModuleRequest

class ModuleRequest extends Data

Upstream V8 C++ class v8::ModuleRequest (v8-script.h).

Static Methods

  • static fromPtr(ptr: number): ModuleRequest

    Wraps a raw V8-wasm handle pointer as a ModuleRequest.

Methods

  • getImportAssertions(): FixedArray

    Binds upstream V8 C++ v8::ModuleRequest::GetImportAssertions.

  • getImportAttributes(): FixedArray

    Contains the import attributes for this request in the form: [key1, value1, source_offset1, key2, value2, source_offset2, ...]. The keys and values are of type String, and the source offsets are of type Int32. Use Module.SourceOffsetToLocation to convert the source offsets to Locations with line/column numbers.

    All attributes present in the module request will be supplied in this list, regardless of whether they are supported by the host. Per https://tc39.es/proposal-import-attributes/#sec-hostgetsupportedimportattributes, hosts are expected to throw for attributes that they do not support (as opposed to, for example, ignoring them).

    Upstream C++: v8::ModuleRequest::GetImportAttributes

  • getPhase(): ModuleImportPhase

    Returns the module import phase for this ModuleRequest.

    Upstream C++: v8::ModuleRequest::GetPhase

  • getSourceOffset(): number

    Returns the source code offset of this module request. Use Module.SourceOffsetToLocation to convert this to line/column numbers.

    Upstream C++: v8::ModuleRequest::GetSourceOffset

  • getSpecifier(): V8String

    Returns the module specifier for this ModuleRequest.

    Upstream C++: v8::ModuleRequest::GetSpecifier

OwnedBuffer

class OwnedBuffer extends WasmHandle

An owned byte buffer with associated size.

Upstream C++: v8::OwnedBuffer (v8-wasm.h)

Script

class Script extends Data

A compiled JavaScript script, tied to a Context which was active when the script was compiled.

Upstream C++: v8::Script (v8-script.h)

Static Methods

  • static compile(context: Context, source: V8String, origin?: ScriptOrigin): MaybeLocal<Script>

    A shorthand for ScriptCompiler.Compile().

    Upstream C++: v8::Script::Compile

  • static fromPtr(ptr: number): Script

    Wraps a raw V8-wasm handle pointer as a Script.

Methods

  • getCompileHintsCollector(): CompileHintsCollector

    Get a compile hints collector object which we can use later for retrieving compile hints (= positions of lazy functions which were compiled and executed).

    Upstream C++: v8::Script::GetCompileHintsCollector

  • getResourceName(): Value

    The name that was passed by the embedder as ResourceName to the ScriptOrigin. This can be either a String or Undefined.

    Upstream C++: v8::Script::GetResourceName

  • getUnboundScript(): UnboundScript

    Returns the corresponding context-unbound script.

    Upstream C++: v8::Script::GetUnboundScript

  • run(context: Context): MaybeLocal<Value>

    Runs the script returning the resulting value. It will be run in the context in which it was created (ScriptCompiler.CompileBound or UnboundScript.BindToCurrentContext()).

    Upstream C++: v8::Script::Run

  • run2(context: Context, host_defined_options: Data): MaybeLocal<Value>

    Runs the script returning the resulting value. It will be run in the context in which it was created (ScriptCompiler.CompileBound or UnboundScript.BindToCurrentContext()).

    Upstream C++: v8::Script::Run

  • scriptId(): number

    Returns the id of the corresponding context-unbound script.

    Upstream C++: v8::Script::ScriptId

ScriptCompiler

class ScriptCompiler extends WasmHandle

For compiling scripts.

Upstream C++: v8::ScriptCompiler (v8-script.h)

Static Methods

  • static cachedDataVersionTag(): number

    Return a version tag for CachedData for the current V8 version & flags.

    This value is meant only for determining whether a previously generated CachedData instance is still valid; the tag has no other meaing.

    Background: The data carried by CachedData may depend on the exact V8 version number or current compiler flags. This means that when persisting CachedData, the embedder must take care to not pass in data from another V8 version, or the same version with different features enabled.

    The easiest way to do so is to clear the embedder's cache on any such change.

    Alternatively, this tag can be stored alongside the cached data and compared when it is being used.

    Upstream C++: v8::ScriptCompiler::CachedDataVersionTag

  • static compile(context: Context, source: ScriptCompilerSource, options: ScriptCompilerCompileOptions, no_cache_reason: ScriptCompilerNoCacheReason): MaybeLocal<Script>

    Compiles the specified script (bound to current context).

    • source: Script source code.
    • pre_data: Pre-parsing data, as obtained by ScriptData.PreCompile() using pre_data speeds compilation if it's done multiple times. Owned by caller, no references are kept when this function returns. Returns: Compiled script object, bound to the context that was active when this function was called. When run it will always use this context.

    Upstream C++: v8::ScriptCompiler::Compile

  • static compile2(context: Context, source: ScriptCompilerStreamedSource, full_source_string: V8String, origin: ScriptOrigin): MaybeLocal<Script>

    Compiles a streamed script (bound to current context).

    This can only be called after the streaming has finished (ScriptStreamingTask has been run). V8 doesn't construct the source string during streaming, so the embedder needs to pass the full source here.

    Upstream C++: v8::ScriptCompiler::Compile

  • static compileFunction(context: Context, source: ScriptCompilerSource, arguments_count: number, arguments_: V8String[], context_extension_count: number, context_extensions: V8Object[], options: ScriptCompilerCompileOptions, no_cache_reason: ScriptCompilerNoCacheReason): MaybeLocal<V8Function>

    Compile a function for a given context. This is equivalent to running

    with (obj) { return function(args) { ... } }

    It is possible to specify multiple context extensions (obj in the above example).

    Upstream C++: v8::ScriptCompiler::CompileFunction

  • static compileModule(isolate: Isolate, source: ScriptCompilerSource, options: ScriptCompilerCompileOptions, no_cache_reason: ScriptCompilerNoCacheReason): MaybeLocal<Module>

    Compile an ES module, returning a Module that encapsulates the compiled code.

    Corresponds to the ParseModule abstract operation in the ECMAScript specification.

    Upstream C++: v8::ScriptCompiler::CompileModule

  • static compileModule2(context: Context, v8_source: ScriptCompilerStreamedSource, full_source_string: V8String, origin: ScriptOrigin): MaybeLocal<Module>

    Compiles a streamed module script.

    This can only be called after the streaming has finished (ScriptStreamingTask has been run). V8 doesn't construct the source string during streaming, so the embedder needs to pass the full source here.

    Upstream C++: v8::ScriptCompiler::CompileModule

  • static compileOptionsIsValid(compile_options: ScriptCompilerCompileOptions): boolean

    Binds upstream V8 C++ v8::ScriptCompiler::CompileOptionsIsValid.

  • static compileUnboundScript(isolate: Isolate, source: ScriptCompilerSource, options: ScriptCompilerCompileOptions, no_cache_reason: ScriptCompilerNoCacheReason): MaybeLocal<UnboundScript>

    Compiles the specified script (context-independent). Cached data as part of the source object can be optionally produced to be consumed later to speed up compilation of identical source scripts.

    Note that when producing cached data, the source must point to null for cached data. When consuming cached data, the cached data must have been produced by the same version of V8, and the embedder needs to ensure the cached data is the correct one for the given script.

    • source: Script source code. Returns: Compiled script object (context independent; for running it must be bound to a context).

    Upstream C++: v8::ScriptCompiler::CompileUnboundScript

  • static createCodeCache(unbound_script: UnboundScript): ScriptCompilerCachedData | null

    Creates and returns code cache for the specified unbound_script. This will return null if the script cannot be serialized. The CachedData returned by this function should be owned by the caller.

    Upstream C++: v8::ScriptCompiler::CreateCodeCache

  • static createCodeCache2(unbound_module_script: UnboundModuleScript): ScriptCompilerCachedData | null

    Creates and returns code cache for the specified unbound_module_script. This will return null if the script cannot be serialized. The CachedData returned by this function should be owned by the caller.

    Upstream C++: v8::ScriptCompiler::CreateCodeCache

  • static createCodeCacheForFunction(function_: V8Function): ScriptCompilerCachedData | null

    Creates and returns code cache for the specified function that was previously produced by CompileFunction. This will return null if the script cannot be serialized. The CachedData returned by this function should be owned by the caller.

    Upstream C++: v8::ScriptCompiler::CreateCodeCacheForFunction

ScriptCompilerCachedData

class ScriptCompilerCachedData extends WasmHandle

Compilation data that the embedder can cache and pass back to speed up future compilations. The data is produced if the CompilerOptions passed to the compilation functions in ScriptCompiler contains produce_data_to_cache = true. The data to cache can then can be retrieved from UnboundScript.

Upstream C++: v8::ScriptCompiler::CachedData (v8-script.h)

Methods

  • compatibilityCheck(isolate: Isolate): ScriptCompilerCachedDataCompatibilityCheckResult

    Check if the CachedData can be loaded in the given isolate.

    Upstream C++: v8::ScriptCompiler::CachedData::CompatibilityCheck

ScriptCompilerCompilationDetails

class ScriptCompilerCompilationDetails extends WasmHandle

Details about what happened during a compilation.

Upstream C++: v8::ScriptCompiler::CompilationDetails (v8-script.h)

ScriptCompilerConsumeCodeCacheTask

class ScriptCompilerConsumeCodeCacheTask extends WasmHandle

A task which the embedder must run on a background thread to consume a V8 code cache. Returned by ScriptCompiler.StartConsumingCodeCache.

Upstream C++: v8::ScriptCompiler::ConsumeCodeCacheTask (v8-script.h)

Methods

  • mergeWithExistingScript(): void

    Merges newly deserialized data into an existing script which was found during SourceTextAvailable. May be called only after Run() has completed. Can execute on any thread, like Run().

    Upstream C++: v8::ScriptCompiler::ConsumeCodeCacheTask::MergeWithExistingScript

  • run(): void

    Binds upstream V8 C++ v8::ScriptCompiler::ConsumeCodeCacheTask::Run.

  • shouldMergeWithExistingScript(): boolean

    Returns whether the embedder should call MergeWithExistingScript. This function may be called from any thread, any number of times, but its return value is only meaningful after SourceTextAvailable has completed.

    Upstream C++: v8::ScriptCompiler::ConsumeCodeCacheTask::ShouldMergeWithExistingScript

  • sourceTextAvailable(isolate: Isolate, source_text: V8String, origin: ScriptOrigin): void

    Provides the source text string and origin information to the consumption task. May be called before, during, or after Run(). This step checks whether the script matches an existing script in the Isolate's compilation cache. To check whether such a script was found, call ShouldMergeWithExistingScript.

    The Isolate provided must be the same one used during StartConsumingCodeCache and must be currently entered on the thread that calls this function. The source text and origin provided in this step must precisely match those used later in the ScriptCompiler.Source that will contain this ConsumeCodeCacheTask.

    Upstream C++: v8::ScriptCompiler::ConsumeCodeCacheTask::SourceTextAvailable

ScriptCompilerExternalSourceStream

class ScriptCompilerExternalSourceStream extends ScriptCompilerExternalSourceStreamBase

For streaming incomplete script data to V8. The embedder should implement a subclass of this class.

Upstream C++: v8::ScriptCompiler::ExternalSourceStream (v8-script.h)

ScriptCompilerExternalSourceStreamBase

class ScriptCompilerExternalSourceStreamBase extends WasmHandle

Upstream V8 C++ class v8::ScriptCompiler::ExternalSourceStreamBase (v8-script.h).

ScriptCompilerFlexibleExternalSourceStream

class ScriptCompilerFlexibleExternalSourceStream extends ScriptCompilerExternalSourceStreamBase

For streaming incomplete UTF16-decoded script data to V8 where each chunk can be optionally packed as 1-byte per character if it only contains 1-byte data. The embedder should implement a subclass of this class.

V8 doesn't take ownership of chunks received through this class, so the embedder is responsible for keeping the data alive until this stream is destroyed, and freeing it afterwards.

Upstream C++: v8::ScriptCompiler::FlexibleExternalSourceStream (v8-script.h)

ScriptCompilerFlexibleExternalSourceStreamChunk

class ScriptCompilerFlexibleExternalSourceStreamChunk extends WasmHandle

Upstream V8 C++ struct v8::ScriptCompiler::FlexibleExternalSourceStream::Chunk (v8-script.h).

Methods

  • end_position(): number

    Binds upstream V8 C++ v8::ScriptCompiler::FlexibleExternalSourceStream::Chunk::end_position.

ScriptCompilerScriptStreamingTask

class ScriptCompilerScriptStreamingTask extends WasmHandle

A streaming task which the embedder must run on a background thread to stream scripts into V8. Returned by ScriptCompiler.StartStreaming.

Upstream C++: v8::ScriptCompiler::ScriptStreamingTask (v8-script.h)

Methods

  • run(): void

    Binds upstream V8 C++ v8::ScriptCompiler::ScriptStreamingTask::Run.

ScriptCompilerSource

class ScriptCompilerSource extends WasmHandle

Source code which can be then compiled to a UnboundScript or Script.

Upstream C++: v8::ScriptCompiler::Source (v8-script.h)

Methods

  • getCachedData(): ScriptCompilerCachedData | null

    Ownership of the CachedData or its buffers is not transferred to the caller. The CachedData object is alive as long as the Source object is alive.

    Upstream C++: v8::ScriptCompiler::Source::GetCachedData

ScriptCompilerStreamedSource

class ScriptCompilerStreamedSource extends WasmHandle

Source code which can be streamed into V8 in pieces. It will be parsed while streaming and compiled after parsing has completed. StreamedSource must be kept alive while the streaming task is run (see ScriptStreamingTask below).

Upstream C++: v8::ScriptCompiler::StreamedSource (v8-script.h)

ScriptOrModule

class ScriptOrModule extends WasmHandle

A container type that holds relevant metadata for module loading.

This is passed back to the embedder as part of HostImportModuleDynamicallyCallback for module loading.

Upstream C++: v8::ScriptOrModule (v8-script.h)

Static Methods

  • static fromPtr(ptr: number): ScriptOrModule

    Wraps a raw V8-wasm handle pointer as a ScriptOrModule.

Methods

  • getResourceName(): Value

    The name that was passed by the embedder as ResourceName to the ScriptOrigin. This can be either a String or Undefined.

    Upstream C++: v8::ScriptOrModule::GetResourceName

  • hostDefinedOptions(): Data

    The options that were passed by the embedder as HostDefinedOptions to the ScriptOrigin.

    Upstream C++: v8::ScriptOrModule::HostDefinedOptions

SourceLocation

class SourceLocation extends WasmHandle

Encapsulates source location information. Mimics C++20's std.source_location.

Upstream C++: v8::SourceLocation (v8-source-location.h)

Methods

  • fileName(): string | null

    Returns the name of the current source file represented by this object.

    Returns: the file name as cstring.

    Upstream C++: v8::SourceLocation::FileName

  • function(): string | null

    Returns the name of the function associated with the position represented by this object, if any.

    Returns: the function name as cstring.

    Upstream C++: v8::SourceLocation::Function

  • line(): number

    Returns the line number represented by this object.

    Returns: the line number.

    Upstream C++: v8::SourceLocation::Line

UnboundModuleScript

class UnboundModuleScript extends Data

A compiled JavaScript module, not yet tied to a Context.

Upstream C++: v8::UnboundModuleScript (v8-script.h)

Static Methods

  • static fromPtr(ptr: number): UnboundModuleScript

    Wraps a raw V8-wasm handle pointer as a UnboundModuleScript.

Methods

  • getSourceMappingURL(): Value

    Data read from magic sourceMappingURL comments.

    Upstream C++: v8::UnboundModuleScript::GetSourceMappingURL

  • getSourceURL(): Value

    Data read from magic sourceURL comments.

    Upstream C++: v8::UnboundModuleScript::GetSourceURL

  • scriptId(): number

    A unique id.

    Upstream C++: v8::UnboundModuleScript::ScriptId

UnboundScript

class UnboundScript extends Data

A compiled JavaScript script, not yet tied to a Context.

Upstream C++: v8::UnboundScript (v8-script.h)

Static Methods

  • static fromPtr(ptr: number): UnboundScript

    Wraps a raw V8-wasm handle pointer as a UnboundScript.

Methods

  • bindToCurrentContext(): Script

    Binds the script to the currently entered context.

    Upstream C++: v8::UnboundScript::BindToCurrentContext

  • getColumnNumber(code_pos: number): number

    Returns zero based column number of the code_pos location in the script. -1 will be returned if no information available.

    Upstream C++: v8::UnboundScript::GetColumnNumber

  • getId(): number

    Binds upstream V8 C++ v8::UnboundScript::GetId.

  • getLineNumber(code_pos: number): number

    Returns zero based line number of the code_pos location in the script. -1 will be returned if no information available.

    Upstream C++: v8::UnboundScript::GetLineNumber

  • getScriptName(): Value

    Binds upstream V8 C++ v8::UnboundScript::GetScriptName.

  • getSourceMappingURL(): Value

    Data read from magic sourceMappingURL comments.

    Upstream C++: v8::UnboundScript::GetSourceMappingURL

  • getSourceURL(): Value

    Data read from magic sourceURL comments.

    Upstream C++: v8::UnboundScript::GetSourceURL

  • scriptId(): number

    A unique id.

    Upstream C++: v8::UnboundScript::ScriptId

WasmMemoryObject

class WasmMemoryObject extends V8Object

An instance of WebAssembly.Memory.

Upstream C++: v8::WasmMemoryObject (v8-wasm.h)

Static Methods

  • static fromPtr(ptr: number): WasmMemoryObject

    Wraps a raw V8-wasm handle pointer as a WasmMemoryObject.

Methods

  • buffer(): V8ArrayBuffer

    Returns underlying ArrayBuffer.

    Upstream C++: v8::WasmMemoryObject::Buffer

WasmModuleCompilation

class WasmModuleCompilation extends WasmHandle

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.

Upstream C++: v8::WasmModuleCompilation (v8-wasm.h)

Methods

  • abort(): void

    Abort compilation. This can be called from any thread. {Abort} must not be called repeatedly, or after {Finish}.

    Upstream C++: v8::WasmModuleCompilation::Abort

  • onBytesReceived(bytes: number, size: number): void

    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.

    Upstream C++: v8::WasmModuleCompilation::OnBytesReceived

  • setHasCompiledModuleBytes(): void

    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.

    Upstream C++: v8::WasmModuleCompilation::SetHasCompiledModuleBytes

  • setUrl(url: string | null, length: number): void

    Sets the UTF-8 encoded source URL for the {Script} object. This must be called before {Finish}.

    Upstream C++: v8::WasmModuleCompilation::SetUrl

WasmModuleObject

class WasmModuleObject extends V8Object

An instance of WebAssembly.Module.

Upstream C++: v8::WasmModuleObject (v8-wasm.h)

Static Methods

  • static fromCompiledModule(isolate: Isolate, arg1: CompiledWasmModule): MaybeLocal<WasmModuleObject>

    Efficiently re-create a WasmModuleObject, without recompiling, from a CompiledWasmModule.

    Upstream C++: v8::WasmModuleObject::FromCompiledModule

  • static fromPtr(ptr: number): WasmModuleObject

    Wraps a raw V8-wasm handle pointer as a WasmModuleObject.

WasmModuleObjectCompileOptions

class WasmModuleObjectCompileOptions extends WasmHandle

Options that influence how a Wasm module is compiled. The compile-time import options mirror those accepted by the JS WebAssembly.Module constructor ({ builtins, importedStringConstants }).

Upstream C++: v8::WasmModuleObject::CompileOptions (v8-wasm.h)

WasmModuleObjectCompileOptionsBuiltins

class WasmModuleObjectCompileOptionsBuiltins extends WasmHandle

Builtin compile-time imports, mirroring the strings accepted in the builtins array of the JS WebAssembly.Module constructor options. Combine values with bitwise-or to enable multiple builtins.

Upstream C++: v8::WasmModuleObject::CompileOptions::Builtins (v8-wasm.h)

WasmStreaming

class WasmStreaming extends WasmHandle

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.

Upstream C++: v8::WasmStreaming (v8-wasm.h)

Static Methods

  • static unpack(isolate: Isolate, value: Value): WasmStreamingShared

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

    Upstream C++: v8::WasmStreaming::Unpack

Methods

  • abort(exception: MaybeLocal<Value>): void

    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}.

    Upstream C++: v8::WasmStreaming::Abort

  • onBytesReceived(bytes: number, size: number): void

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

    Upstream C++: v8::WasmStreaming::OnBytesReceived

  • setHasCompiledModuleBytes(): void

    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.

    Upstream C++: v8::WasmStreaming::SetHasCompiledModuleBytes

  • setUrl(url: string | null, length: number): void

    Sets the UTF-8 encoded source URL for the {Script} object. This must be called before {Finish}.

    Upstream C++: v8::WasmStreaming::SetUrl

WasmStreamingModuleCachingInterface

class WasmStreamingModuleCachingInterface extends WasmHandle

Upstream V8 C++ class v8::WasmStreaming::ModuleCachingInterface (v8-wasm.h).

On this page