github.com/wasilibs/wazerox@v0.0.0-20240124024944-4923be63ab5f/experimental/checkpoint.go (about) 1 package experimental 2 3 // Snapshot holds the execution state at the time of a Snapshotter.Snapshot call. 4 type Snapshot interface { 5 // Restore sets the Wasm execution state to the capture. Because a host function 6 // calling this is resetting the pointer to the executation stack, the host function 7 // will not be able to return values in the normal way. ret is a slice of values the 8 // host function intends to return from the restored function. 9 Restore(ret []uint64) 10 } 11 12 // Snapshotter allows host functions to snapshot the WebAssembly execution environment. 13 type Snapshotter interface { 14 // Snapshot captures the current execution state. 15 Snapshot() Snapshot 16 } 17 18 // EnableSnapshotterKey is a context key to indicate that snapshotting should be enabled. 19 // The context.Context passed to a exported function invocation should have this key set 20 // to a non-nil value, and host functions will be able to retrieve it using SnapshotterKey. 21 type EnableSnapshotterKey struct{} 22 23 // SnapshotterKey is a context key to access a Snapshotter from a host function. 24 // It is only present if EnableSnapshotter was set in the function invocation context. 25 type SnapshotterKey struct{}