diff --git a/api/process.capnp b/api/process.capnp index 518e6a63..15e95cf4 100644 --- a/api/process.capnp +++ b/api/process.capnp @@ -7,13 +7,11 @@ $Go.import("github.com/wetware/ww/internal/api/process"); interface Executor { - spawn @0 (byteCode :Data, entryPoint :Text = "run") -> (process :Process); - # spawn a WASM based process from the binary module with the target - # entry function + exec @0 (bytecode :Data) -> (process :Process); + # exec a WASM based process } interface Process { - start @0 () -> (); - stop @1 () -> (); - wait @2 () -> (exitCode :UInt32); + wait @0 () -> (exitCode :UInt32); + kill @1 () -> (); } diff --git a/cmd/ww/main.go b/cmd/ww/main.go index 4cf1812c..1d6e10a1 100644 --- a/cmd/ww/main.go +++ b/cmd/ww/main.go @@ -13,6 +13,7 @@ import ( "github.com/wetware/ww/internal/cmd/cluster" "github.com/wetware/ww/internal/cmd/debug" + "github.com/wetware/ww/internal/cmd/run" "github.com/wetware/ww/internal/cmd/start" ww "github.com/wetware/ww/pkg" ) @@ -58,11 +59,12 @@ var flags = []cli.Flag{ var commands = []*cli.Command{ start.Command(), cluster.Command(), + run.Command(), debug.Command(), } func main() { - run(&cli.App{ + app := &cli.App{ Name: "wetware", HelpName: "ww", Usage: "simple, secure clusters", @@ -75,10 +77,8 @@ func main() { Metadata: map[string]interface{}{ "version": ww.Version, }, - }) -} + } -func run(app *cli.App) { if err := app.Run(os.Args); err != nil { log.Fatal(err) } diff --git a/go.mod b/go.mod index 8284ff88..d9ee4df6 100644 --- a/go.mod +++ b/go.mod @@ -35,6 +35,7 @@ require ( github.com/ipfs/go-ds-badger2 v0.1.3 github.com/lthibault/go-libp2p-inproc-transport v0.4.0 github.com/multiformats/go-multistream v0.4.1 + github.com/stealthrocket/wazergo v0.11.0 github.com/stretchr/testify v1.8.2 github.com/tetratelabs/wazero v1.0.1 github.com/thejerf/suture/v4 v4.0.2 diff --git a/go.sum b/go.sum index dce7bdd9..d94ffe65 100644 --- a/go.sum +++ b/go.sum @@ -472,6 +472,8 @@ github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tL github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s= +github.com/stealthrocket/wazergo v0.11.0 h1:uei6jlnTQxjpuhzW31QgSkHi4eVKUaQmOf7WVytOCq8= +github.com/stealthrocket/wazergo v0.11.0/go.mod h1:ONoLQpwgBDX9VGB+CCAbzTNDmJJi5kcnFLL+pWIGF5M= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= diff --git a/guest/tinygo/imports.go b/guest/tinygo/imports.go new file mode 100644 index 00000000..41877372 --- /dev/null +++ b/guest/tinygo/imports.go @@ -0,0 +1,7 @@ +//go:build wasm || tinygo.wasm || wasi + +package ww + +//go:wasm-module ww +//go:export __test +func test(a, b uint32) uint32 diff --git a/guest/tinygo/shims.go b/guest/tinygo/shims.go new file mode 100644 index 00000000..a04905f3 --- /dev/null +++ b/guest/tinygo/shims.go @@ -0,0 +1,14 @@ +//go:build !purego && !appengine && !wasm && !tinygo.wasm && !wasi + +package ww + +/* + + shims.go contains shim functions for WASM imports, which allows + symbol names to resolve on non-WASM architectures. + +*/ + +func test(a, b uint32) uint32 { + return a + b +} diff --git a/guest/tinygo/testdata/main.go b/guest/tinygo/testdata/main.go new file mode 100644 index 00000000..9b57ad4b --- /dev/null +++ b/guest/tinygo/testdata/main.go @@ -0,0 +1,18 @@ +package main + +import ( + "fmt" + + ww "github.com/wetware/ww/guest/tinygo" +) + +func main() { + // it, release := ww.Ls(context.Background()) + // defer release() + + // for name := it.Next(); name != ""; name = it.Next() { + // fmt.Println(name) + // } + + fmt.Println(ww.Test(40, 2)) +} diff --git a/guest/tinygo/testdata/main.wasm b/guest/tinygo/testdata/main.wasm new file mode 100755 index 00000000..3e042154 Binary files /dev/null and b/guest/tinygo/testdata/main.wasm differ diff --git a/guest/tinygo/testdata/main.wat b/guest/tinygo/testdata/main.wat new file mode 100644 index 00000000..933974f7 --- /dev/null +++ b/guest/tinygo/testdata/main.wat @@ -0,0 +1,3984 @@ +(module + (type $i32_i32_i32_i32_=>_i32 (func (param i32 i32 i32 i32) (result i32))) + (type $i32_=>_none (func (param i32))) + (type $none_=>_none (func)) + (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) + (type $i32_i32_=>_none (func (param i32 i32))) + (type $i32_=>_i32 (func (param i32) (result i32))) + (type $none_=>_i32 (func (result i32))) + (type $i32_i32_i32_i32_=>_none (func (param i32 i32 i32 i32))) + (type $i32_i64_i32_=>_i32 (func (param i32 i64 i32) (result i32))) + (import "ww" "__test" (func $github.com/wetware/ww/guest/tinygo.test (param i32 i32) (result i32))) + (import "wasi_snapshot_preview1" "fd_write" (func $runtime.fd_write (param i32 i32 i32 i32) (result i32))) + (import "wasi_snapshot_preview1" "clock_time_get" (func $runtime.clock_time_get (param i32 i64 i32) (result i32))) + (import "wasi_snapshot_preview1" "proc_exit" (func $runtime.proc_exit (param i32))) + (import "wasi_snapshot_preview1" "args_sizes_get" (func $runtime.args_sizes_get (param i32 i32) (result i32))) + (import "wasi_snapshot_preview1" "args_get" (func $runtime.args_get (param i32 i32) (result i32))) + (memory $0 2) + (data (i32.const 65536) "free: invalid pointer\00\00\00\00\00\01\00\15\00\00\00realloc: invalid pointer \00\01\00\18\00\00\00out of memorypanic: panic: runtime error: nil pointer dereferenceindex out of rangeslice out of range") + (data (i32.const 65704) "x\9c\19\f6\e8\00\01\00\00\00\00\00\ac\01\01\00\c1\82\01\00\00\00\00\00\04\00\00\00\0c\00\00\00\01\00\00\00\00\00\00\00\01\00\00\00\00\00\00\00\02") + (table $0 3 3 funcref) + (elem (i32.const 1) $runtime.memequal $runtime.hash32) + (global $__stack_pointer (mut i32) (i32.const 65536)) + (export "memory" (memory $0)) + (export "malloc" (func $malloc)) + (export "free" (func $free)) + (export "calloc" (func $calloc)) + (export "realloc" (func $realloc)) + (export "_start" (func $_start)) + (func $__wasm_call_ctors + (nop) + ) + (func $tinygo_getCurrentStackPointer (result i32) + (global.get $__stack_pointer) + ) + (func $strlen (param $0 i32) (result i32) + (local $1 i32) + (local $2 i32) + (local.set $1 + (local.get $0) + ) + (block $label$1 + (block $label$2 + (br_if $label$2 + (i32.eqz + (i32.and + (local.get $0) + (i32.const 3) + ) + ) + ) + (br_if $label$1 + (i32.eqz + (i32.load8_u + (local.get $0) + ) + ) + ) + (br_if $label$2 + (i32.eqz + (i32.and + (local.tee $1 + (i32.add + (local.get $0) + (i32.const 1) + ) + ) + (i32.const 3) + ) + ) + ) + (br_if $label$1 + (i32.eqz + (i32.load8_u + (local.get $1) + ) + ) + ) + (br_if $label$2 + (i32.eqz + (i32.and + (local.tee $1 + (i32.add + (local.get $0) + (i32.const 2) + ) + ) + (i32.const 3) + ) + ) + ) + (br_if $label$1 + (i32.eqz + (i32.load8_u + (local.get $1) + ) + ) + ) + (br_if $label$2 + (i32.eqz + (i32.and + (local.tee $1 + (i32.add + (local.get $0) + (i32.const 3) + ) + ) + (i32.const 3) + ) + ) + ) + (br_if $label$1 + (i32.eqz + (i32.load8_u + (local.get $1) + ) + ) + ) + (local.set $1 + (i32.add + (local.get $0) + (i32.const 4) + ) + ) + ) + (local.set $1 + (i32.sub + (local.get $1) + (i32.const 5) + ) + ) + (loop $label$3 + (local.set $2 + (i32.add + (local.get $1) + (i32.const 5) + ) + ) + (local.set $1 + (i32.add + (local.get $1) + (i32.const 4) + ) + ) + (br_if $label$3 + (i32.eqz + (i32.and + (i32.and + (i32.xor + (local.tee $2 + (i32.load + (local.get $2) + ) + ) + (i32.const -1) + ) + (i32.sub + (local.get $2) + (i32.const 16843009) + ) + ) + (i32.const -2139062144) + ) + ) + ) + ) + (loop $label$4 + (br_if $label$4 + (i32.load8_u + (local.tee $1 + (i32.add + (local.get $1) + (i32.const 1) + ) + ) + ) + ) + ) + ) + (i32.sub + (local.get $1) + (local.get $0) + ) + ) + (func $runtime.memequal (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) + (local $4 i32) + (local $5 i32) + (local $6 i32) + (i32.ge_u + (local.tee $4 + (block $label$1 (result i32) + (loop $label$2 + (drop + (br_if $label$1 + (local.get $2) + (i32.eq + (local.get $2) + (local.get $4) + ) + ) + ) + (local.set $5 + (i32.add + (local.get $1) + (local.get $4) + ) + ) + (local.set $6 + (i32.add + (local.get $0) + (local.get $4) + ) + ) + (local.set $4 + (i32.add + (local.get $4) + (i32.const 1) + ) + ) + (br_if $label$2 + (i32.eq + (i32.load8_u + (local.get $6) + ) + (i32.load8_u + (local.get $5) + ) + ) + ) + ) + (i32.sub + (local.get $4) + (i32.const 1) + ) + ) + ) + (local.get $2) + ) + ) + (func $runtime.hash32 (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) + (local.set $2 + (i32.xor + (i32.xor + (i32.mul + (local.get $1) + (i32.const -962287725) + ) + (local.get $2) + ) + (i32.const -1130422988) + ) + ) + (loop $label$1 + (if + (i32.eqz + (i32.lt_s + (local.get $1) + (i32.const 4) + ) + ) + (block + (local.set $2 + (i32.xor + (i32.shr_u + (local.tee $2 + (i32.mul + (i32.add + (i32.load align=1 + (local.get $0) + ) + (local.get $2) + ) + (i32.const -962287725) + ) + ) + (i32.const 16) + ) + (local.get $2) + ) + ) + (local.set $1 + (i32.sub + (local.get $1) + (i32.const 4) + ) + ) + (local.set $0 + (i32.add + (local.get $0) + (i32.const 4) + ) + ) + (br $label$1) + ) + ) + ) + (block $label$3 + (block $label$4 + (block $label$5 + (block $label$6 + (br_table $label$4 $label$5 $label$6 $label$3 + (i32.sub + (local.get $1) + (i32.const 1) + ) + ) + ) + (local.set $2 + (i32.add + (i32.shl + (i32.load8_u offset=2 + (local.get $0) + ) + (i32.const 16) + ) + (local.get $2) + ) + ) + ) + (local.set $2 + (i32.add + (i32.shl + (i32.load8_u offset=1 + (local.get $0) + ) + (i32.const 8) + ) + (local.get $2) + ) + ) + ) + (local.set $2 + (i32.xor + (i32.shr_u + (local.tee $1 + (i32.mul + (i32.add + (local.get $2) + (i32.load8_u + (local.get $0) + ) + ) + (i32.const -962287725) + ) + ) + (i32.const 24) + ) + (local.get $1) + ) + ) + ) + (local.get $2) + ) + (func $runtime.lookupPanic + (call $runtime.runtimePanic + (i32.const 65665) + (i32.const 18) + ) + (unreachable) + ) + (func $runtime.runtimePanic (param $0 i32) (param $1 i32) + (call $runtime.printstring + (i32.const 65620) + (i32.const 22) + ) + (call $runtime.printstring + (local.get $0) + (local.get $1) + ) + (call $runtime.printnl) + (unreachable) + ) + (func $runtime.slicePanic + (call $runtime.runtimePanic + (i32.const 65683) + (i32.const 18) + ) + (unreachable) + ) + (func $runtime.printstring (param $0 i32) (param $1 i32) + (local.set $1 + (select + (local.get $1) + (i32.const 0) + (i32.gt_s + (local.get $1) + (i32.const 0) + ) + ) + ) + (loop $label$1 + (if + (local.get $1) + (block + (call $runtime.putchar + (i32.load8_u + (local.get $0) + ) + ) + (local.set $1 + (i32.sub + (local.get $1) + (i32.const 1) + ) + ) + (local.set $0 + (i32.add + (local.get $0) + (i32.const 1) + ) + ) + (br $label$1) + ) + ) + ) + ) + (func $runtime.printnl + (call $runtime.putchar + (i32.const 10) + ) + ) + (func $runtime.putchar (param $0 i32) + (local $1 i32) + (local $2 i32) + (if + (i32.le_u + (local.tee $1 + (i32.load + (i32.const 65764) + ) + ) + (i32.const 119) + ) + (block + (i32.store + (i32.const 65764) + (local.tee $2 + (i32.add + (local.get $1) + (i32.const 1) + ) + ) + ) + (i32.store8 + (i32.add + (local.get $1) + (i32.const 65768) + ) + (local.get $0) + ) + (if + (i32.eqz + (i32.and + (i32.ne + (i32.and + (local.get $0) + (i32.const 255) + ) + (i32.const 10) + ) + (i32.ne + (local.get $1) + (i32.const 119) + ) + ) + ) + (block + (i32.store + (i32.const 65712) + (local.get $2) + ) + (drop + (call $runtime.fd_write + (i32.const 1) + (i32.const 65708) + (i32.const 1) + (i32.const 65936) + ) + ) + (i32.store + (i32.const 65764) + (i32.const 0) + ) + ) + ) + (return) + ) + ) + (call $runtime.lookupPanic) + (unreachable) + ) + (func $runtime.alloc (param $0 i32) (result i32) + (local $1 i32) + (local $2 i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + (local $6 i32) + (local $7 i32) + (if + (i32.eqz + (local.get $0) + ) + (return + (i32.const 65928) + ) + ) + (i64.store + (i32.const 65904) + (i64.add + (i64.load + (i32.const 65904) + ) + (i64.extend_i32_u + (local.get $0) + ) + ) + ) + (i64.store + (i32.const 65912) + (i64.add + (i64.load + (i32.const 65912) + ) + (i64.const 1) + ) + ) + (local.set $5 + (i32.shr_u + (i32.add + (local.get $0) + (i32.const 15) + ) + (i32.const 4) + ) + ) + (local.set $3 + (local.tee $4 + (i32.load + (i32.const 65892) + ) + ) + ) + (loop $label$2 + (block $label$3 + (block $label$4 + (block $label$5 + (block $label$6 + (if + (i32.ne + (local.get $3) + (local.get $4) + ) + (block + (local.set $1 + (local.get $2) + ) + (br $label$6) + ) + ) + (local.set $1 + (i32.const 1) + ) + (block $label$8 + (block $label$9 + (br_table $label$6 $label$9 $label$8 + (i32.and + (local.get $2) + (i32.const 255) + ) + ) + ) + (drop + (i32.load + (i32.const 65932) + ) + ) + (call $runtime.markRoots + (call $tinygo_getCurrentStackPointer) + (i32.const 65536) + ) + (call $runtime.markRoots + (i32.const 65536) + (i32.const 66336) + ) + (loop $label$10 + (if + (i32.eqz + (i32.load8_u + (i32.const 65929) + ) + ) + (block + (local.set $2 + (i32.const 0) + ) + (local.set $4 + (i32.const 0) + ) + (local.set $1 + (i32.const 0) + ) + (loop $label$12 + (block $label$13 + (block $label$14 + (if + (i32.gt_u + (i32.load + (i32.const 65896) + ) + (local.get $1) + ) + (block + (block $label$16 + (block $label$17 + (block $label$18 + (block $label$19 + (br_table $label$16 $label$19 $label$18 $label$17 $label$13 + (i32.and + (call $\28runtime.gcBlock\29.state + (local.get $1) + ) + (i32.const 255) + ) + ) + ) + (call $\28runtime.gcBlock\29.markFree + (local.get $1) + ) + (i64.store + (i32.const 65920) + (i64.add + (i64.load + (i32.const 65920) + ) + (i64.const 1) + ) + ) + (br $label$14) + ) + (local.set $7 + (i32.and + (local.get $4) + (i32.const 1) + ) + ) + (local.set $4 + (i32.const 0) + ) + (br_if $label$13 + (i32.eqz + (local.get $7) + ) + ) + (call $\28runtime.gcBlock\29.markFree + (local.get $1) + ) + (br $label$14) + ) + (local.set $4 + (i32.const 0) + ) + (i32.store8 + (local.tee $7 + (i32.add + (i32.load + (i32.const 65888) + ) + (i32.shr_u + (local.get $1) + (i32.const 2) + ) + ) + ) + (i32.and + (i32.load8_u + (local.get $7) + ) + (i32.xor + (i32.shl + (i32.const 2) + (i32.and + (i32.shl + (local.get $1) + (i32.const 1) + ) + (i32.const 6) + ) + ) + (i32.const -1) + ) + ) + ) + (br $label$13) + ) + (local.set $2 + (i32.add + (local.get $2) + (i32.const 16) + ) + ) + (br $label$13) + ) + ) + (local.set $1 + (i32.const 2) + ) + (br_if $label$6 + (i32.ge_u + (local.get $2) + (i32.div_u + (i32.sub + (i32.load + (i32.const 65888) + ) + (i32.const 66336) + ) + (i32.const 3) + ) + ) + ) + (drop + (call $runtime.growHeap) + ) + (br $label$6) + ) + (local.set $2 + (i32.add + (local.get $2) + (i32.const 16) + ) + ) + (local.set $4 + (i32.const 1) + ) + ) + (local.set $1 + (i32.add + (local.get $1) + (i32.const 1) + ) + ) + (br $label$12) + ) + ) + ) + (local.set $1 + (i32.const 0) + ) + (i32.store8 + (i32.const 65929) + (i32.const 0) + ) + (local.set $2 + (i32.load + (i32.const 65896) + ) + ) + (loop $label$20 + (br_if $label$10 + (i32.ge_u + (local.get $1) + (local.get $2) + ) + ) + (if + (i32.eq + (i32.and + (call $\28runtime.gcBlock\29.state + (local.get $1) + ) + (i32.const 255) + ) + (i32.const 3) + ) + (block + (call $runtime.startMark + (local.get $1) + ) + (local.set $2 + (i32.load + (i32.const 65896) + ) + ) + ) + ) + (local.set $1 + (i32.add + (local.get $1) + (i32.const 1) + ) + ) + (br $label$20) + ) + ) + ) + (local.set $1 + (local.get $2) + ) + (br_if $label$5 + (i32.eqz + (i32.and + (call $runtime.growHeap) + (i32.const 1) + ) + ) + ) + ) + (if + (i32.eq + (i32.load + (i32.const 65896) + ) + (local.get $3) + ) + (block + (local.set $3 + (i32.const 0) + ) + (br $label$4) + ) + ) + (if + (i32.and + (call $\28runtime.gcBlock\29.state + (local.get $3) + ) + (i32.const 255) + ) + (block + (local.set $3 + (i32.add + (local.get $3) + (i32.const 1) + ) + ) + (br $label$4) + ) + ) + (local.set $2 + (i32.add + (local.get $3) + (i32.const 1) + ) + ) + (if + (i32.ne + (local.get $5) + (local.tee $6 + (i32.add + (local.get $6) + (i32.const 1) + ) + ) + ) + (block + (local.set $3 + (local.get $2) + ) + (br $label$3) + ) + ) + (i32.store + (i32.const 65892) + (local.get $2) + ) + (call $\28runtime.gcBlock\29.setState + (local.tee $2 + (i32.sub + (local.get $2) + (local.get $5) + ) + ) + (i32.const 1) + ) + (local.set $1 + (i32.add + (i32.sub + (local.get $3) + (local.get $5) + ) + (i32.const 2) + ) + ) + (loop $label$25 + (if + (i32.eqz + (i32.eq + (local.get $1) + (i32.load + (i32.const 65892) + ) + ) + ) + (block + (call $\28runtime.gcBlock\29.setState + (local.get $1) + (i32.const 2) + ) + (local.set $1 + (i32.add + (local.get $1) + (i32.const 1) + ) + ) + (br $label$25) + ) + ) + ) + (memory.fill + (local.tee $1 + (i32.add + (i32.shl + (local.get $2) + (i32.const 4) + ) + (i32.const 66336) + ) + ) + (i32.const 0) + (local.get $0) + ) + (return + (local.get $1) + ) + ) + (call $runtime.runtimePanic + (i32.const 65600) + (i32.const 13) + ) + (unreachable) + ) + (local.set $6 + (i32.const 0) + ) + ) + (local.set $4 + (i32.load + (i32.const 65892) + ) + ) + (local.set $2 + (local.get $1) + ) + (br $label$2) + ) + ) + (func $runtime.markRoots (param $0 i32) (param $1 i32) + (local $2 i32) + (loop $label$1 + (if + (i32.eqz + (i32.ge_u + (local.get $0) + (local.get $1) + ) + ) + (block + (block $label$3 + (br_if $label$3 + (i32.lt_u + (local.tee $2 + (i32.load + (local.get $0) + ) + ) + (i32.const 66336) + ) + ) + (br_if $label$3 + (i32.ge_u + (local.get $2) + (i32.load + (i32.const 65888) + ) + ) + ) + (br_if $label$3 + (i32.eqz + (i32.and + (call $\28runtime.gcBlock\29.state + (local.tee $2 + (i32.shr_u + (i32.sub + (local.get $2) + (i32.const 66336) + ) + (i32.const 4) + ) + ) + ) + (i32.const 255) + ) + ) + ) + (br_if $label$3 + (i32.eq + (i32.and + (call $\28runtime.gcBlock\29.state + (local.tee $2 + (call $\28runtime.gcBlock\29.findHead + (local.get $2) + ) + ) + ) + (i32.const 255) + ) + (i32.const 3) + ) + ) + (call $runtime.startMark + (local.get $2) + ) + ) + (local.set $0 + (i32.add + (local.get $0) + (i32.const 4) + ) + ) + (br $label$1) + ) + ) + ) + ) + (func $\28runtime.gcBlock\29.state (param $0 i32) (result i32) + (i32.and + (i32.shr_u + (i32.load8_u + (i32.add + (i32.load + (i32.const 65888) + ) + (i32.shr_u + (local.get $0) + (i32.const 2) + ) + ) + ) + (i32.and + (i32.shl + (local.get $0) + (i32.const 1) + ) + (i32.const 6) + ) + ) + (i32.const 3) + ) + ) + (func $\28runtime.gcBlock\29.markFree (param $0 i32) + (local $1 i32) + (i32.store8 + (local.tee $1 + (i32.add + (i32.load + (i32.const 65888) + ) + (i32.shr_u + (local.get $0) + (i32.const 2) + ) + ) + ) + (i32.and + (i32.load8_u + (local.get $1) + ) + (i32.xor + (i32.shl + (i32.const 3) + (i32.and + (i32.shl + (local.get $0) + (i32.const 1) + ) + (i32.const 6) + ) + ) + (i32.const -1) + ) + ) + ) + ) + (func $runtime.growHeap (result i32) + (local $0 i32) + (local $1 i32) + (local $2 i32) + (if + (local.tee $1 + (i32.ne + (memory.grow + (memory.size) + ) + (i32.const -1) + ) + ) + (block + (local.set $0 + (memory.size) + ) + (local.set $2 + (i32.load + (i32.const 65760) + ) + ) + (i32.store + (i32.const 65760) + (i32.shl + (local.get $0) + (i32.const 16) + ) + ) + (local.set $0 + (i32.load + (i32.const 65888) + ) + ) + (call $runtime.calculateHeapAddresses) + (memory.copy + (i32.load + (i32.const 65888) + ) + (local.get $0) + (i32.sub + (local.get $2) + (local.get $0) + ) + ) + ) + ) + (local.get $1) + ) + (func $runtime.startMark (param $0 i32) + (local $1 i32) + (local $2 i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + (local $6 i32) + (local $7 i32) + (local $8 i32) + (global.set $__stack_pointer + (local.tee $3 + (i32.add + (global.get $__stack_pointer) + (i32.const -64) + ) + ) + ) + (memory.fill + (i32.add + (local.get $3) + (i32.const 4) + ) + (i32.const 0) + (i32.const 60) + ) + (i32.store + (local.get $3) + (local.get $0) + ) + (call $\28runtime.gcBlock\29.setState + (local.get $0) + (i32.const 3) + ) + (local.set $2 + (i32.const 1) + ) + (block $label$1 + (loop $label$2 + (if + (i32.gt_s + (local.get $2) + (i32.const 0) + ) + (block + (br_if $label$1 + (i32.gt_u + (local.tee $2 + (i32.sub + (local.get $2) + (i32.const 1) + ) + ) + (i32.const 15) + ) + ) + (local.set $0 + (i32.shl + (local.tee $1 + (i32.load + (i32.add + (local.get $3) + (i32.shl + (local.get $2) + (i32.const 2) + ) + ) + ) + ) + (i32.const 4) + ) + ) + (block $label$4 + (block $label$5 + (br_table $label$5 $label$4 $label$5 $label$4 + (i32.sub + (i32.and + (call $\28runtime.gcBlock\29.state + (local.get $1) + ) + (i32.const 255) + ) + (i32.const 1) + ) + ) + ) + (local.set $1 + (i32.add + (local.get $1) + (i32.const 1) + ) + ) + ) + (local.set $5 + (i32.add + (local.get $0) + (i32.const 66336) + ) + ) + (local.set $6 + (i32.sub + (local.tee $4 + (i32.shl + (local.get $1) + (i32.const 4) + ) + ) + (local.get $0) + ) + ) + (local.set $4 + (i32.add + (local.get $4) + (i32.const 66336) + ) + ) + (local.set $7 + (i32.load + (i32.const 65888) + ) + ) + (loop $label$6 + (block $label$7 + (local.set $0 + (local.get $6) + ) + (br_if $label$7 + (i32.ge_u + (local.get $4) + (local.get $7) + ) + ) + (local.set $6 + (i32.add + (local.get $0) + (i32.const 16) + ) + ) + (local.set $4 + (i32.add + (local.get $4) + (i32.const 16) + ) + ) + (local.set $8 + (call $\28runtime.gcBlock\29.state + (local.get $1) + ) + ) + (local.set $1 + (i32.add + (local.get $1) + (i32.const 1) + ) + ) + (br_if $label$6 + (i32.eq + (i32.and + (local.get $8) + (i32.const 255) + ) + (i32.const 2) + ) + ) + ) + ) + (loop $label$8 + (br_if $label$2 + (i32.eqz + (local.get $0) + ) + ) + (block $label$9 + (br_if $label$9 + (i32.lt_u + (local.tee $1 + (i32.load + (local.get $5) + ) + ) + (i32.const 66336) + ) + ) + (br_if $label$9 + (i32.ge_u + (local.get $1) + (i32.load + (i32.const 65888) + ) + ) + ) + (br_if $label$9 + (i32.eqz + (i32.and + (call $\28runtime.gcBlock\29.state + (local.tee $1 + (i32.shr_u + (i32.sub + (local.get $1) + (i32.const 66336) + ) + (i32.const 4) + ) + ) + ) + (i32.const 255) + ) + ) + ) + (br_if $label$9 + (i32.eq + (i32.and + (call $\28runtime.gcBlock\29.state + (local.tee $1 + (call $\28runtime.gcBlock\29.findHead + (local.get $1) + ) + ) + ) + (i32.const 255) + ) + (i32.const 3) + ) + ) + (call $\28runtime.gcBlock\29.setState + (local.get $1) + (i32.const 3) + ) + (if + (i32.eq + (local.get $2) + (i32.const 16) + ) + (block + (i32.store8 + (i32.const 65929) + (i32.const 1) + ) + (local.set $2 + (i32.const 16) + ) + (br $label$9) + ) + ) + (br_if $label$1 + (i32.gt_u + (local.get $2) + (i32.const 15) + ) + ) + (i32.store + (i32.add + (local.get $3) + (i32.shl + (local.get $2) + (i32.const 2) + ) + ) + (local.get $1) + ) + (local.set $2 + (i32.add + (local.get $2) + (i32.const 1) + ) + ) + ) + (local.set $0 + (i32.sub + (local.get $0) + (i32.const 4) + ) + ) + (local.set $5 + (i32.add + (local.get $5) + (i32.const 4) + ) + ) + (br $label$8) + ) + ) + ) + ) + (global.set $__stack_pointer + (i32.sub + (local.get $3) + (i32.const -64) + ) + ) + (return) + ) + (call $runtime.lookupPanic) + (unreachable) + ) + (func $\28runtime.gcBlock\29.setState (param $0 i32) (param $1 i32) + (local $2 i32) + (i32.store8 + (local.tee $2 + (i32.add + (i32.load + (i32.const 65888) + ) + (i32.shr_u + (local.get $0) + (i32.const 2) + ) + ) + ) + (i32.or + (i32.load8_u + (local.get $2) + ) + (i32.shl + (local.get $1) + (i32.and + (i32.shl + (local.get $0) + (i32.const 1) + ) + (i32.const 6) + ) + ) + ) + ) + ) + (func $runtime.nilPanic + (call $runtime.runtimePanic + (i32.const 65642) + (i32.const 23) + ) + (unreachable) + ) + (func $runtime.calculateHeapAddresses + (local $0 i32) + (i32.store + (i32.const 65888) + (local.tee $0 + (i32.sub + (local.tee $0 + (i32.load + (i32.const 65760) + ) + ) + (i32.div_u + (i32.sub + (local.get $0) + (i32.const 66272) + ) + (i32.const 65) + ) + ) + ) + ) + (i32.store + (i32.const 65896) + (i32.shr_u + (i32.sub + (local.get $0) + (i32.const 66336) + ) + (i32.const 4) + ) + ) + ) + (func $\28runtime.gcBlock\29.findHead (param $0 i32) (result i32) + (local $1 i32) + (local $2 i32) + (loop $label$1 + (local.set $1 + (call $\28runtime.gcBlock\29.state + (local.get $0) + ) + ) + (local.set $0 + (local.tee $2 + (i32.sub + (local.get $0) + (i32.const 1) + ) + ) + ) + (br_if $label$1 + (i32.eq + (i32.and + (local.get $1) + (i32.const 255) + ) + (i32.const 2) + ) + ) + ) + (i32.add + (local.get $2) + (i32.const 1) + ) + ) + (func $malloc (param $0 i32) (result i32) + (local $1 i32) + (local $2 i32) + (local $3 i32) + (global.set $__stack_pointer + (local.tee $1 + (i32.sub + (global.get $__stack_pointer) + (i32.const 32) + ) + ) + ) + (i32.store offset=20 + (local.get $1) + (i32.const 2) + ) + (local.set $3 + (i32.load + (i32.const 65932) + ) + ) + (i32.store + (i32.const 65932) + (i32.add + (local.get $1) + (i32.const 16) + ) + ) + (i32.store offset=16 + (local.get $1) + (local.get $3) + ) + (block $label$1 + (if + (local.get $0) + (block + (br_if $label$1 + (i32.lt_s + (local.get $0) + (i32.const 0) + ) + ) + (i32.store offset=24 + (local.get $1) + (local.tee $2 + (call $runtime.alloc + (local.get $0) + ) + ) + ) + (i32.store offset=28 + (local.get $1) + (local.get $2) + ) + (i32.store offset=8 + (local.get $1) + (local.get $0) + ) + (i32.store offset=4 + (local.get $1) + (local.get $0) + ) + (i32.store + (local.get $1) + (local.get $2) + ) + (i32.store offset=12 + (local.get $1) + (local.get $2) + ) + (call $runtime.hashmapBinarySet + (i32.add + (local.get $1) + (i32.const 12) + ) + (local.get $1) + ) + ) + ) + (i32.store + (i32.const 65932) + (local.get $3) + ) + (global.set $__stack_pointer + (i32.add + (local.get $1) + (i32.const 32) + ) + ) + (return + (local.get $2) + ) + ) + (call $runtime.slicePanic) + (unreachable) + ) + (func $runtime.hashmapBinarySet (param $0 i32) (param $1 i32) + (call $runtime.hashmapSet + (i32.const 65716) + (local.get $0) + (local.get $1) + (call $runtime.hash32 + (local.get $0) + (i32.load + (i32.const 65728) + ) + (i32.load + (i32.const 65720) + ) + (local.get $0) + ) + ) + ) + (func $free (param $0 i32) + (local $1 i32) + (global.set $__stack_pointer + (local.tee $1 + (i32.sub + (global.get $__stack_pointer) + (i32.const 16) + ) + ) + ) + (block $label$1 + (if + (local.get $0) + (block + (i32.store offset=12 + (local.get $1) + (local.get $0) + ) + (br_if $label$1 + (i32.eqz + (i32.and + (call $runtime.hashmapBinaryGet + (i32.add + (local.get $1) + (i32.const 12) + ) + (local.get $1) + ) + (i32.const 1) + ) + ) + ) + (i32.store + (local.get $1) + (local.get $0) + ) + (call $runtime.hashmapBinaryDelete + (local.get $1) + ) + ) + ) + (global.set $__stack_pointer + (i32.add + (local.get $1) + (i32.const 16) + ) + ) + (return) + ) + (call $runtime._panic + (i32.const 65560) + ) + (unreachable) + ) + (func $runtime.hashmapBinaryGet (param $0 i32) (param $1 i32) (result i32) + (call $runtime.hashmapGet + (i32.const 65716) + (local.get $0) + (local.get $1) + (call $runtime.hash32 + (local.get $0) + (i32.load + (i32.const 65728) + ) + (i32.load + (i32.const 65720) + ) + (local.get $0) + ) + ) + ) + (func $runtime.hashmapBinaryDelete (param $0 i32) + (local $1 i32) + (local $2 i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + (local $6 i32) + (local $7 i32) + (local $8 i32) + (local $9 i32) + (global.set $__stack_pointer + (local.tee $1 + (i32.sub + (global.get $__stack_pointer) + (i32.const 32) + ) + ) + ) + (i64.store + (i32.add + (local.get $1) + (i32.const 24) + ) + (i64.const 0) + ) + (i64.store offset=16 + (local.get $1) + (i64.const 0) + ) + (i32.store offset=4 + (local.get $1) + (i32.const 6) + ) + (local.set $6 + (i32.load + (i32.const 65932) + ) + ) + (i32.store + (i32.const 65932) + (local.get $1) + ) + (i32.store + (local.get $1) + (local.get $6) + ) + (local.set $3 + (call $runtime.hash32 + (local.get $0) + (local.tee $2 + (i32.load + (i32.const 65728) + ) + ) + (i32.load + (i32.const 65720) + ) + (i32.const 0) + ) + ) + (i32.store offset=8 + (local.get $1) + (local.tee $4 + (i32.load + (i32.const 65716) + ) + ) + ) + (local.set $7 + (select + (local.tee $5 + (i32.shr_u + (local.get $3) + (i32.const 24) + ) + ) + (i32.const 1) + (local.get $5) + ) + ) + (local.set $2 + (i32.add + (local.get $4) + (i32.mul + (i32.add + (i32.shl + (i32.add + (local.get $2) + (i32.load + (i32.const 65732) + ) + ) + (i32.const 3) + ) + (i32.const 12) + ) + (i32.and + (local.get $3) + (select + (i32.const -1) + (i32.xor + (i32.shl + (i32.const -1) + (local.tee $2 + (i32.load8_u + (i32.const 65736) + ) + ) + ) + (i32.const -1) + ) + (i32.gt_u + (local.get $2) + (i32.const 31) + ) + ) + ) + ) + ) + ) + (block $label$1 + (loop $label$2 + (i32.store offset=12 + (local.get $1) + (local.get $2) + ) + (i32.store offset=16 + (local.get $1) + (local.get $2) + ) + (br_if $label$1 + (i32.eqz + (local.get $2) + ) + ) + (local.set $3 + (i32.const 0) + ) + (block $label$3 + (loop $label$4 + (if + (i32.ne + (local.get $3) + (i32.const 8) + ) + (block + (block $label$6 + (br_if $label$6 + (i32.ne + (i32.load8_u + (local.tee $8 + (i32.add + (local.get $2) + (local.get $3) + ) + ) + ) + (local.get $7) + ) + ) + (local.set $5 + (i32.load + (i32.const 65728) + ) + ) + (i32.store offset=20 + (local.get $1) + (local.tee $9 + (i32.load + (i32.const 65740) + ) + ) + ) + (i32.store offset=24 + (local.get $1) + (local.tee $4 + (i32.load + (i32.const 65744) + ) + ) + ) + (br_if $label$3 + (i32.eqz + (local.get $4) + ) + ) + (br_if $label$6 + (i32.eqz + (i32.and + (call_indirect (type $i32_i32_i32_i32_=>_i32) + (local.get $0) + (i32.add + (i32.add + (i32.mul + (local.get $3) + (local.get $5) + ) + (local.get $2) + ) + (i32.const 12) + ) + (local.get $5) + (local.get $9) + (local.get $4) + ) + (i32.const 1) + ) + ) + ) + (i32.store8 + (local.get $8) + (i32.const 0) + ) + (i32.store + (i32.const 65724) + (i32.sub + (i32.load + (i32.const 65724) + ) + (i32.const 1) + ) + ) + (br $label$1) + ) + (local.set $3 + (i32.add + (local.get $3) + (i32.const 1) + ) + ) + (br $label$4) + ) + ) + ) + (i32.store offset=28 + (local.get $1) + (local.tee $2 + (i32.load offset=8 + (local.get $2) + ) + ) + ) + (br $label$2) + ) + ) + (call $runtime.nilPanic) + (unreachable) + ) + (i32.store + (i32.const 65932) + (local.get $6) + ) + (global.set $__stack_pointer + (i32.add + (local.get $1) + (i32.const 32) + ) + ) + ) + (func $runtime._panic (param $0 i32) + (call $runtime.printstring + (i32.const 65613) + (i32.const 7) + ) + (call $runtime.printitf + (local.get $0) + ) + (call $runtime.printnl) + (unreachable) + ) + (func $calloc (param $0 i32) (param $1 i32) (result i32) + (local $2 i32) + (local $3 i32) + (global.set $__stack_pointer + (local.tee $2 + (i32.sub + (global.get $__stack_pointer) + (i32.const 16) + ) + ) + ) + (local.set $3 + (i32.load + (i32.const 65932) + ) + ) + (i32.store + (i32.const 65932) + (local.get $2) + ) + (local.set $0 + (call $malloc + (i32.mul + (local.get $0) + (local.get $1) + ) + ) + ) + (i32.store + (i32.const 65932) + (local.get $3) + ) + (global.set $__stack_pointer + (i32.add + (local.get $2) + (i32.const 16) + ) + ) + (local.get $0) + ) + (func $realloc (param $0 i32) (param $1 i32) (result i32) + (local $2 i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + (global.set $__stack_pointer + (local.tee $2 + (i32.sub + (global.get $__stack_pointer) + (i32.const 32) + ) + ) + ) + (i32.store offset=20 + (local.get $2) + (i32.const 2) + ) + (local.set $4 + (i32.load + (i32.const 65932) + ) + ) + (i32.store + (i32.const 65932) + (i32.add + (local.get $2) + (i32.const 16) + ) + ) + (i32.store offset=16 + (local.get $2) + (local.get $4) + ) + (block $label$1 + (block $label$2 + (block $label$3 + (if + (i32.eqz + (local.get $1) + ) + (block + (call $free + (local.get $0) + ) + (br $label$3) + ) + ) + (br_if $label$2 + (i32.lt_s + (local.get $1) + (i32.const 0) + ) + ) + (i32.store offset=24 + (local.get $2) + (local.tee $3 + (call $runtime.alloc + (local.get $1) + ) + ) + ) + (i32.store offset=28 + (local.get $2) + (local.get $3) + ) + (if + (local.get $0) + (block + (i32.store offset=12 + (local.get $2) + (local.get $0) + ) + (br_if $label$1 + (i32.eqz + (i32.and + (call $runtime.hashmapBinaryGet + (i32.add + (local.get $2) + (i32.const 12) + ) + (local.get $2) + ) + (i32.const 1) + ) + ) + ) + (memory.copy + (local.get $3) + (i32.load + (local.get $2) + ) + (select + (local.tee $5 + (i32.load offset=4 + (local.get $2) + ) + ) + (local.get $1) + (i32.gt_u + (local.get $1) + (local.get $5) + ) + ) + ) + (i32.store + (local.get $2) + (local.get $0) + ) + (call $runtime.hashmapBinaryDelete + (local.get $2) + ) + ) + ) + (i32.store offset=8 + (local.get $2) + (local.get $1) + ) + (i32.store offset=4 + (local.get $2) + (local.get $1) + ) + (i32.store + (local.get $2) + (local.get $3) + ) + (i32.store offset=12 + (local.get $2) + (local.get $3) + ) + (call $runtime.hashmapBinarySet + (i32.add + (local.get $2) + (i32.const 12) + ) + (local.get $2) + ) + ) + (i32.store + (i32.const 65932) + (local.get $4) + ) + (global.set $__stack_pointer + (i32.add + (local.get $2) + (i32.const 32) + ) + ) + (return + (local.get $3) + ) + ) + (call $runtime.slicePanic) + (unreachable) + ) + (call $runtime._panic + (i32.const 65592) + ) + (unreachable) + ) + (func $_start + (local $0 i32) + (local $1 i32) + (local $2 i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + (local $6 i32) + (local $7 i32) + (local $8 i32) + (global.set $__stack_pointer + (local.tee $0 + (i32.sub + (global.get $__stack_pointer) + (i32.const 96) + ) + ) + ) + (i32.store offset=36 + (local.get $0) + (i32.const 13) + ) + (memory.fill + (i32.add + (local.get $0) + (i32.const 40) + ) + (i32.const 0) + (i32.const 52) + ) + (i32.store offset=32 + (local.get $0) + (local.tee $7 + (i32.load + (i32.const 65932) + ) + ) + ) + (i32.store + (i32.const 65932) + (i32.add + (local.get $0) + (i32.const 32) + ) + ) + (i32.store + (i32.const 65760) + (local.tee $5 + (i32.shl + (memory.size) + (i32.const 16) + ) + ) + ) + (call $runtime.calculateHeapAddresses) + (i32.store offset=44 + (local.get $0) + (local.tee $1 + (i32.load + (i32.const 65888) + ) + ) + ) + (i32.store offset=40 + (local.get $0) + (local.get $1) + ) + (memory.fill + (local.get $1) + (i32.const 0) + (i32.sub + (local.get $5) + (local.get $1) + ) + ) + (i32.store + (i32.const 65760) + (i32.shl + (memory.size) + (i32.const 16) + ) + ) + (call $__wasm_call_ctors) + (i32.store offset=48 + (local.get $0) + (local.tee $4 + (i32.load + (i32.const 65944) + ) + ) + ) + (block $label$1 + (block $label$2 + (block $label$3 + (local.set $3 + (block $label$4 (result i32) + (if + (local.get $4) + (block + (local.set $2 + (i32.load + (i32.const 65960) + ) + ) + (br $label$4 + (i32.load + (i32.const 65952) + ) + ) + ) + ) + (i32.store offset=16 + (local.get $0) + (i32.const 0) + ) + (i32.store offset=24 + (local.get $0) + (i32.const 0) + ) + (drop + (call $runtime.args_sizes_get + (i32.add + (local.get $0) + (i32.const 24) + ) + (i32.add + (local.get $0) + (i32.const 16) + ) + ) + ) + (if + (i32.eqz + (local.tee $2 + (i32.load offset=24 + (local.get $0) + ) + ) + ) + (block + (local.set $4 + (i32.const 0) + ) + (local.set $2 + (i32.const 0) + ) + (br $label$3) + ) + ) + (br_if $label$1 + (i32.gt_u + (local.get $2) + (i32.const 1073741823) + ) + ) + (i32.store offset=52 + (local.get $0) + (local.tee $5 + (call $runtime.alloc + (i32.shl + (local.get $2) + (i32.const 2) + ) + ) + ) + ) + (br_if $label$1 + (i32.lt_s + (local.tee $1 + (i32.load offset=16 + (local.get $0) + ) + ) + (i32.const 0) + ) + ) + (i32.store offset=56 + (local.get $0) + (local.tee $3 + (call $runtime.alloc + (local.get $1) + ) + ) + ) + (i32.store offset=60 + (local.get $0) + (local.get $3) + ) + (br_if $label$2 + (i32.eqz + (local.get $1) + ) + ) + (drop + (call $runtime.args_get + (local.get $5) + (local.get $3) + ) + ) + (br_if $label$1 + (i32.gt_u + (local.get $2) + (i32.const 536870911) + ) + ) + (i32.store + (i32.const 65944) + (local.tee $4 + (call $runtime.alloc + (i32.shl + (local.get $2) + (i32.const 3) + ) + ) + ) + ) + (i32.store + (i32.const 65952) + (local.get $2) + ) + (i32.store + (i32.const 65960) + (local.get $2) + ) + (i32.store offset=64 + (local.get $0) + (local.get $4) + ) + (local.set $3 + (local.get $4) + ) + (local.set $6 + (local.get $2) + ) + (loop $label$7 + (if + (local.get $6) + (block + (i32.store offset=80 + (local.get $0) + (local.tee $1 + (i32.load + (local.get $5) + ) + ) + ) + (i32.store offset=72 + (local.get $0) + (local.get $1) + ) + (i32.store offset=68 + (local.get $0) + (local.get $1) + ) + (i32.store + (i32.add + (local.get $3) + (i32.const 4) + ) + (local.tee $8 + (call $strlen + (local.get $1) + ) + ) + ) + (i32.store + (local.get $3) + (local.get $1) + ) + (i32.store offset=76 + (local.get $0) + (local.get $4) + ) + (local.set $5 + (i32.add + (local.get $5) + (i32.const 4) + ) + ) + (local.set $3 + (i32.add + (local.get $3) + (i32.const 8) + ) + ) + (local.set $6 + (i32.sub + (local.get $6) + (i32.const 1) + ) + ) + (br $label$7) + ) + ) + ) + (i32.store offset=8 + (local.get $0) + (local.get $1) + ) + (i32.store offset=12 + (local.get $0) + (local.get $8) + ) + (local.get $2) + ) + ) + (i32.store offset=84 + (local.get $0) + (local.get $4) + ) + ) + (i32.store + (i32.const 66312) + (local.get $4) + ) + (i32.store + (i32.const 66316) + (local.get $3) + ) + (i32.store + (i32.const 66320) + (local.get $2) + ) + (i32.store offset=88 + (local.get $0) + (local.get $4) + ) + (i64.store offset=8 + (local.get $0) + (i64.const 0) + ) + (drop + (call $runtime.clock_time_get + (i32.const 0) + (i64.const 1000) + (i32.add + (local.get $0) + (i32.const 8) + ) + ) + ) + (i32.store + (select + (i32.add + (local.get $0) + (i32.const 24) + ) + (i32.add + (local.get $0) + (i32.const 16) + ) + (i64.lt_u + (i64.add + (i64.div_s + (i64.load offset=8 + (local.get $0) + ) + (i64.const 1000000000) + ) + (i64.const 2682288000) + ) + (i64.const 8589934592) + ) + ) + (i32.const 66248) + ) + (call $runtime.proc_exit + (call $github.com/wetware/ww/guest/tinygo.test + (i32.const 40) + (i32.const 2) + ) + ) + (i32.store + (i32.const 65932) + (local.get $7) + ) + (global.set $__stack_pointer + (i32.add + (local.get $0) + (i32.const 96) + ) + ) + (return) + ) + (call $runtime.lookupPanic) + (unreachable) + ) + (call $runtime.slicePanic) + (unreachable) + ) + (func $runtime.hashmapGet (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) + (local $4 i32) + (local $5 i32) + (local $6 i32) + (local $7 i32) + (local $8 i32) + (local $9 i32) + (local $10 i32) + (local $11 i32) + (global.set $__stack_pointer + (local.tee $4 + (i32.sub + (global.get $__stack_pointer) + (i32.const 48) + ) + ) + ) + (i32.store + (i32.add + (local.get $4) + (i32.const 40) + ) + (i32.const 0) + ) + (i64.store offset=32 + (local.get $4) + (i64.const 0) + ) + (i32.store offset=12 + (local.get $4) + (i32.const 7) + ) + (local.set $7 + (i32.load + (i32.const 65932) + ) + ) + (i32.store + (i32.const 65932) + (i32.add + (local.get $4) + (i32.const 8) + ) + ) + (i32.store offset=8 + (local.get $4) + (local.get $7) + ) + (i32.store offset=16 + (local.get $4) + (local.tee $5 + (i32.load + (local.get $0) + ) + ) + ) + (local.set $5 + (i32.add + (local.get $5) + (i32.mul + (i32.add + (i32.shl + (i32.add + (i32.load offset=16 + (local.get $0) + ) + (i32.load offset=12 + (local.get $0) + ) + ) + (i32.const 3) + ) + (i32.const 12) + ) + (i32.and + (select + (i32.const -1) + (i32.xor + (i32.shl + (i32.const -1) + (local.tee $6 + (i32.load8_u offset=20 + (local.get $0) + ) + ) + ) + (i32.const -1) + ) + (i32.gt_u + (local.get $6) + (i32.const 31) + ) + ) + (local.get $3) + ) + ) + ) + ) + (local.set $9 + (select + (local.tee $3 + (i32.shr_u + (local.get $3) + (i32.const 24) + ) + ) + (i32.const 1) + (local.get $3) + ) + ) + (block $label$1 + (block $label$2 + (loop $label$3 + (block $label$4 + (i32.store offset=24 + (local.get $4) + (local.get $5) + ) + (i32.store offset=28 + (local.get $4) + (local.get $5) + ) + (i32.store offset=20 + (local.get $4) + (local.get $5) + ) + (br_if $label$4 + (i32.eqz + (local.get $5) + ) + ) + (local.set $3 + (i32.const 0) + ) + (loop $label$5 + (if + (i32.ne + (local.get $3) + (i32.const 8) + ) + (block + (block $label$7 + (br_if $label$7 + (i32.ne + (i32.load8_u + (i32.add + (local.get $3) + (local.get $5) + ) + ) + (local.get $9) + ) + ) + (local.set $6 + (i32.load offset=12 + (local.get $0) + ) + ) + (local.set $10 + (i32.load offset=16 + (local.get $0) + ) + ) + (i32.store offset=32 + (local.get $4) + (local.tee $11 + (i32.load offset=24 + (local.get $0) + ) + ) + ) + (i32.store offset=36 + (local.get $4) + (local.tee $8 + (i32.load offset=28 + (local.get $0) + ) + ) + ) + (br_if $label$2 + (i32.eqz + (local.get $8) + ) + ) + (br_if $label$7 + (i32.eqz + (i32.and + (call_indirect (type $i32_i32_i32_i32_=>_i32) + (local.get $1) + (i32.add + (i32.add + (i32.mul + (local.get $3) + (local.get $6) + ) + (local.get $5) + ) + (i32.const 12) + ) + (local.get $6) + (local.get $11) + (local.get $8) + ) + (i32.const 1) + ) + ) + ) + (memory.copy + (local.get $2) + (i32.add + (i32.add + (i32.add + (i32.mul + (local.get $3) + (local.get $10) + ) + (i32.shl + (local.get $6) + (i32.const 3) + ) + ) + (local.get $5) + ) + (i32.const 12) + ) + (i32.load offset=16 + (local.get $0) + ) + ) + (br $label$1) + ) + (local.set $3 + (i32.add + (local.get $3) + (i32.const 1) + ) + ) + (br $label$5) + ) + ) + ) + (i32.store offset=40 + (local.get $4) + (local.tee $5 + (i32.load offset=8 + (local.get $5) + ) + ) + ) + (br $label$3) + ) + ) + (memory.fill + (local.get $2) + (i32.const 0) + (i32.load offset=16 + (local.get $0) + ) + ) + (br $label$1) + ) + (call $runtime.nilPanic) + (unreachable) + ) + (i32.store + (i32.const 65932) + (local.get $7) + ) + (global.set $__stack_pointer + (i32.add + (local.get $4) + (i32.const 48) + ) + ) + (i32.ne + (local.get $5) + (i32.const 0) + ) + ) + (func $runtime.printitf (param $0 i32) + (call $runtime.printstring + (i32.load + (local.get $0) + ) + (i32.load offset=4 + (local.get $0) + ) + ) + ) + (func $runtime.hashmapSet (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) + (local $4 i32) + (local $5 i32) + (local $6 i32) + (local $7 i32) + (local $8 i32) + (local $9 i32) + (local $10 i32) + (local $11 i32) + (local $12 i32) + (local $13 i32) + (local $14 i32) + (local $15 i32) + (global.set $__stack_pointer + (local.tee $4 + (i32.sub + (global.get $__stack_pointer) + (i32.const 256) + ) + ) + ) + (i32.store offset=52 + (local.get $4) + (i32.const 50) + ) + (memory.fill + (i32.add + (local.get $4) + (i32.const 56) + ) + (i32.const 0) + (i32.const 200) + ) + (i32.store offset=48 + (local.get $4) + (local.tee $14 + (i32.load + (i32.const 65932) + ) + ) + ) + (i32.store + (i32.const 65932) + (i32.add + (local.get $4) + (i32.const 48) + ) + ) + (block $label$1 + (block $label$2 + (br_if $label$2 + (i32.eqz + (local.get $0) + ) + ) + (block $label$3 + (br_if $label$3 + (i32.gt_u + (local.tee $5 + (i32.load8_u offset=20 + (local.get $0) + ) + ) + (i32.const 29) + ) + ) + (br_if $label$3 + (i32.le_u + (i32.load offset=8 + (local.get $0) + ) + (i32.shl + (i32.const 6) + (local.get $5) + ) + ) + ) + (i64.store offset=24 + (local.get $4) + (i64.const 0) + ) + (i32.store offset=72 + (local.get $4) + (local.tee $3 + (i32.load offset=36 + (local.get $0) + ) + ) + ) + (i32.store offset=68 + (local.get $4) + (local.tee $7 + (i32.load offset=32 + (local.get $0) + ) + ) + ) + (i32.store offset=64 + (local.get $4) + (local.tee $6 + (i32.load offset=28 + (local.get $0) + ) + ) + ) + (i32.store offset=60 + (local.get $4) + (local.tee $8 + (i32.load offset=24 + (local.get $0) + ) + ) + ) + (i32.store offset=56 + (local.get $4) + (i32.load + (local.get $0) + ) + ) + (i32.store offset=44 + (local.get $4) + (local.get $3) + ) + (i32.store offset=40 + (local.get $4) + (local.get $7) + ) + (i32.store offset=36 + (local.get $4) + (local.get $6) + ) + (i32.store offset=32 + (local.get $4) + (local.get $8) + ) + (i32.store offset=24 + (local.get $4) + (i32.load offset=16 + (local.get $0) + ) + ) + (i32.store offset=20 + (local.get $4) + (i32.load offset=12 + (local.get $0) + ) + ) + (i32.store + (i32.const 65704) + (local.tee $3 + (i32.xor + (i32.shl + (local.tee $3 + (i32.xor + (i32.shr_u + (local.tee $3 + (i32.xor + (i32.shl + (local.tee $3 + (i32.load + (i32.const 65704) + ) + ) + (i32.const 7) + ) + (local.get $3) + ) + ) + (i32.const 1) + ) + (local.get $3) + ) + ) + (i32.const 9) + ) + (local.get $3) + ) + ) + ) + (i32.store offset=16 + (local.get $4) + (i32.const 0) + ) + (i32.store offset=12 + (local.get $4) + (local.get $3) + ) + (i32.store8 offset=28 + (local.get $4) + (local.tee $3 + (i32.add + (local.get $5) + (i32.const 1) + ) + ) + ) + (i32.store offset=8 + (local.get $4) + (local.tee $3 + (call $runtime.alloc + (i32.shl + (i32.add + (i32.shl + (i32.add + (i32.load offset=16 + (local.get $0) + ) + (i32.load offset=12 + (local.get $0) + ) + ) + (i32.const 3) + ) + (i32.const 12) + ) + (local.get $3) + ) + ) + ) + ) + (i32.store offset=76 + (local.get $4) + (local.get $3) + ) + (i32.store offset=80 + (local.get $4) + (local.tee $7 + (call $runtime.alloc + (i32.load offset=12 + (local.get $0) + ) + ) + ) + ) + (i32.store offset=84 + (local.get $4) + (local.tee $13 + (call $runtime.alloc + (i32.load offset=16 + (local.get $0) + ) + ) + ) + ) + (local.set $3 + (i32.const 0) + ) + (local.set $5 + (i32.const 0) + ) + (loop $label$4 + (i32.store offset=88 + (local.get $4) + (local.get $10) + ) + (if + (i32.eqz + (local.get $10) + ) + (block + (i32.store offset=92 + (local.get $4) + (local.tee $10 + (i32.load + (local.get $0) + ) + ) + ) + (local.set $12 + (select + (i32.shl + (i32.const 1) + (local.tee $6 + (i32.load8_u offset=20 + (local.get $0) + ) + ) + ) + (i32.const 0) + (i32.le_u + (local.get $6) + (i32.const 31) + ) + ) + ) + ) + ) + (i32.store offset=108 + (local.get $4) + (local.get $10) + ) + (i32.store offset=124 + (local.get $4) + (local.get $10) + ) + (block $label$6 + (loop $label$7 + (i32.store offset=96 + (local.get $4) + (local.get $3) + ) + (if + (i32.ge_u + (i32.and + (local.get $5) + (i32.const 255) + ) + (i32.const 8) + ) + (block + (br_if $label$2 + (i32.eqz + (local.get $3) + ) + ) + (i32.store offset=100 + (local.get $4) + (local.tee $3 + (i32.load offset=8 + (local.get $3) + ) + ) + ) + (local.set $5 + (i32.const 0) + ) + ) + ) + (i32.store offset=104 + (local.get $4) + (local.get $3) + ) + (if + (i32.eqz + (local.get $3) + ) + (block + (br_if $label$6 + (i32.ge_u + (local.get $9) + (local.get $12) + ) + ) + (local.set $3 + (i32.add + (local.get $10) + (i32.mul + (i32.add + (i32.shl + (i32.add + (i32.load offset=16 + (local.get $0) + ) + (i32.load offset=12 + (local.get $0) + ) + ) + (i32.const 3) + ) + (i32.const 12) + ) + (local.get $9) + ) + ) + ) + (local.set $9 + (i32.add + (local.get $9) + (i32.const 1) + ) + ) + ) + ) + (i32.store offset=116 + (local.get $4) + (local.get $3) + ) + (i32.store offset=120 + (local.get $4) + (local.get $3) + ) + (i32.store offset=112 + (local.get $4) + (local.get $3) + ) + (br_if $label$2 + (i32.eqz + (local.get $3) + ) + ) + (if + (i32.eqz + (i32.load8_u + (i32.add + (local.get $3) + (local.tee $8 + (i32.and + (local.get $5) + (i32.const 255) + ) + ) + ) + ) + ) + (block + (local.set $5 + (i32.add + (local.get $5) + (i32.const 1) + ) + ) + (br $label$7) + ) + ) + (memory.copy + (local.get $7) + (i32.add + (i32.add + (i32.mul + (local.tee $6 + (i32.load offset=12 + (local.get $0) + ) + ) + (local.get $8) + ) + (local.get $3) + ) + (i32.const 12) + ) + (local.get $6) + ) + (i32.store offset=128 + (local.get $4) + (local.tee $11 + (i32.load + (local.get $0) + ) + ) + ) + (block $label$11 + (if + (i32.eq + (local.get $10) + (local.get $11) + ) + (block + (memory.copy + (local.get $13) + (i32.add + (i32.add + (i32.add + (i32.shl + (local.get $6) + (i32.const 3) + ) + (i32.mul + (local.tee $6 + (i32.load offset=16 + (local.get $0) + ) + ) + (local.get $8) + ) + ) + (local.get $3) + ) + (i32.const 12) + ) + (local.get $6) + ) + (local.set $5 + (i32.add + (local.get $5) + (i32.const 1) + ) + ) + (br $label$11) + ) + ) + (i32.store offset=132 + (local.get $4) + (local.tee $11 + (i32.load offset=32 + (local.get $0) + ) + ) + ) + (i32.store offset=136 + (local.get $4) + (local.tee $8 + (i32.load offset=36 + (local.get $0) + ) + ) + ) + (br_if $label$2 + (i32.eqz + (local.get $8) + ) + ) + (local.set $5 + (i32.add + (local.get $5) + (i32.const 1) + ) + ) + (br_if $label$7 + (i32.eqz + (i32.and + (call $runtime.hashmapGet + (local.get $0) + (local.get $7) + (local.get $13) + (call_indirect (type $i32_i32_i32_i32_=>_i32) + (local.get $7) + (local.get $6) + (i32.load offset=4 + (local.get $0) + ) + (local.get $11) + (local.get $8) + ) + ) + (i32.const 1) + ) + ) + ) + ) + ) + (i32.store offset=140 + (local.get $4) + (local.tee $8 + (i32.load offset=40 + (local.get $4) + ) + ) + ) + (i32.store offset=144 + (local.get $4) + (local.tee $6 + (i32.load offset=44 + (local.get $4) + ) + ) + ) + (br_if $label$2 + (i32.eqz + (local.get $6) + ) + ) + (call $runtime.hashmapSet + (i32.add + (local.get $4) + (i32.const 8) + ) + (local.get $7) + (local.get $13) + (call_indirect (type $i32_i32_i32_i32_=>_i32) + (local.get $7) + (i32.load offset=20 + (local.get $4) + ) + (i32.load offset=12 + (local.get $4) + ) + (local.get $8) + (local.get $6) + ) + ) + (br $label$4) + ) + ) + (i32.store + (local.get $0) + (local.tee $3 + (i32.load offset=8 + (local.get $4) + ) + ) + ) + (i64.store offset=4 align=4 + (local.get $0) + (i64.load offset=12 align=4 + (local.get $4) + ) + ) + (i64.store offset=12 align=4 + (local.get $0) + (i64.load offset=20 align=4 + (local.get $4) + ) + ) + (i32.store8 offset=20 + (local.get $0) + (i32.load8_u offset=28 + (local.get $4) + ) + ) + (i32.store offset=24 + (local.get $0) + (local.tee $5 + (i32.load offset=32 + (local.get $4) + ) + ) + ) + (i32.store offset=28 + (local.get $0) + (local.tee $7 + (i32.load offset=36 + (local.get $4) + ) + ) + ) + (i32.store offset=32 + (local.get $0) + (local.tee $6 + (i32.load offset=40 + (local.get $4) + ) + ) + ) + (i32.store offset=36 + (local.get $0) + (local.tee $8 + (i32.load offset=44 + (local.get $4) + ) + ) + ) + (i32.store offset=148 + (local.get $4) + (local.get $3) + ) + (i32.store offset=152 + (local.get $4) + (local.get $5) + ) + (i32.store offset=156 + (local.get $4) + (local.get $7) + ) + (i32.store offset=160 + (local.get $4) + (local.get $6) + ) + (i32.store offset=164 + (local.get $4) + (local.get $8) + ) + (i32.store offset=168 + (local.get $4) + (local.tee $5 + (i32.load offset=32 + (local.get $0) + ) + ) + ) + (i32.store offset=172 + (local.get $4) + (local.tee $3 + (i32.load offset=36 + (local.get $0) + ) + ) + ) + (br_if $label$2 + (i32.eqz + (local.get $3) + ) + ) + (local.set $3 + (call_indirect (type $i32_i32_i32_i32_=>_i32) + (local.get $1) + (i32.load offset=12 + (local.get $0) + ) + (i32.load offset=4 + (local.get $0) + ) + (local.get $5) + (local.get $3) + ) + ) + (local.set $5 + (i32.load8_u offset=20 + (local.get $0) + ) + ) + ) + (i32.store offset=176 + (local.get $4) + (local.tee $7 + (i32.load + (local.get $0) + ) + ) + ) + (local.set $9 + (i32.add + (local.get $7) + (i32.mul + (i32.add + (i32.shl + (i32.add + (i32.load offset=16 + (local.get $0) + ) + (i32.load offset=12 + (local.get $0) + ) + ) + (i32.const 3) + ) + (i32.const 12) + ) + (i32.and + (select + (i32.const -1) + (i32.xor + (i32.shl + (i32.const -1) + (local.tee $5 + (i32.and + (local.get $5) + (i32.const 255) + ) + ) + ) + (i32.const -1) + ) + (i32.gt_u + (local.get $5) + (i32.const 31) + ) + ) + (local.get $3) + ) + ) + ) + ) + (local.set $12 + (select + (local.tee $3 + (i32.shr_u + (local.get $3) + (i32.const 24) + ) + ) + (i32.const 1) + (local.get $3) + ) + ) + (local.set $3 + (i32.const 0) + ) + (local.set $5 + (i32.const 0) + ) + (local.set $8 + (i32.const 0) + ) + (local.set $6 + (i32.const 0) + ) + (loop $label$13 + (block $label$14 + (i32.store offset=212 + (local.get $4) + (local.tee $7 + (local.get $9) + ) + ) + (i32.store offset=216 + (local.get $4) + (local.get $7) + ) + (i32.store offset=196 + (local.get $4) + (local.get $7) + ) + (i32.store offset=192 + (local.get $4) + (local.get $3) + ) + (i32.store offset=188 + (local.get $4) + (local.get $5) + ) + (i32.store offset=184 + (local.get $4) + (local.get $8) + ) + (i32.store offset=180 + (local.get $4) + (local.get $6) + ) + (br_if $label$14 + (i32.eqz + (local.get $7) + ) + ) + (local.set $3 + (i32.const 0) + ) + (loop $label$15 + (block $label$16 + (i32.store offset=204 + (local.get $4) + (local.get $8) + ) + (i32.store offset=208 + (local.get $4) + (local.get $5) + ) + (i32.store offset=200 + (local.get $4) + (local.get $6) + ) + (br_if $label$16 + (i32.eq + (local.get $3) + (i32.const 8) + ) + ) + (i32.store offset=220 + (local.get $4) + (local.tee $6 + (select + (local.get $6) + (local.tee $9 + (i32.add + (local.get $3) + (local.get $7) + ) + ) + (local.tee $11 + (i32.or + (i32.load8_u + (local.get $9) + ) + (local.get $5) + ) + ) + ) + ) + ) + (i32.store offset=228 + (local.get $4) + (local.tee $5 + (select + (local.get $5) + (local.tee $13 + (i32.add + (i32.add + (i32.mul + (local.tee $10 + (i32.load offset=12 + (local.get $0) + ) + ) + (local.get $3) + ) + (local.get $7) + ) + (i32.const 12) + ) + ) + (local.get $11) + ) + ) + ) + (i32.store offset=224 + (local.get $4) + (local.tee $8 + (select + (local.get $8) + (local.tee $15 + (i32.add + (i32.add + (i32.add + (i32.mul + (i32.load offset=16 + (local.get $0) + ) + (local.get $3) + ) + (i32.shl + (local.get $10) + (i32.const 3) + ) + ) + (local.get $7) + ) + (i32.const 12) + ) + ) + (local.get $11) + ) + ) + ) + (block $label$17 + (br_if $label$17 + (i32.ne + (i32.load8_u + (local.get $9) + ) + (local.get $12) + ) + ) + (i32.store offset=232 + (local.get $4) + (local.tee $11 + (i32.load offset=24 + (local.get $0) + ) + ) + ) + (i32.store offset=236 + (local.get $4) + (local.tee $9 + (i32.load offset=28 + (local.get $0) + ) + ) + ) + (br_if $label$2 + (i32.eqz + (local.get $9) + ) + ) + (br_if $label$17 + (i32.eqz + (i32.and + (call_indirect (type $i32_i32_i32_i32_=>_i32) + (local.get $1) + (local.get $13) + (local.get $10) + (local.get $11) + (local.get $9) + ) + (i32.const 1) + ) + ) + ) + (memory.copy + (local.get $15) + (local.get $2) + (i32.load offset=16 + (local.get $0) + ) + ) + (br $label$1) + ) + (local.set $3 + (i32.add + (local.get $3) + (i32.const 1) + ) + ) + (br $label$15) + ) + ) + (i32.store offset=240 + (local.get $4) + (local.tee $9 + (i32.load offset=8 + (local.get $7) + ) + ) + ) + (local.set $3 + (local.get $7) + ) + (br $label$13) + ) + ) + (if + (i32.eqz + (local.get $5) + ) + (block + (local.set $5 + (call $runtime.alloc + (i32.add + (i32.shl + (i32.add + (i32.load offset=16 + (local.get $0) + ) + (i32.load offset=12 + (local.get $0) + ) + ) + (i32.const 3) + ) + (i32.const 12) + ) + ) + ) + (i32.store offset=8 + (local.get $0) + (i32.add + (i32.load offset=8 + (local.get $0) + ) + (i32.const 1) + ) + ) + (i32.store offset=248 + (local.get $4) + (local.get $5) + ) + (i32.store offset=252 + (local.get $4) + (local.get $5) + ) + (i32.store offset=244 + (local.get $4) + (local.get $5) + ) + (memory.copy + (local.tee $7 + (i32.add + (local.get $5) + (i32.const 12) + ) + ) + (local.get $1) + (local.tee $6 + (i32.load offset=12 + (local.get $0) + ) + ) + ) + (memory.copy + (i32.add + (local.get $7) + (i32.shl + (local.get $6) + (i32.const 3) + ) + ) + (local.get $2) + (i32.load offset=16 + (local.get $0) + ) + ) + (i32.store8 + (local.get $5) + (local.get $12) + ) + (br_if $label$2 + (i32.eqz + (local.get $3) + ) + ) + (i32.store offset=8 + (local.get $3) + (local.get $5) + ) + (br $label$1) + ) + ) + (i32.store offset=8 + (local.get $0) + (i32.add + (i32.load offset=8 + (local.get $0) + ) + (i32.const 1) + ) + ) + (memory.copy + (local.get $5) + (local.get $1) + (i32.load offset=12 + (local.get $0) + ) + ) + (memory.copy + (local.get $8) + (local.get $2) + (i32.load offset=16 + (local.get $0) + ) + ) + (br_if $label$2 + (i32.eqz + (local.get $6) + ) + ) + (i32.store8 + (local.get $6) + (local.get $12) + ) + (br $label$1) + ) + (call $runtime.nilPanic) + (unreachable) + ) + (i32.store + (i32.const 65932) + (local.get $14) + ) + (global.set $__stack_pointer + (i32.add + (local.get $4) + (i32.const 256) + ) + ) + ) + ;; custom section ".debug_info", size 29604 + ;; custom section ".debug_pubtypes", size 2106 + ;; custom section ".debug_loc", size 8492 + ;; custom section ".debug_ranges", size 1440 + ;; custom section ".debug_aranges", size 80 + ;; custom section ".debug_abbrev", size 2027 + ;; custom section ".debug_line", size 11123 + ;; custom section ".debug_str", size 18173 + ;; custom section ".debug_pubnames", size 16895 + ;; custom section "producers", size 128 +) diff --git a/guest/tinygo/ww.go b/guest/tinygo/ww.go new file mode 100644 index 00000000..20bfa36f --- /dev/null +++ b/guest/tinygo/ww.go @@ -0,0 +1,6 @@ +// Package ww contains Wetware bindings for WASM guest-code. +package ww + +func Test(a, b uint32) uint32 { + return test(a, b) +} diff --git a/internal/api/process/process.capnp.go b/internal/api/process/process.capnp.go index f06d2d63..55a78f39 100644 --- a/internal/api/process/process.capnp.go +++ b/internal/api/process/process.capnp.go @@ -16,23 +16,23 @@ type Executor capnp.Client // Executor_TypeID is the unique identifier for the type Executor. const Executor_TypeID = 0xaf2e5ebaa58175d2 -func (c Executor) Spawn(ctx context.Context, params func(Executor_spawn_Params) error) (Executor_spawn_Results_Future, capnp.ReleaseFunc) { +func (c Executor) Exec(ctx context.Context, params func(Executor_exec_Params) error) (Executor_exec_Results_Future, capnp.ReleaseFunc) { s := capnp.Send{ Method: capnp.Method{ InterfaceID: 0xaf2e5ebaa58175d2, MethodID: 0, InterfaceName: "process.capnp:Executor", - MethodName: "spawn", + MethodName: "exec", }, } if params != nil { - s.ArgsSize = capnp.ObjectSize{DataSize: 0, PointerCount: 2} - s.PlaceArgs = func(s capnp.Struct) error { return params(Executor_spawn_Params(s)) } + s.ArgsSize = capnp.ObjectSize{DataSize: 0, PointerCount: 1} + s.PlaceArgs = func(s capnp.Struct) error { return params(Executor_exec_Params(s)) } } ans, release := capnp.Client(c).SendCall(ctx, s) - return Executor_spawn_Results_Future{Future: ans.Future()}, release + return Executor_exec_Results_Future{Future: ans.Future()}, release } @@ -109,7 +109,7 @@ func (c Executor) GetFlowLimiter() fc.FlowLimiter { // A Executor_Server is a Executor with a local implementation. type Executor_Server interface { - Spawn(context.Context, Executor_spawn) error + Exec(context.Context, Executor_exec) error } // Executor_NewServer creates a new Server from an implementation of Executor_Server. @@ -136,31 +136,31 @@ func Executor_Methods(methods []server.Method, s Executor_Server) []server.Metho InterfaceID: 0xaf2e5ebaa58175d2, MethodID: 0, InterfaceName: "process.capnp:Executor", - MethodName: "spawn", + MethodName: "exec", }, Impl: func(ctx context.Context, call *server.Call) error { - return s.Spawn(ctx, Executor_spawn{call}) + return s.Exec(ctx, Executor_exec{call}) }, }) return methods } -// Executor_spawn holds the state for a server call to Executor.spawn. +// Executor_exec holds the state for a server call to Executor.exec. // See server.Call for documentation. -type Executor_spawn struct { +type Executor_exec struct { *server.Call } // Args returns the call's arguments. -func (c Executor_spawn) Args() Executor_spawn_Params { - return Executor_spawn_Params(c.Call.Args()) +func (c Executor_exec) Args() Executor_exec_Params { + return Executor_exec_Params(c.Call.Args()) } // AllocResults allocates the results struct. -func (c Executor_spawn) AllocResults() (Executor_spawn_Results, error) { +func (c Executor_exec) AllocResults() (Executor_exec_Results, error) { r, err := c.Call.AllocResults(capnp.ObjectSize{DataSize: 0, PointerCount: 1}) - return Executor_spawn_Results(r), err + return Executor_exec_Results(r), err } // Executor_List is a list of Executor. @@ -172,158 +172,140 @@ func NewExecutor_List(s *capnp.Segment, sz int32) (Executor_List, error) { return capnp.CapList[Executor](l), err } -type Executor_spawn_Params capnp.Struct +type Executor_exec_Params capnp.Struct -// Executor_spawn_Params_TypeID is the unique identifier for the type Executor_spawn_Params. -const Executor_spawn_Params_TypeID = 0xf20b3dea95929312 +// Executor_exec_Params_TypeID is the unique identifier for the type Executor_exec_Params. +const Executor_exec_Params_TypeID = 0xf20b3dea95929312 -func NewExecutor_spawn_Params(s *capnp.Segment) (Executor_spawn_Params, error) { - st, err := capnp.NewStruct(s, capnp.ObjectSize{DataSize: 0, PointerCount: 2}) - return Executor_spawn_Params(st), err +func NewExecutor_exec_Params(s *capnp.Segment) (Executor_exec_Params, error) { + st, err := capnp.NewStruct(s, capnp.ObjectSize{DataSize: 0, PointerCount: 1}) + return Executor_exec_Params(st), err } -func NewRootExecutor_spawn_Params(s *capnp.Segment) (Executor_spawn_Params, error) { - st, err := capnp.NewRootStruct(s, capnp.ObjectSize{DataSize: 0, PointerCount: 2}) - return Executor_spawn_Params(st), err +func NewRootExecutor_exec_Params(s *capnp.Segment) (Executor_exec_Params, error) { + st, err := capnp.NewRootStruct(s, capnp.ObjectSize{DataSize: 0, PointerCount: 1}) + return Executor_exec_Params(st), err } -func ReadRootExecutor_spawn_Params(msg *capnp.Message) (Executor_spawn_Params, error) { +func ReadRootExecutor_exec_Params(msg *capnp.Message) (Executor_exec_Params, error) { root, err := msg.Root() - return Executor_spawn_Params(root.Struct()), err + return Executor_exec_Params(root.Struct()), err } -func (s Executor_spawn_Params) String() string { +func (s Executor_exec_Params) String() string { str, _ := text.Marshal(0xf20b3dea95929312, capnp.Struct(s)) return str } -func (s Executor_spawn_Params) EncodeAsPtr(seg *capnp.Segment) capnp.Ptr { +func (s Executor_exec_Params) EncodeAsPtr(seg *capnp.Segment) capnp.Ptr { return capnp.Struct(s).EncodeAsPtr(seg) } -func (Executor_spawn_Params) DecodeFromPtr(p capnp.Ptr) Executor_spawn_Params { - return Executor_spawn_Params(capnp.Struct{}.DecodeFromPtr(p)) +func (Executor_exec_Params) DecodeFromPtr(p capnp.Ptr) Executor_exec_Params { + return Executor_exec_Params(capnp.Struct{}.DecodeFromPtr(p)) } -func (s Executor_spawn_Params) ToPtr() capnp.Ptr { +func (s Executor_exec_Params) ToPtr() capnp.Ptr { return capnp.Struct(s).ToPtr() } -func (s Executor_spawn_Params) IsValid() bool { +func (s Executor_exec_Params) IsValid() bool { return capnp.Struct(s).IsValid() } -func (s Executor_spawn_Params) Message() *capnp.Message { +func (s Executor_exec_Params) Message() *capnp.Message { return capnp.Struct(s).Message() } -func (s Executor_spawn_Params) Segment() *capnp.Segment { +func (s Executor_exec_Params) Segment() *capnp.Segment { return capnp.Struct(s).Segment() } -func (s Executor_spawn_Params) ByteCode() ([]byte, error) { +func (s Executor_exec_Params) Bytecode() ([]byte, error) { p, err := capnp.Struct(s).Ptr(0) return []byte(p.Data()), err } -func (s Executor_spawn_Params) HasByteCode() bool { +func (s Executor_exec_Params) HasBytecode() bool { return capnp.Struct(s).HasPtr(0) } -func (s Executor_spawn_Params) SetByteCode(v []byte) error { +func (s Executor_exec_Params) SetBytecode(v []byte) error { return capnp.Struct(s).SetData(0, v) } -func (s Executor_spawn_Params) EntryPoint() (string, error) { - p, err := capnp.Struct(s).Ptr(1) - return p.TextDefault("run"), err -} - -func (s Executor_spawn_Params) HasEntryPoint() bool { - return capnp.Struct(s).HasPtr(1) -} - -func (s Executor_spawn_Params) EntryPointBytes() ([]byte, error) { - p, err := capnp.Struct(s).Ptr(1) - return p.TextBytesDefault("run"), err -} - -func (s Executor_spawn_Params) SetEntryPoint(v string) error { - return capnp.Struct(s).SetNewText(1, v) -} +// Executor_exec_Params_List is a list of Executor_exec_Params. +type Executor_exec_Params_List = capnp.StructList[Executor_exec_Params] -// Executor_spawn_Params_List is a list of Executor_spawn_Params. -type Executor_spawn_Params_List = capnp.StructList[Executor_spawn_Params] - -// NewExecutor_spawn_Params creates a new list of Executor_spawn_Params. -func NewExecutor_spawn_Params_List(s *capnp.Segment, sz int32) (Executor_spawn_Params_List, error) { - l, err := capnp.NewCompositeList(s, capnp.ObjectSize{DataSize: 0, PointerCount: 2}, sz) - return capnp.StructList[Executor_spawn_Params](l), err +// NewExecutor_exec_Params creates a new list of Executor_exec_Params. +func NewExecutor_exec_Params_List(s *capnp.Segment, sz int32) (Executor_exec_Params_List, error) { + l, err := capnp.NewCompositeList(s, capnp.ObjectSize{DataSize: 0, PointerCount: 1}, sz) + return capnp.StructList[Executor_exec_Params](l), err } -// Executor_spawn_Params_Future is a wrapper for a Executor_spawn_Params promised by a client call. -type Executor_spawn_Params_Future struct{ *capnp.Future } +// Executor_exec_Params_Future is a wrapper for a Executor_exec_Params promised by a client call. +type Executor_exec_Params_Future struct{ *capnp.Future } -func (f Executor_spawn_Params_Future) Struct() (Executor_spawn_Params, error) { +func (f Executor_exec_Params_Future) Struct() (Executor_exec_Params, error) { p, err := f.Future.Ptr() - return Executor_spawn_Params(p.Struct()), err + return Executor_exec_Params(p.Struct()), err } -type Executor_spawn_Results capnp.Struct +type Executor_exec_Results capnp.Struct -// Executor_spawn_Results_TypeID is the unique identifier for the type Executor_spawn_Results. -const Executor_spawn_Results_TypeID = 0xbb4f16b0a7d2d09b +// Executor_exec_Results_TypeID is the unique identifier for the type Executor_exec_Results. +const Executor_exec_Results_TypeID = 0xbb4f16b0a7d2d09b -func NewExecutor_spawn_Results(s *capnp.Segment) (Executor_spawn_Results, error) { +func NewExecutor_exec_Results(s *capnp.Segment) (Executor_exec_Results, error) { st, err := capnp.NewStruct(s, capnp.ObjectSize{DataSize: 0, PointerCount: 1}) - return Executor_spawn_Results(st), err + return Executor_exec_Results(st), err } -func NewRootExecutor_spawn_Results(s *capnp.Segment) (Executor_spawn_Results, error) { +func NewRootExecutor_exec_Results(s *capnp.Segment) (Executor_exec_Results, error) { st, err := capnp.NewRootStruct(s, capnp.ObjectSize{DataSize: 0, PointerCount: 1}) - return Executor_spawn_Results(st), err + return Executor_exec_Results(st), err } -func ReadRootExecutor_spawn_Results(msg *capnp.Message) (Executor_spawn_Results, error) { +func ReadRootExecutor_exec_Results(msg *capnp.Message) (Executor_exec_Results, error) { root, err := msg.Root() - return Executor_spawn_Results(root.Struct()), err + return Executor_exec_Results(root.Struct()), err } -func (s Executor_spawn_Results) String() string { +func (s Executor_exec_Results) String() string { str, _ := text.Marshal(0xbb4f16b0a7d2d09b, capnp.Struct(s)) return str } -func (s Executor_spawn_Results) EncodeAsPtr(seg *capnp.Segment) capnp.Ptr { +func (s Executor_exec_Results) EncodeAsPtr(seg *capnp.Segment) capnp.Ptr { return capnp.Struct(s).EncodeAsPtr(seg) } -func (Executor_spawn_Results) DecodeFromPtr(p capnp.Ptr) Executor_spawn_Results { - return Executor_spawn_Results(capnp.Struct{}.DecodeFromPtr(p)) +func (Executor_exec_Results) DecodeFromPtr(p capnp.Ptr) Executor_exec_Results { + return Executor_exec_Results(capnp.Struct{}.DecodeFromPtr(p)) } -func (s Executor_spawn_Results) ToPtr() capnp.Ptr { +func (s Executor_exec_Results) ToPtr() capnp.Ptr { return capnp.Struct(s).ToPtr() } -func (s Executor_spawn_Results) IsValid() bool { +func (s Executor_exec_Results) IsValid() bool { return capnp.Struct(s).IsValid() } -func (s Executor_spawn_Results) Message() *capnp.Message { +func (s Executor_exec_Results) Message() *capnp.Message { return capnp.Struct(s).Message() } -func (s Executor_spawn_Results) Segment() *capnp.Segment { +func (s Executor_exec_Results) Segment() *capnp.Segment { return capnp.Struct(s).Segment() } -func (s Executor_spawn_Results) Process() Process { +func (s Executor_exec_Results) Process() Process { p, _ := capnp.Struct(s).Ptr(0) return Process(p.Interface().Client()) } -func (s Executor_spawn_Results) HasProcess() bool { +func (s Executor_exec_Results) HasProcess() bool { return capnp.Struct(s).HasPtr(0) } -func (s Executor_spawn_Results) SetProcess(v Process) error { +func (s Executor_exec_Results) SetProcess(v Process) error { if !v.IsValid() { return capnp.Struct(s).SetPtr(0, capnp.Ptr{}) } @@ -332,23 +314,23 @@ func (s Executor_spawn_Results) SetProcess(v Process) error { return capnp.Struct(s).SetPtr(0, in.ToPtr()) } -// Executor_spawn_Results_List is a list of Executor_spawn_Results. -type Executor_spawn_Results_List = capnp.StructList[Executor_spawn_Results] +// Executor_exec_Results_List is a list of Executor_exec_Results. +type Executor_exec_Results_List = capnp.StructList[Executor_exec_Results] -// NewExecutor_spawn_Results creates a new list of Executor_spawn_Results. -func NewExecutor_spawn_Results_List(s *capnp.Segment, sz int32) (Executor_spawn_Results_List, error) { +// NewExecutor_exec_Results creates a new list of Executor_exec_Results. +func NewExecutor_exec_Results_List(s *capnp.Segment, sz int32) (Executor_exec_Results_List, error) { l, err := capnp.NewCompositeList(s, capnp.ObjectSize{DataSize: 0, PointerCount: 1}, sz) - return capnp.StructList[Executor_spawn_Results](l), err + return capnp.StructList[Executor_exec_Results](l), err } -// Executor_spawn_Results_Future is a wrapper for a Executor_spawn_Results promised by a client call. -type Executor_spawn_Results_Future struct{ *capnp.Future } +// Executor_exec_Results_Future is a wrapper for a Executor_exec_Results promised by a client call. +type Executor_exec_Results_Future struct{ *capnp.Future } -func (f Executor_spawn_Results_Future) Struct() (Executor_spawn_Results, error) { +func (f Executor_exec_Results_Future) Struct() (Executor_exec_Results, error) { p, err := f.Future.Ptr() - return Executor_spawn_Results(p.Struct()), err + return Executor_exec_Results(p.Struct()), err } -func (p Executor_spawn_Results_Future) Process() Process { +func (p Executor_exec_Results_Future) Process() Process { return Process(p.Future.Field(0, nil).Client()) } @@ -357,63 +339,43 @@ type Process capnp.Client // Process_TypeID is the unique identifier for the type Process. const Process_TypeID = 0xda23f0d3a8250633 -func (c Process) Start(ctx context.Context, params func(Process_start_Params) error) (Process_start_Results_Future, capnp.ReleaseFunc) { +func (c Process) Wait(ctx context.Context, params func(Process_wait_Params) error) (Process_wait_Results_Future, capnp.ReleaseFunc) { s := capnp.Send{ Method: capnp.Method{ InterfaceID: 0xda23f0d3a8250633, MethodID: 0, InterfaceName: "process.capnp:Process", - MethodName: "start", + MethodName: "wait", }, } if params != nil { s.ArgsSize = capnp.ObjectSize{DataSize: 0, PointerCount: 0} - s.PlaceArgs = func(s capnp.Struct) error { return params(Process_start_Params(s)) } + s.PlaceArgs = func(s capnp.Struct) error { return params(Process_wait_Params(s)) } } ans, release := capnp.Client(c).SendCall(ctx, s) - return Process_start_Results_Future{Future: ans.Future()}, release + return Process_wait_Results_Future{Future: ans.Future()}, release } -func (c Process) Stop(ctx context.Context, params func(Process_stop_Params) error) (Process_stop_Results_Future, capnp.ReleaseFunc) { +func (c Process) Kill(ctx context.Context, params func(Process_kill_Params) error) (Process_kill_Results_Future, capnp.ReleaseFunc) { s := capnp.Send{ Method: capnp.Method{ InterfaceID: 0xda23f0d3a8250633, MethodID: 1, InterfaceName: "process.capnp:Process", - MethodName: "stop", - }, - } - if params != nil { - s.ArgsSize = capnp.ObjectSize{DataSize: 0, PointerCount: 0} - s.PlaceArgs = func(s capnp.Struct) error { return params(Process_stop_Params(s)) } - } - - ans, release := capnp.Client(c).SendCall(ctx, s) - return Process_stop_Results_Future{Future: ans.Future()}, release - -} - -func (c Process) Wait(ctx context.Context, params func(Process_wait_Params) error) (Process_wait_Results_Future, capnp.ReleaseFunc) { - - s := capnp.Send{ - Method: capnp.Method{ - InterfaceID: 0xda23f0d3a8250633, - MethodID: 2, - InterfaceName: "process.capnp:Process", - MethodName: "wait", + MethodName: "kill", }, } if params != nil { s.ArgsSize = capnp.ObjectSize{DataSize: 0, PointerCount: 0} - s.PlaceArgs = func(s capnp.Struct) error { return params(Process_wait_Params(s)) } + s.PlaceArgs = func(s capnp.Struct) error { return params(Process_kill_Params(s)) } } ans, release := capnp.Client(c).SendCall(ctx, s) - return Process_wait_Results_Future{Future: ans.Future()}, release + return Process_kill_Results_Future{Future: ans.Future()}, release } @@ -490,11 +452,9 @@ func (c Process) GetFlowLimiter() fc.FlowLimiter { // A Process_Server is a Process with a local implementation. type Process_Server interface { - Start(context.Context, Process_start) error - - Stop(context.Context, Process_stop) error - Wait(context.Context, Process_wait) error + + Kill(context.Context, Process_kill) error } // Process_NewServer creates a new Server from an implementation of Process_Server. @@ -513,7 +473,7 @@ func Process_ServerToClient(s Process_Server) Process { // This can be used to create a more complicated Server. func Process_Methods(methods []server.Method, s Process_Server) []server.Method { if cap(methods) == 0 { - methods = make([]server.Method, 0, 3) + methods = make([]server.Method, 0, 2) } methods = append(methods, server.Method{ @@ -521,10 +481,10 @@ func Process_Methods(methods []server.Method, s Process_Server) []server.Method InterfaceID: 0xda23f0d3a8250633, MethodID: 0, InterfaceName: "process.capnp:Process", - MethodName: "start", + MethodName: "wait", }, Impl: func(ctx context.Context, call *server.Call) error { - return s.Start(ctx, Process_start{call}) + return s.Wait(ctx, Process_wait{call}) }, }) @@ -533,77 +493,48 @@ func Process_Methods(methods []server.Method, s Process_Server) []server.Method InterfaceID: 0xda23f0d3a8250633, MethodID: 1, InterfaceName: "process.capnp:Process", - MethodName: "stop", + MethodName: "kill", }, Impl: func(ctx context.Context, call *server.Call) error { - return s.Stop(ctx, Process_stop{call}) - }, - }) - - methods = append(methods, server.Method{ - Method: capnp.Method{ - InterfaceID: 0xda23f0d3a8250633, - MethodID: 2, - InterfaceName: "process.capnp:Process", - MethodName: "wait", - }, - Impl: func(ctx context.Context, call *server.Call) error { - return s.Wait(ctx, Process_wait{call}) + return s.Kill(ctx, Process_kill{call}) }, }) return methods } -// Process_start holds the state for a server call to Process.start. +// Process_wait holds the state for a server call to Process.wait. // See server.Call for documentation. -type Process_start struct { +type Process_wait struct { *server.Call } // Args returns the call's arguments. -func (c Process_start) Args() Process_start_Params { - return Process_start_Params(c.Call.Args()) +func (c Process_wait) Args() Process_wait_Params { + return Process_wait_Params(c.Call.Args()) } // AllocResults allocates the results struct. -func (c Process_start) AllocResults() (Process_start_Results, error) { - r, err := c.Call.AllocResults(capnp.ObjectSize{DataSize: 0, PointerCount: 0}) - return Process_start_Results(r), err +func (c Process_wait) AllocResults() (Process_wait_Results, error) { + r, err := c.Call.AllocResults(capnp.ObjectSize{DataSize: 8, PointerCount: 0}) + return Process_wait_Results(r), err } -// Process_stop holds the state for a server call to Process.stop. +// Process_kill holds the state for a server call to Process.kill. // See server.Call for documentation. -type Process_stop struct { +type Process_kill struct { *server.Call } // Args returns the call's arguments. -func (c Process_stop) Args() Process_stop_Params { - return Process_stop_Params(c.Call.Args()) +func (c Process_kill) Args() Process_kill_Params { + return Process_kill_Params(c.Call.Args()) } // AllocResults allocates the results struct. -func (c Process_stop) AllocResults() (Process_stop_Results, error) { +func (c Process_kill) AllocResults() (Process_kill_Results, error) { r, err := c.Call.AllocResults(capnp.ObjectSize{DataSize: 0, PointerCount: 0}) - return Process_stop_Results(r), err -} - -// Process_wait holds the state for a server call to Process.wait. -// See server.Call for documentation. -type Process_wait struct { - *server.Call -} - -// Args returns the call's arguments. -func (c Process_wait) Args() Process_wait_Params { - return Process_wait_Params(c.Call.Args()) -} - -// AllocResults allocates the results struct. -func (c Process_wait) AllocResults() (Process_wait_Results, error) { - r, err := c.Call.AllocResults(capnp.ObjectSize{DataSize: 8, PointerCount: 0}) - return Process_wait_Results(r), err + return Process_kill_Results(r), err } // Process_List is a list of Process. @@ -615,451 +546,311 @@ func NewProcess_List(s *capnp.Segment, sz int32) (Process_List, error) { return capnp.CapList[Process](l), err } -type Process_start_Params capnp.Struct +type Process_wait_Params capnp.Struct -// Process_start_Params_TypeID is the unique identifier for the type Process_start_Params. -const Process_start_Params_TypeID = 0xf9694ae208dbb3e3 +// Process_wait_Params_TypeID is the unique identifier for the type Process_wait_Params. +const Process_wait_Params_TypeID = 0xf9694ae208dbb3e3 -func NewProcess_start_Params(s *capnp.Segment) (Process_start_Params, error) { +func NewProcess_wait_Params(s *capnp.Segment) (Process_wait_Params, error) { st, err := capnp.NewStruct(s, capnp.ObjectSize{DataSize: 0, PointerCount: 0}) - return Process_start_Params(st), err + return Process_wait_Params(st), err } -func NewRootProcess_start_Params(s *capnp.Segment) (Process_start_Params, error) { +func NewRootProcess_wait_Params(s *capnp.Segment) (Process_wait_Params, error) { st, err := capnp.NewRootStruct(s, capnp.ObjectSize{DataSize: 0, PointerCount: 0}) - return Process_start_Params(st), err + return Process_wait_Params(st), err } -func ReadRootProcess_start_Params(msg *capnp.Message) (Process_start_Params, error) { +func ReadRootProcess_wait_Params(msg *capnp.Message) (Process_wait_Params, error) { root, err := msg.Root() - return Process_start_Params(root.Struct()), err + return Process_wait_Params(root.Struct()), err } -func (s Process_start_Params) String() string { +func (s Process_wait_Params) String() string { str, _ := text.Marshal(0xf9694ae208dbb3e3, capnp.Struct(s)) return str } -func (s Process_start_Params) EncodeAsPtr(seg *capnp.Segment) capnp.Ptr { +func (s Process_wait_Params) EncodeAsPtr(seg *capnp.Segment) capnp.Ptr { return capnp.Struct(s).EncodeAsPtr(seg) } -func (Process_start_Params) DecodeFromPtr(p capnp.Ptr) Process_start_Params { - return Process_start_Params(capnp.Struct{}.DecodeFromPtr(p)) +func (Process_wait_Params) DecodeFromPtr(p capnp.Ptr) Process_wait_Params { + return Process_wait_Params(capnp.Struct{}.DecodeFromPtr(p)) } -func (s Process_start_Params) ToPtr() capnp.Ptr { +func (s Process_wait_Params) ToPtr() capnp.Ptr { return capnp.Struct(s).ToPtr() } -func (s Process_start_Params) IsValid() bool { +func (s Process_wait_Params) IsValid() bool { return capnp.Struct(s).IsValid() } -func (s Process_start_Params) Message() *capnp.Message { +func (s Process_wait_Params) Message() *capnp.Message { return capnp.Struct(s).Message() } -func (s Process_start_Params) Segment() *capnp.Segment { +func (s Process_wait_Params) Segment() *capnp.Segment { return capnp.Struct(s).Segment() } -// Process_start_Params_List is a list of Process_start_Params. -type Process_start_Params_List = capnp.StructList[Process_start_Params] +// Process_wait_Params_List is a list of Process_wait_Params. +type Process_wait_Params_List = capnp.StructList[Process_wait_Params] -// NewProcess_start_Params creates a new list of Process_start_Params. -func NewProcess_start_Params_List(s *capnp.Segment, sz int32) (Process_start_Params_List, error) { +// NewProcess_wait_Params creates a new list of Process_wait_Params. +func NewProcess_wait_Params_List(s *capnp.Segment, sz int32) (Process_wait_Params_List, error) { l, err := capnp.NewCompositeList(s, capnp.ObjectSize{DataSize: 0, PointerCount: 0}, sz) - return capnp.StructList[Process_start_Params](l), err + return capnp.StructList[Process_wait_Params](l), err } -// Process_start_Params_Future is a wrapper for a Process_start_Params promised by a client call. -type Process_start_Params_Future struct{ *capnp.Future } +// Process_wait_Params_Future is a wrapper for a Process_wait_Params promised by a client call. +type Process_wait_Params_Future struct{ *capnp.Future } -func (f Process_start_Params_Future) Struct() (Process_start_Params, error) { +func (f Process_wait_Params_Future) Struct() (Process_wait_Params, error) { p, err := f.Future.Ptr() - return Process_start_Params(p.Struct()), err + return Process_wait_Params(p.Struct()), err } -type Process_start_Results capnp.Struct +type Process_wait_Results capnp.Struct -// Process_start_Results_TypeID is the unique identifier for the type Process_start_Results. -const Process_start_Results_TypeID = 0xd72ab4a0243047ac +// Process_wait_Results_TypeID is the unique identifier for the type Process_wait_Results. +const Process_wait_Results_TypeID = 0xd72ab4a0243047ac -func NewProcess_start_Results(s *capnp.Segment) (Process_start_Results, error) { - st, err := capnp.NewStruct(s, capnp.ObjectSize{DataSize: 0, PointerCount: 0}) - return Process_start_Results(st), err +func NewProcess_wait_Results(s *capnp.Segment) (Process_wait_Results, error) { + st, err := capnp.NewStruct(s, capnp.ObjectSize{DataSize: 8, PointerCount: 0}) + return Process_wait_Results(st), err } -func NewRootProcess_start_Results(s *capnp.Segment) (Process_start_Results, error) { - st, err := capnp.NewRootStruct(s, capnp.ObjectSize{DataSize: 0, PointerCount: 0}) - return Process_start_Results(st), err +func NewRootProcess_wait_Results(s *capnp.Segment) (Process_wait_Results, error) { + st, err := capnp.NewRootStruct(s, capnp.ObjectSize{DataSize: 8, PointerCount: 0}) + return Process_wait_Results(st), err } -func ReadRootProcess_start_Results(msg *capnp.Message) (Process_start_Results, error) { +func ReadRootProcess_wait_Results(msg *capnp.Message) (Process_wait_Results, error) { root, err := msg.Root() - return Process_start_Results(root.Struct()), err + return Process_wait_Results(root.Struct()), err } -func (s Process_start_Results) String() string { +func (s Process_wait_Results) String() string { str, _ := text.Marshal(0xd72ab4a0243047ac, capnp.Struct(s)) return str } -func (s Process_start_Results) EncodeAsPtr(seg *capnp.Segment) capnp.Ptr { +func (s Process_wait_Results) EncodeAsPtr(seg *capnp.Segment) capnp.Ptr { return capnp.Struct(s).EncodeAsPtr(seg) } -func (Process_start_Results) DecodeFromPtr(p capnp.Ptr) Process_start_Results { - return Process_start_Results(capnp.Struct{}.DecodeFromPtr(p)) +func (Process_wait_Results) DecodeFromPtr(p capnp.Ptr) Process_wait_Results { + return Process_wait_Results(capnp.Struct{}.DecodeFromPtr(p)) } -func (s Process_start_Results) ToPtr() capnp.Ptr { +func (s Process_wait_Results) ToPtr() capnp.Ptr { return capnp.Struct(s).ToPtr() } -func (s Process_start_Results) IsValid() bool { +func (s Process_wait_Results) IsValid() bool { return capnp.Struct(s).IsValid() } -func (s Process_start_Results) Message() *capnp.Message { +func (s Process_wait_Results) Message() *capnp.Message { return capnp.Struct(s).Message() } -func (s Process_start_Results) Segment() *capnp.Segment { +func (s Process_wait_Results) Segment() *capnp.Segment { return capnp.Struct(s).Segment() } - -// Process_start_Results_List is a list of Process_start_Results. -type Process_start_Results_List = capnp.StructList[Process_start_Results] - -// NewProcess_start_Results creates a new list of Process_start_Results. -func NewProcess_start_Results_List(s *capnp.Segment, sz int32) (Process_start_Results_List, error) { - l, err := capnp.NewCompositeList(s, capnp.ObjectSize{DataSize: 0, PointerCount: 0}, sz) - return capnp.StructList[Process_start_Results](l), err -} - -// Process_start_Results_Future is a wrapper for a Process_start_Results promised by a client call. -type Process_start_Results_Future struct{ *capnp.Future } - -func (f Process_start_Results_Future) Struct() (Process_start_Results, error) { - p, err := f.Future.Ptr() - return Process_start_Results(p.Struct()), err -} - -type Process_stop_Params capnp.Struct - -// Process_stop_Params_TypeID is the unique identifier for the type Process_stop_Params. -const Process_stop_Params_TypeID = 0xeea7ae19b02f5d47 - -func NewProcess_stop_Params(s *capnp.Segment) (Process_stop_Params, error) { - st, err := capnp.NewStruct(s, capnp.ObjectSize{DataSize: 0, PointerCount: 0}) - return Process_stop_Params(st), err -} - -func NewRootProcess_stop_Params(s *capnp.Segment) (Process_stop_Params, error) { - st, err := capnp.NewRootStruct(s, capnp.ObjectSize{DataSize: 0, PointerCount: 0}) - return Process_stop_Params(st), err -} - -func ReadRootProcess_stop_Params(msg *capnp.Message) (Process_stop_Params, error) { - root, err := msg.Root() - return Process_stop_Params(root.Struct()), err -} - -func (s Process_stop_Params) String() string { - str, _ := text.Marshal(0xeea7ae19b02f5d47, capnp.Struct(s)) - return str -} - -func (s Process_stop_Params) EncodeAsPtr(seg *capnp.Segment) capnp.Ptr { - return capnp.Struct(s).EncodeAsPtr(seg) -} - -func (Process_stop_Params) DecodeFromPtr(p capnp.Ptr) Process_stop_Params { - return Process_stop_Params(capnp.Struct{}.DecodeFromPtr(p)) -} - -func (s Process_stop_Params) ToPtr() capnp.Ptr { - return capnp.Struct(s).ToPtr() -} -func (s Process_stop_Params) IsValid() bool { - return capnp.Struct(s).IsValid() -} - -func (s Process_stop_Params) Message() *capnp.Message { - return capnp.Struct(s).Message() +func (s Process_wait_Results) ExitCode() uint32 { + return capnp.Struct(s).Uint32(0) } -func (s Process_stop_Params) Segment() *capnp.Segment { - return capnp.Struct(s).Segment() +func (s Process_wait_Results) SetExitCode(v uint32) { + capnp.Struct(s).SetUint32(0, v) } -// Process_stop_Params_List is a list of Process_stop_Params. -type Process_stop_Params_List = capnp.StructList[Process_stop_Params] +// Process_wait_Results_List is a list of Process_wait_Results. +type Process_wait_Results_List = capnp.StructList[Process_wait_Results] -// NewProcess_stop_Params creates a new list of Process_stop_Params. -func NewProcess_stop_Params_List(s *capnp.Segment, sz int32) (Process_stop_Params_List, error) { - l, err := capnp.NewCompositeList(s, capnp.ObjectSize{DataSize: 0, PointerCount: 0}, sz) - return capnp.StructList[Process_stop_Params](l), err +// NewProcess_wait_Results creates a new list of Process_wait_Results. +func NewProcess_wait_Results_List(s *capnp.Segment, sz int32) (Process_wait_Results_List, error) { + l, err := capnp.NewCompositeList(s, capnp.ObjectSize{DataSize: 8, PointerCount: 0}, sz) + return capnp.StructList[Process_wait_Results](l), err } -// Process_stop_Params_Future is a wrapper for a Process_stop_Params promised by a client call. -type Process_stop_Params_Future struct{ *capnp.Future } +// Process_wait_Results_Future is a wrapper for a Process_wait_Results promised by a client call. +type Process_wait_Results_Future struct{ *capnp.Future } -func (f Process_stop_Params_Future) Struct() (Process_stop_Params, error) { +func (f Process_wait_Results_Future) Struct() (Process_wait_Results, error) { p, err := f.Future.Ptr() - return Process_stop_Params(p.Struct()), err + return Process_wait_Results(p.Struct()), err } -type Process_stop_Results capnp.Struct +type Process_kill_Params capnp.Struct -// Process_stop_Results_TypeID is the unique identifier for the type Process_stop_Results. -const Process_stop_Results_TypeID = 0xc53168b273d497ee +// Process_kill_Params_TypeID is the unique identifier for the type Process_kill_Params. +const Process_kill_Params_TypeID = 0xeea7ae19b02f5d47 -func NewProcess_stop_Results(s *capnp.Segment) (Process_stop_Results, error) { +func NewProcess_kill_Params(s *capnp.Segment) (Process_kill_Params, error) { st, err := capnp.NewStruct(s, capnp.ObjectSize{DataSize: 0, PointerCount: 0}) - return Process_stop_Results(st), err + return Process_kill_Params(st), err } -func NewRootProcess_stop_Results(s *capnp.Segment) (Process_stop_Results, error) { +func NewRootProcess_kill_Params(s *capnp.Segment) (Process_kill_Params, error) { st, err := capnp.NewRootStruct(s, capnp.ObjectSize{DataSize: 0, PointerCount: 0}) - return Process_stop_Results(st), err + return Process_kill_Params(st), err } -func ReadRootProcess_stop_Results(msg *capnp.Message) (Process_stop_Results, error) { +func ReadRootProcess_kill_Params(msg *capnp.Message) (Process_kill_Params, error) { root, err := msg.Root() - return Process_stop_Results(root.Struct()), err + return Process_kill_Params(root.Struct()), err } -func (s Process_stop_Results) String() string { - str, _ := text.Marshal(0xc53168b273d497ee, capnp.Struct(s)) +func (s Process_kill_Params) String() string { + str, _ := text.Marshal(0xeea7ae19b02f5d47, capnp.Struct(s)) return str } -func (s Process_stop_Results) EncodeAsPtr(seg *capnp.Segment) capnp.Ptr { +func (s Process_kill_Params) EncodeAsPtr(seg *capnp.Segment) capnp.Ptr { return capnp.Struct(s).EncodeAsPtr(seg) } -func (Process_stop_Results) DecodeFromPtr(p capnp.Ptr) Process_stop_Results { - return Process_stop_Results(capnp.Struct{}.DecodeFromPtr(p)) +func (Process_kill_Params) DecodeFromPtr(p capnp.Ptr) Process_kill_Params { + return Process_kill_Params(capnp.Struct{}.DecodeFromPtr(p)) } -func (s Process_stop_Results) ToPtr() capnp.Ptr { +func (s Process_kill_Params) ToPtr() capnp.Ptr { return capnp.Struct(s).ToPtr() } -func (s Process_stop_Results) IsValid() bool { +func (s Process_kill_Params) IsValid() bool { return capnp.Struct(s).IsValid() } -func (s Process_stop_Results) Message() *capnp.Message { +func (s Process_kill_Params) Message() *capnp.Message { return capnp.Struct(s).Message() } -func (s Process_stop_Results) Segment() *capnp.Segment { +func (s Process_kill_Params) Segment() *capnp.Segment { return capnp.Struct(s).Segment() } -// Process_stop_Results_List is a list of Process_stop_Results. -type Process_stop_Results_List = capnp.StructList[Process_stop_Results] +// Process_kill_Params_List is a list of Process_kill_Params. +type Process_kill_Params_List = capnp.StructList[Process_kill_Params] -// NewProcess_stop_Results creates a new list of Process_stop_Results. -func NewProcess_stop_Results_List(s *capnp.Segment, sz int32) (Process_stop_Results_List, error) { +// NewProcess_kill_Params creates a new list of Process_kill_Params. +func NewProcess_kill_Params_List(s *capnp.Segment, sz int32) (Process_kill_Params_List, error) { l, err := capnp.NewCompositeList(s, capnp.ObjectSize{DataSize: 0, PointerCount: 0}, sz) - return capnp.StructList[Process_stop_Results](l), err + return capnp.StructList[Process_kill_Params](l), err } -// Process_stop_Results_Future is a wrapper for a Process_stop_Results promised by a client call. -type Process_stop_Results_Future struct{ *capnp.Future } +// Process_kill_Params_Future is a wrapper for a Process_kill_Params promised by a client call. +type Process_kill_Params_Future struct{ *capnp.Future } -func (f Process_stop_Results_Future) Struct() (Process_stop_Results, error) { +func (f Process_kill_Params_Future) Struct() (Process_kill_Params, error) { p, err := f.Future.Ptr() - return Process_stop_Results(p.Struct()), err + return Process_kill_Params(p.Struct()), err } -type Process_wait_Params capnp.Struct +type Process_kill_Results capnp.Struct -// Process_wait_Params_TypeID is the unique identifier for the type Process_wait_Params. -const Process_wait_Params_TypeID = 0xd22f75df06c187e8 +// Process_kill_Results_TypeID is the unique identifier for the type Process_kill_Results. +const Process_kill_Results_TypeID = 0xc53168b273d497ee -func NewProcess_wait_Params(s *capnp.Segment) (Process_wait_Params, error) { +func NewProcess_kill_Results(s *capnp.Segment) (Process_kill_Results, error) { st, err := capnp.NewStruct(s, capnp.ObjectSize{DataSize: 0, PointerCount: 0}) - return Process_wait_Params(st), err + return Process_kill_Results(st), err } -func NewRootProcess_wait_Params(s *capnp.Segment) (Process_wait_Params, error) { +func NewRootProcess_kill_Results(s *capnp.Segment) (Process_kill_Results, error) { st, err := capnp.NewRootStruct(s, capnp.ObjectSize{DataSize: 0, PointerCount: 0}) - return Process_wait_Params(st), err + return Process_kill_Results(st), err } -func ReadRootProcess_wait_Params(msg *capnp.Message) (Process_wait_Params, error) { +func ReadRootProcess_kill_Results(msg *capnp.Message) (Process_kill_Results, error) { root, err := msg.Root() - return Process_wait_Params(root.Struct()), err + return Process_kill_Results(root.Struct()), err } -func (s Process_wait_Params) String() string { - str, _ := text.Marshal(0xd22f75df06c187e8, capnp.Struct(s)) +func (s Process_kill_Results) String() string { + str, _ := text.Marshal(0xc53168b273d497ee, capnp.Struct(s)) return str } -func (s Process_wait_Params) EncodeAsPtr(seg *capnp.Segment) capnp.Ptr { +func (s Process_kill_Results) EncodeAsPtr(seg *capnp.Segment) capnp.Ptr { return capnp.Struct(s).EncodeAsPtr(seg) } -func (Process_wait_Params) DecodeFromPtr(p capnp.Ptr) Process_wait_Params { - return Process_wait_Params(capnp.Struct{}.DecodeFromPtr(p)) +func (Process_kill_Results) DecodeFromPtr(p capnp.Ptr) Process_kill_Results { + return Process_kill_Results(capnp.Struct{}.DecodeFromPtr(p)) } -func (s Process_wait_Params) ToPtr() capnp.Ptr { +func (s Process_kill_Results) ToPtr() capnp.Ptr { return capnp.Struct(s).ToPtr() } -func (s Process_wait_Params) IsValid() bool { +func (s Process_kill_Results) IsValid() bool { return capnp.Struct(s).IsValid() } -func (s Process_wait_Params) Message() *capnp.Message { +func (s Process_kill_Results) Message() *capnp.Message { return capnp.Struct(s).Message() } -func (s Process_wait_Params) Segment() *capnp.Segment { +func (s Process_kill_Results) Segment() *capnp.Segment { return capnp.Struct(s).Segment() } -// Process_wait_Params_List is a list of Process_wait_Params. -type Process_wait_Params_List = capnp.StructList[Process_wait_Params] +// Process_kill_Results_List is a list of Process_kill_Results. +type Process_kill_Results_List = capnp.StructList[Process_kill_Results] -// NewProcess_wait_Params creates a new list of Process_wait_Params. -func NewProcess_wait_Params_List(s *capnp.Segment, sz int32) (Process_wait_Params_List, error) { +// NewProcess_kill_Results creates a new list of Process_kill_Results. +func NewProcess_kill_Results_List(s *capnp.Segment, sz int32) (Process_kill_Results_List, error) { l, err := capnp.NewCompositeList(s, capnp.ObjectSize{DataSize: 0, PointerCount: 0}, sz) - return capnp.StructList[Process_wait_Params](l), err + return capnp.StructList[Process_kill_Results](l), err } -// Process_wait_Params_Future is a wrapper for a Process_wait_Params promised by a client call. -type Process_wait_Params_Future struct{ *capnp.Future } +// Process_kill_Results_Future is a wrapper for a Process_kill_Results promised by a client call. +type Process_kill_Results_Future struct{ *capnp.Future } -func (f Process_wait_Params_Future) Struct() (Process_wait_Params, error) { +func (f Process_kill_Results_Future) Struct() (Process_kill_Results, error) { p, err := f.Future.Ptr() - return Process_wait_Params(p.Struct()), err -} - -type Process_wait_Results capnp.Struct - -// Process_wait_Results_TypeID is the unique identifier for the type Process_wait_Results. -const Process_wait_Results_TypeID = 0x9d6074459fa0602b - -func NewProcess_wait_Results(s *capnp.Segment) (Process_wait_Results, error) { - st, err := capnp.NewStruct(s, capnp.ObjectSize{DataSize: 8, PointerCount: 0}) - return Process_wait_Results(st), err -} - -func NewRootProcess_wait_Results(s *capnp.Segment) (Process_wait_Results, error) { - st, err := capnp.NewRootStruct(s, capnp.ObjectSize{DataSize: 8, PointerCount: 0}) - return Process_wait_Results(st), err -} - -func ReadRootProcess_wait_Results(msg *capnp.Message) (Process_wait_Results, error) { - root, err := msg.Root() - return Process_wait_Results(root.Struct()), err -} - -func (s Process_wait_Results) String() string { - str, _ := text.Marshal(0x9d6074459fa0602b, capnp.Struct(s)) - return str -} - -func (s Process_wait_Results) EncodeAsPtr(seg *capnp.Segment) capnp.Ptr { - return capnp.Struct(s).EncodeAsPtr(seg) -} - -func (Process_wait_Results) DecodeFromPtr(p capnp.Ptr) Process_wait_Results { - return Process_wait_Results(capnp.Struct{}.DecodeFromPtr(p)) -} - -func (s Process_wait_Results) ToPtr() capnp.Ptr { - return capnp.Struct(s).ToPtr() -} -func (s Process_wait_Results) IsValid() bool { - return capnp.Struct(s).IsValid() -} - -func (s Process_wait_Results) Message() *capnp.Message { - return capnp.Struct(s).Message() -} - -func (s Process_wait_Results) Segment() *capnp.Segment { - return capnp.Struct(s).Segment() -} -func (s Process_wait_Results) ExitCode() uint32 { - return capnp.Struct(s).Uint32(0) -} - -func (s Process_wait_Results) SetExitCode(v uint32) { - capnp.Struct(s).SetUint32(0, v) -} - -// Process_wait_Results_List is a list of Process_wait_Results. -type Process_wait_Results_List = capnp.StructList[Process_wait_Results] - -// NewProcess_wait_Results creates a new list of Process_wait_Results. -func NewProcess_wait_Results_List(s *capnp.Segment, sz int32) (Process_wait_Results_List, error) { - l, err := capnp.NewCompositeList(s, capnp.ObjectSize{DataSize: 8, PointerCount: 0}, sz) - return capnp.StructList[Process_wait_Results](l), err -} - -// Process_wait_Results_Future is a wrapper for a Process_wait_Results promised by a client call. -type Process_wait_Results_Future struct{ *capnp.Future } - -func (f Process_wait_Results_Future) Struct() (Process_wait_Results, error) { - p, err := f.Future.Ptr() - return Process_wait_Results(p.Struct()), err -} - -const schema_9a51e53177277763 = "x\xda|\x92Oh\x13M\x18\xc6\xdfgf\xd3\x0d|" + - "\xc9W\xa6[\xab\xf6R\xac\x15\xb5\xd26\xb1\x1eT\x94" + - "\x06%\x14zq\xc7\x9b\x82\xd25.\x18h\x93\xb8\x7f" + - "H{\x10\xe9A\xc4\xa3\x8a\x88\x8aX\x0fR\x05\xd1R" + - "\xbdX\xf1\xe0\xa1x\x95\xa8\x14\xf4 (\x82\x08\x16\xf1" + - "\xe6ie6\xd95\xad\xa6\xb7\x19\xdew\x9e\xf7y\x7f" + - "\xf3dF\x90\xd3\xb2\xe9e\x8d\x98\xdc\x9bh\x0bv\x8d" + - "\xcf\xde\xc9{\xe3\xb7Iv\x01D\x9aN4,Y7" + - "\x08\xc616B\x08j\xfe\xcc\xbd\xc5\x93\x83\x8fI\xfc" + - "\xcf\x83Bu{5\xfbE\xde$\x82q\x8e-\x1a\x17" + - "\x98Nd\xcc\xb0Q\xe3\x81:\x05\xb7^\xd7\xe6\xe6\xbb" + - "\x8e<'\xb1\x11D\x09(\xb5\xcb\xac_\xa9\xdd\x08\xd5" + - "V\xae\xbfu\x17\xced\x97HtE\xd3\x9e\xa9iZ" + - "\xf0\xf5\xe2\xcb\xb6\x8f\xfeP\xad\xa9r\x97u\xa8\xca\xc3" + - "\xd1L\xdf\xec\xd3\xfe\xe5\xa6\xca%\xd6\xab*\xc3m\xdb" + - "\xee\xbf\xf9\xb1\xf5\xfd_\xde\xce\xb2\x05c:\xf4\xe6\xb3" + - "W\xc6\xf7\xd0\xdb\xe8\x89\xa1\xf9\xcd\x8f\xe6V\x9ad\xde" + - "\xd5\x07t\\\xbdr\xed\xdb\xc1\xff~6\\\xab\xee\xe1" + - "\x17j\x02\x8c%V%\x04\x9f\x9f|H~\x1a+\xfe" + - "jz:\xc0\xbbA\x99\xa0\xe2\x94\x0b\xb6\xeb\x0e\xf2\x82" + - "U)U\xf6\x9b\x8dk\xd5*z}Gm\xd7\x9f\xe0" + - "\x9e+5\xae\x11i \x12\xe91\"\x99\xe2\x90\x9b\x18" + - "\x02{\xaa\xe8\x1d.\x9f\xb6\x89\x08IbH\x12b=" + - "\xd4\xf5\xf2S#v\xc1\xf7\xca\x8e\x09H\x8d'\x88b" + - "\xb3\x88X\x0b\xb1\x9b\x98H\xe8=n\xc5\xaa\x96r0" + - "\x81\xb5\xb6\xf2Su\x95\xc1\xb0E\x19k\xf7'V\x1b" + - ";D$\x93\x1c\xb2\x93\xe1|\xe35\xc4\x1f\xc0\x04\x08" + - "B\xabu]\xaf\\\x89\xd7]\x97\x89i9\xd6$\xdc" + - "\xd6B\x96S\x07\xa7O4)!\xea\xea\x09\xef\x0aF" + - "*\x84\x11}\x0c\xa2\x8c\x08\xa9`\xe4u \xfeoD" + - "\x99\x13\xfb\xfa\x89\x89\x01\x1d,\x0e\x1b\xa2\xf8\x8b-\xaa" + - "\xb6A\xef\x09\x1d\xe4\xd0\xaeV\xca\xa1]\x99\xfe'\xd2" + - "U\xab\xb7\xd8j\x0dv\xd3rtk\xd2\x95\xc9\x98\xfa" + - "N\x15\x87\x1d\x1cr\x0f\x83\x00:\x01@d\x8f\x13\xc9" + - "\x0c\x87<\xc0\x10\x9c\x9a\xf6\xec(#ibH\x13\x02" + - "\xbb\xe49\xd3f\xb9H\xbc\xe4!E\x0c)\"\x81^" + - "\xdd\xf1K\xebsU6\xf9\xa4\xfb;\x00\x00\xff\xff\xdc" + - "a-[" + return Process_kill_Results(p.Struct()), err +} + +const schema_9a51e53177277763 = "x\xda|\x921h\x13Q\x18\xc7\xff\xffw/\xbd\x03" + + "=\xc3\xebi\xb4\x82\x08\xdaP\xe8\x10\x13\x8a\x8b \x0d" + + "\x8a\x04\x0bb\x9e\xbbB<\x0f\x0c&&\xe4.$N" + + "\xe2 \xee\x8a\x88\x8a\xe0\"u\x10-\xd5\xa9\xce\xeeR" + + "\x05A7\xc5\xc5\xa1\x88[\x079y\xd7\\<\xa9\xe9" + + "v\x8f\xef\xfb\xfe\xff\xff\xf7\xfb\xae,Y\x95\x15wN" + + "B\xe8rn*^\xef\xdfz\xb6v\xa9\xf4\x0aj\x8f" + + "\x15\xfb\x83\xb9A\xe5\xbb~\x04\xd0\xdb\xe4\x9aGa\x03" + + "\xdeo\xd6\xbc\xa2\xf9\x8a\x1f\xbf__^)\x9c\x7f\x0b" + + "\xb5\x9f@\x8e6\xb0\xe0\x8a#\x04\xbd}b\x11\x8c7" + + "\x1e|\x0cW\xafV\xdeA\x15\x08HS?.\x0e\x12" + + "2~Q+\xcf>}3\xff\x09\xba\xc0\xb4t\xc8\x94" + + "\xe8\x15\x93\xd1\x85\xa9\xe2\xf3\x0f?\x8f~\xde\x16\xe4\xac" + + "X\xf5t\x12\xe4\x9c\xb8\xe3=I\x82\xd4.\x1e[\x99" + + "y\xb9\xbc\x91\xf1\xb9-\xa6\x8d\xcf\xf4\xbd\xbb\xf7\x7f\x9c" + + "\xdc\xf5+\x1b\xb1\xbd\xe5\xd3O|\xbe\xbd\xfe\xe2|]" + + "jnfF\x1f\x9a\xd1r\xdc\xedu\xfc \x0cK\xf4" + + "\x1b\xdd\xeb\xdd\x13g\x86\x8b\x81\xdf\x8f:\xbd:\xa9\xa5" + + "\x95\x03\xc6\xe2LA(5\x0f\xa1rv>\x18\x06~" + + "\x95ur\xacb\xa5*[\"%\xd31{!\x08\xfb" + + "v+\x0a\xb5\xb4$ \x09(\xf7\x14\xa0\x1d\x8bz\xaf" + + "\xe0\xcd\xd10\xd5_\x1c \x15\xb6\xc9\xd6G\xcfk\xcd" + + "V+QmYQ8\xa9i\xd0hF\xe3\xa6\xac\xf5" + + "\x12\xa0w[\xd4\x07\x04\xe3`\xd8\x8cNw\xae\x04\x00" + + "\xe8@\xd0\xc9\x982\xd5;\x9c\xbc\x0d\x10'\x01\x92\xc2" + + "dz^U1@\x8a69\xbe\x11\xd3\x9fB\xcd\x98" + + "\x9ak\xe7M\x9e*\xf3&\xfb\x7f\x99\xfd\xb3\\\xbd\xd1" + + "k\xb4\x19\xee\xcc\xd54Y\xed\x89\xbb]\xbe\x11\x05\xfe" + + "h7\x17\x82\xeed\xa0\x09\xab\x91\xe7\x9f\x00\x00\x00\xff" + + "\xff8\xaa\xe7q" func RegisterSchema(reg *schemas.Registry) { reg.Register(&schemas.Schema{ String: schema_9a51e53177277763, Nodes: []uint64{ - 0x9d6074459fa0602b, 0xaf2e5ebaa58175d2, 0xbb4f16b0a7d2d09b, 0xc53168b273d497ee, - 0xd22f75df06c187e8, 0xd72ab4a0243047ac, 0xda23f0d3a8250633, 0xeea7ae19b02f5d47, diff --git a/internal/cmd/cluster/process.go b/internal/cmd/cluster/process.go index 9c82edc4..243aa2b5 100644 --- a/internal/cmd/cluster/process.go +++ b/internal/cmd/cluster/process.go @@ -32,14 +32,9 @@ func runAction() cli.ActionFunc { executor, release := node.Executor(ctx) defer release() - proc, release := executor.Spawn(ctx, src) + proc, release := executor.Exec(ctx, src) defer release() - if err := proc.Start(ctx); err != nil { - return err - } - defer proc.Stop(ctx) - return proc.Wait(ctx) } } diff --git a/internal/cmd/run/run.go b/internal/cmd/run/run.go new file mode 100644 index 00000000..9b83df95 --- /dev/null +++ b/internal/cmd/run/run.go @@ -0,0 +1,78 @@ +package run + +import ( + "crypto/rand" + "errors" + "io" + "os" + + "github.com/stealthrocket/wazergo" + "github.com/tetratelabs/wazero" + "github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1" + "github.com/urfave/cli/v2" + "github.com/wetware/ww/pkg/csp/proc" +) + +func Command() *cli.Command { + return &cli.Command{ + Name: "run", + Usage: "execute a local webassembly process", + Before: setup(), + After: teardown(), + Action: run(), + } +} + +var ( + r wazero.Runtime + h *wazergo.ModuleInstance[*proc.Module] +) + +func setup() cli.BeforeFunc { + return func(c *cli.Context) error { + r = wazero.NewRuntime(c.Context) + h = proc.BindModule(c.Context, r) + wasi_snapshot_preview1.MustInstantiate(c.Context, r) + return nil + } +} + +func teardown() cli.AfterFunc { + return func(c *cli.Context) error { + return r.Close(c.Context) + } +} + +func run() cli.ActionFunc { + return func(c *cli.Context) error { + b, err := bytecode(c) + if err != nil { + return err + } + + module, err := r.InstantiateWithConfig(c.Context, b, wazero.NewModuleConfig(). + WithRandSource(rand.Reader). + WithStartFunctions(). // disable auto-calling of _start + WithStdout(c.App.Writer). + WithStderr(c.App.ErrWriter)) + if err != nil { + return err + } + + fn := module.ExportedFunction("_start") + if fn == nil { + return errors.New("ww: missing export: _start") + } + + _, err = fn.Call(wazergo.WithModuleInstance(c.Context, h)) + return err + } +} + +func bytecode(c *cli.Context) ([]byte, error) { + if c.Args().Len() > 0 { + return os.ReadFile(c.Args().First()) // file path + } + + return io.ReadAll(c.App.Reader) // stdin +} diff --git a/pkg/csp/executor.go b/pkg/csp/executor.go index b9b0c94f..b5243217 100644 --- a/pkg/csp/executor.go +++ b/pkg/csp/executor.go @@ -4,14 +4,16 @@ import ( "context" "crypto/rand" "encoding/hex" - "fmt" + "errors" capnp "capnproto.org/go/capnp/v3" + "github.com/stealthrocket/wazergo" "github.com/tetratelabs/wazero" "lukechampine.com/blake3" wasm "github.com/tetratelabs/wazero/api" api "github.com/wetware/ww/internal/api/process" + "github.com/wetware/ww/pkg/csp/proc" ) // ByteCode is a representation of arbitrary executable data. @@ -39,79 +41,98 @@ func (ex Executor) Release() { capnp.Client(ex).Release() } -func (ex Executor) Spawn(ctx context.Context, src []byte) (Proc, capnp.ReleaseFunc) { - f, release := api.Executor(ex).Spawn(ctx, func(ps api.Executor_spawn_Params) error { - return ps.SetByteCode(src) +func (ex Executor) Exec(ctx context.Context, src []byte) (Proc, capnp.ReleaseFunc) { + f, release := api.Executor(ex).Exec(ctx, func(ps api.Executor_exec_Params) error { + return ps.SetBytecode(src) }) return Proc(f.Process()), release } -// Server is the main Executor implementation. It spawns WebAssembly- -// based processes. The zero-value Server panics. -type Server struct { - Runtime wazero.Runtime +// Runtime is the main Executor implementation. It spawns WebAssembly- +// based processes. The zero-value Runtime panics. +type Runtime struct { + Runtime wazero.Runtime + HostModule *wazergo.ModuleInstance[*proc.Module] } // Executor provides the Executor capability. -func (wx Server) Executor() Executor { - return Executor(api.Executor_ServerToClient(wx)) +func (r Runtime) Executor() Executor { + return Executor(api.Executor_ServerToClient(r)) } -// Spawn a process by creating a process server and converting it into -// a capability as a response to the call. -func (wx Server) Spawn(ctx context.Context, call api.Executor_spawn) error { +func (r Runtime) Exec(ctx context.Context, call api.Executor_exec) error { res, err := call.AllocResults() if err != nil { return err } - mod, err := wx.loadModule(ctx, call.Args()) + p, err := r.mkproc(ctx, call.Args()) if err != nil { return err } - p, err := wx.mkproc(ctx, mod, call.Args()) - if err == nil { - err = res.SetProcess(api.Process_ServerToClient(p)) - } - - return err + return res.SetProcess(api.Process_ServerToClient(p)) } -func (wx Server) mkproc(ctx context.Context, mod wasm.Module, args api.Executor_spawn_Params) (*process, error) { - name, err := args.EntryPoint() +func (r Runtime) mkproc(ctx context.Context, args api.Executor_exec_Params) (*process, error) { + mod, err := r.mkmod(ctx, args) if err != nil { return nil, err } - var proc process - if proc.fn = mod.ExportedFunction(name); proc.fn == nil { - err = fmt.Errorf("module %s: %s not found", mod.Name(), name) + fn := mod.ExportedFunction("_start") + if fn == nil { + return nil, errors.New("ww: missing export: _start") } - return &proc, err + done, cancel := r.spawn(fn) + return &process{ + done: done, + cancel: cancel, + }, nil } -func (wx Server) loadModule(ctx context.Context, args api.Executor_spawn_Params) (wasm.Module, error) { - bc, err := args.ByteCode() +func (r Runtime) mkmod(ctx context.Context, args api.Executor_exec_Params) (wasm.Module, error) { + bc, err := args.Bytecode() if err != nil { return nil, err } name := ByteCode(bc).String() - config := wazero. - NewModuleConfig(). - WithName(name). - WithRandSource(rand.Reader) - if mod := wx.Runtime.Module(name); mod != nil { - return mod, nil - } - - module, err := wx.Runtime.CompileModule(ctx, bc) + // TODO(perf): cache compiled modules so that we can instantiate module + // instances for concurrent use. + module, err := r.Runtime.CompileModule(ctx, bc) if err != nil { return nil, err } - return wx.Runtime.InstantiateModule(ctx, module, config) + return r.Runtime.InstantiateModule(ctx, module, wazero. + NewModuleConfig(). + WithName(name). + WithStartFunctions(). // disable automatic calling of _start (main) + WithRandSource(rand.Reader)) +} + +func (r Runtime) spawn(fn wasm.Function) (<-chan execResult, context.CancelFunc) { + out := make(chan execResult, 1) + + // NOTE: we use the runtime context rather than the context passed into the + // rpc handler. This ensures that a process can continue to run after + // the rpc handler has returned. Note also that this context is bound + // to the application lifetime, so processes cannot block a shutdown. + ctx, cancel := context.WithCancel(context.Background()) + + go func() { + defer close(out) + defer cancel() + + vs, err := fn.Call(wazergo.WithModuleInstance(ctx, r.HostModule)) + out <- execResult{ + Values: vs, + Err: err, + } + }() + + return out, cancel } diff --git a/pkg/csp/executor_test.go b/pkg/csp/executor_test.go index 4e30b28c..153992a4 100644 --- a/pkg/csp/executor_test.go +++ b/pkg/csp/executor_test.go @@ -1,46 +1,46 @@ package csp_test -import ( - "context" - "os" - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - "github.com/tetratelabs/wazero" - "github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1" - "github.com/tetratelabs/wazero/sys" - "github.com/wetware/ww/pkg/csp" -) - -func TestExecutor(t *testing.T) { - t.Parallel() - - r := wazero.NewRuntime(context.Background()) - wasi_snapshot_preview1.MustInstantiate(context.Background(), r) - - exec := csp.Server{Runtime: r}.Executor() - defer exec.Release() - - proc, release := exec.Spawn(context.Background(), testdata()) - defer release() - - err := proc.Start(context.Background()) - require.NoError(t, err, "should start process") - - err = proc.Wait(context.Background()) - require.Error(t, err, "should return an error from process") - - ee, ok := err.(*sys.ExitError) - require.True(t, ok, "should return sys.ExitError") - assert.Equal(t, uint32(99), ee.ExitCode()) -} - -func testdata() []byte { - b, err := os.ReadFile("testdata/main.wasm") - if err != nil { - panic(err) - } - - return b -} +// import ( +// "context" +// "os" +// "testing" + +// "github.com/stretchr/testify/assert" +// "github.com/stretchr/testify/require" +// "github.com/tetratelabs/wazero" +// "github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1" +// "github.com/tetratelabs/wazero/sys" +// "github.com/wetware/ww/pkg/csp" +// ) + +// func TestExecutor(t *testing.T) { +// t.Parallel() + +// r := wazero.NewRuntime(context.Background()) +// wasi_snapshot_preview1.MustInstantiate(context.Background(), r) + +// exec := csp.Runtime{Runtime: r}.Executor() +// defer exec.Release() + +// proc, release := exec.Spawn(context.Background(), testdata()) +// defer release() + +// err := proc.Start(context.Background()) +// require.NoError(t, err, "should start process") + +// err = proc.Wait(context.Background()) +// require.Error(t, err, "should return an error from process") + +// ee, ok := err.(*sys.ExitError) +// require.True(t, ok, "should return sys.ExitError") +// assert.Equal(t, uint32(99), ee.ExitCode()) +// } + +// func testdata() []byte { +// b, err := os.ReadFile("testdata/main.wasm") +// if err != nil { +// panic(err) +// } + +// return b +// } diff --git a/pkg/csp/proc.go b/pkg/csp/proc.go index 1cab4271..f1e270d2 100644 --- a/pkg/csp/proc.go +++ b/pkg/csp/proc.go @@ -3,10 +3,8 @@ package csp import ( "context" "errors" - "sync/atomic" capnp "capnproto.org/go/capnp/v3" - wasm "github.com/tetratelabs/wazero/api" "github.com/tetratelabs/wazero/sys" casm "github.com/wetware/casm/pkg" @@ -26,18 +24,10 @@ func (p Proc) AddRef() Proc { func (p Proc) Release() { capnp.Client(p).Release() - -} - -func (p Proc) Start(ctx context.Context) error { - f, release := api.Process(p).Start(ctx, nil) - defer release() - - return casm.Future(f).Await(ctx) } -func (p Proc) Stop(ctx context.Context) error { - f, release := api.Process(p).Stop(ctx, nil) +func (p Proc) Kill(ctx context.Context) error { + f, release := api.Process(p).Kill(ctx, nil) defer release() return casm.Future(f).Await(ctx) @@ -61,110 +51,36 @@ func (p Proc) Wait(ctx context.Context) error { // process is the main implementation of the Process capability. type process struct { - fn wasm.Function - handle procHandle -} - -// Stop calls the runtime cancellation function. -func (p *process) Stop(context.Context, api.Process_stop) error { - state := p.handle.Load() - if state.Err == nil { - state.Cancel() - } - - return state.Err + done <-chan execResult + cancel context.CancelFunc + result execResult } -// Start the process in the background. -func (p *process) Start(_ context.Context, call api.Process_start) error { - state := p.handle.Load() - if state.Err != ErrNotStarted { - return state.Err - } - - p.handle.Exec(p.fn) +func (p process) Kill(context.Context, api.Process_kill) error { + p.cancel() return nil } -// Wait for the process to finish running. func (p *process) Wait(ctx context.Context, call api.Process_wait) error { - state := p.handle.Load() - if state.Err == ErrNotStarted { - return state.Err - } - - results, err := call.AllocResults() - if err != nil { - return err - } - - call.Go() - select { + case res, ok := <-p.done: + if ok { + p.result = res + } + case <-ctx.Done(): return ctx.Err() - case <-state.Ctx.Done(): - return p.handle.Bind(results) } -} - -// procHandle encapsulates all the runtime state of a process. Its -// methods are safe for concurrent access. -type procHandle atomic.Pointer[state] - -// Exec sets the current state to ErrRunning, calls the function, and -// then sets the current state to the resulting error. -func (as *procHandle) Exec(fn wasm.Function) { - ctx, cancel := context.WithCancel(context.Background()) - - // set "running" state - (*atomic.Pointer[state])(as).Store(&state{ - Ctx: ctx, - Cancel: cancel, - Err: ErrRunning, - }) - - go func() { - defer cancel() - - // block until function call completes - _, err := fn.Call(ctx) - - // call entrypoint function & set "finished" state - (*atomic.Pointer[state])(as).Store(&state{ - Ctx: ctx, - Cancel: cancel, - Err: err, - }) - }() -} -// Bind the error from the entrypoint function to the results struct. -// Callers MUST NOT call Bind until the function has returned. -func (as *procHandle) Bind(res api.Process_wait_Results) error { - if state := as.Load(); state.Err != nil { - code := state.Err.(*sys.ExitError).ExitCode() - res.SetExitCode(code) - } - - return nil -} - -// Load the current state atomically. The resulting resulting state -// defaults to ErrNotStarted. -func (as *procHandle) Load() state { - if s := (*atomic.Pointer[state])(as).Load(); s != nil { - return *s + res, err := call.AllocResults() + if err != nil { + res.SetExitCode(err.(*sys.ExitError).ExitCode()) } - return state{ - Cancel: func() {}, - Err: ErrNotStarted, - } + return err } -type state struct { - Ctx context.Context - Cancel context.CancelFunc +type execResult struct { + Values []uint64 Err error } diff --git a/pkg/csp/proc/proc.go b/pkg/csp/proc/proc.go new file mode 100644 index 00000000..667c8dfb --- /dev/null +++ b/pkg/csp/proc/proc.go @@ -0,0 +1,50 @@ +// Package proc provides the WebAssembly host module for Wetware processes +package proc + +import ( + "context" + + "github.com/stealthrocket/wazergo" + "github.com/stealthrocket/wazergo/types" + wasm "github.com/tetratelabs/wazero" +) + +var fs wazergo.HostModule[*Module] = functions{ + "__test": wazergo.F2((*Module).Add), +} + +// BindModule instantiates a host module instance and binds it to the supplied +// runtime. The returned module instance is bound to the lifetime of r. +func BindModule(ctx context.Context, r wasm.Runtime) *wazergo.ModuleInstance[*Module] { + // We use BindModule to avoid exporting fs as a public variable, since this + // would allow users to mutate it. + return wazergo.MustInstantiate(ctx, r, fs) +} + +type functions wazergo.Functions[*Module] + +func (functions) Name() string { + return "ww" +} + +func (f functions) Functions() wazergo.Functions[*Module] { + return (wazergo.Functions[*Module])(f) +} + +func (f functions) Instantiate(ctx context.Context, opts ...Option) (*Module, error) { + module := &Module{} + wazergo.Configure(module, opts...) + return module, nil +} + +type Option = wazergo.Option[*Module] + +type Module struct{} + +func (m Module) Close(context.Context) error { + return nil +} + +func (m Module) Add(ctx context.Context, a, b types.Uint32) types.Uint32 { + return a + b +} diff --git a/pkg/server/config.go b/pkg/server/config.go index d41105b9..29d46bbf 100644 --- a/pkg/server/config.go +++ b/pkg/server/config.go @@ -13,6 +13,8 @@ import ( "github.com/wetware/casm/pkg/cluster/pulse" "github.com/wetware/casm/pkg/cluster/routing" "github.com/wetware/casm/pkg/debug" + "github.com/wetware/ww/pkg/csp" + "github.com/wetware/ww/pkg/csp/proc" ) type ClusterConfig struct { @@ -65,7 +67,7 @@ type RuntimeConfig struct { Config wazero.RuntimeConfig `optional:"true"` } -func (rc RuntimeConfig) New() wazero.Runtime { +func (rc RuntimeConfig) New() csp.Runtime { if rc.Ctx == nil { rc.Ctx = context.Background() } @@ -76,7 +78,11 @@ func (rc RuntimeConfig) New() wazero.Runtime { r := wazero.NewRuntimeWithConfig(rc.Ctx, rc.Config) wasi_snapshot_preview1.MustInstantiate(rc.Ctx, r) - return r + + return csp.Runtime{ + Runtime: r, + HostModule: proc.BindModule(rc.Ctx, r), + } } type DebugConfig struct { diff --git a/pkg/server/server.go b/pkg/server/server.go index df737fcc..d8e68d03 100644 --- a/pkg/server/server.go +++ b/pkg/server/server.go @@ -11,7 +11,6 @@ import ( casm "github.com/wetware/casm/pkg" "github.com/wetware/casm/pkg/cluster" "github.com/wetware/ww/pkg/anchor" - "github.com/wetware/ww/pkg/csp" "github.com/wetware/ww/pkg/host" "github.com/wetware/ww/pkg/pubsub" ) @@ -71,7 +70,7 @@ func (j Joiner) Join(vat casm.Vat, r Router) (*Node, error) { PubSubProvider: j.pubsub(vat.Logger, r), AnchorProvider: j.anchor(), DebugProvider: j.Debugger.New(), - ExecutorProvider: j.executor(), + ExecutorProvider: j.Runtime.New(), }) return &Node{ @@ -90,9 +89,3 @@ func (j Joiner) pubsub(log log.Logger, router pubsub.TopicJoiner) *pubsub.Server func (j Joiner) anchor() anchor.Server { return anchor.Root() } - -func (j Joiner) executor() csp.Server { - return csp.Server{ - Runtime: j.Runtime.New(), - } -}