Documentation
¶
Overview ¶
Package browser is the Executor for GOOS=js: each container process runs in its own Web Worker (worker.js), its wasi_snapshot_preview1 imports served synchronously by the engine's WASI host (package wasi) in the worker that runs the engine, over SharedArrayBuffer and Atomics.wait.
The page must be cross-origin isolated (COOP same-origin, COEP require-corp) for SharedArrayBuffer and shared WebAssembly memories.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var WorkerJS []byte
WorkerJS is the container worker script, to be served same-origin at the URL given to the executor.
Functions ¶
This section is empty.
Types ¶
type CompileStat ¶ added in v0.4.0
type CompileStat struct {
// Source is where the compiled module came from: "memory" (this
// engine's own cache), "cache" (WebAssembly.compileStreaming of a
// Response kept in Cache Storage by an earlier page), "stored"
// (WebAssembly.compile, the module being stored for the next page), or
// "bytes" (WebAssembly.compile, no Cache Storage).
Source string
// Bytes is the module's size; Took how long getting the module took,
// of which Compile in the browser's compile call alone.
Bytes int
Took time.Duration
Compile time.Duration
// Error says why Cache Storage was not used, if it was not.
Error string
}
CompileStat is one module compilation, for measurements.
type Executor ¶
type Executor struct {
// contains filtered or unexported fields
}
Executor runs each container process in a Web Worker.
func (*Executor) ClearCodeCache ¶ added in v0.4.0
func (e *Executor) ClearCodeCache()
ClearCodeCache forgets every compiled module, in memory and in Cache Storage (after images were removed, or to reclaim space).
type Options ¶
type Options struct {
// WorkerURL is where worker.js (WorkerJS) is served, same origin.
WorkerURL string
// DefaultMemoryLimitBytes applies when a Spec sets none (256 MiB).
DefaultMemoryLimitBytes int64
// MaxCompiled bounds the compiled-module cache (default 32).
MaxCompiled int
// CodeCache names a Cache Storage cache that keeps modules across
// page loads, under CodeCacheURL + <sha256>.wasm (same origin), so the
// browser can reuse its compiled code; "" disables it.
CodeCache, CodeCacheURL string
// OnCompile, when set, is told about each module the executor got.
OnCompile func(CompileStat)
}
Options configures the executor.