examples/terminate: Use wasm_runtime_spawn_exec_env as well (#3049)

This commit is contained in:
YAMAMOTO Takashi
2024-01-18 21:44:09 +09:00
committed by GitHub
parent b97370e3a8
commit fde98331ff
3 changed files with 75 additions and 7 deletions

View File

@ -3,7 +3,7 @@
(module
(func $fd_read (import "wasi_snapshot_preview1" "fd_read") (param i32 i32 i32 i32) (result i32))
(func (export "_start")
(func $block_forever (export "block_forever")
;; read from FD 0
i32.const 100 ;; iov_base
i32.const 200 ;; buffer
@ -18,5 +18,36 @@
call $fd_read
unreachable
)
(func (export "_start")
call $block_forever
)
;; a dumb malloc/free implementation
(func (export "malloc") (param i32) (result i32)
local.get 0
i32.const 65535
i32.add
i32.const 65536
i32.div_u
memory.grow
local.set 0
local.get 0
i32.const -1
i32.eq
if
i32.const 0
return
end
local.get 0
i32.const 65536
i32.mul
)
(func (export "free") (param i32))
(memory (export "memory") 1)
;; fake globals to make wasm_set_aux_stack happy
(global (export "__heap_base") i32 (i32.const 0x10000))
(global (export "__data_end") i32 (i32.const 0x10000))
(global (mut i32) (i32.const 0x10000))
)