Documentation
¶
Overview ¶
Package browser runs kernel guests on the browser's WebAssembly API.
A guest must be transformed with Binaryen's Asyncify pass (wasm-opt --asyncify). A WebAssembly import must return before the guest continues, but a host call compiled to TypeScript may need to await. The engine unwinds the guest's call stack into a buffer, awaits the call, and rewinds the guest to the same import. A copy of that buffer is a snapshot: rewinding from it again returns from the import a second time, as fork, setjmp and longjmp need.
GoScript replaces this package with its TypeScript implementation in the repository's gs directory. These declarations give the kernel the package's API to compile against; compiled by Go, the engine reports errUnsupported.
Index ¶
- type Function
- type Instance
- type Module
- type Runtime
- func (r *Runtime) Close(ctx context.Context) error
- func (r *Runtime) Compile(ctx context.Context, wasm []byte) (engine.Module, error)
- func (r *Runtime) Define(ctx context.Context, module string, fns map[string]engine.HostFunction) error
- func (r *Runtime) Snapshotter(ctx context.Context) engine.Snapshotter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Function ¶
type Function struct{}
Function is an exported guest function. Its calls suspend across asynchronous host calls.
type Instance ¶
type Instance struct{}
Instance is a WebAssembly.Instance.
func (*Instance) ExportedFunction ¶
ExportedFunction returns an exported function, or nil.
func (*Instance) ExportedGlobal ¶
ExportedGlobal returns an exported global, or nil.
type Module ¶
type Module struct{}
Module is a compiled WebAssembly.Module.
type Runtime ¶
type Runtime struct{}
Runtime compiles guests with WebAssembly.compile.
func (*Runtime) Define ¶
func (r *Runtime) Define(ctx context.Context, module string, fns map[string]engine.HostFunction) error
Define provides fns to guests as the imports of module.
func (*Runtime) Snapshotter ¶
func (r *Runtime) Snapshotter(ctx context.Context) engine.Snapshotter
Snapshotter returns the snapshotter of the host call running under ctx, or nil when its guest is not transformed with Asyncify.