Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 26 additions & 3 deletions src/runtime/runtime_wasm_wasip2.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
package runtime

import (
"sync"
"unsafe"

"internal/wasi/cli/v0.2.0/environment"
Expand All @@ -11,12 +12,34 @@ import (

type timeUnit int64

//export wasi:cli/[email protected]#run
func __wasi_cli_run_run() uint32 {
var callInitAll = sync.OnceFunc(initAll)

var initialize = sync.OnceFunc(func() {
// These need to be initialized early so that the heap can be initialized.
heapStart = uintptr(unsafe.Pointer(&heapStartSymbol))
heapEnd = uintptr(wasm_memory_size(0) * wasmPageSize)
run()
initHeap()
})

//export _initialize
func _initialize() {
initialize()
callInitAll()
}

//export wasi:cli/[email protected]#run
func __wasi_cli_run_run() uint32 {
initialize()
if hasScheduler {
go func() {
callInitAll()
callMain()
schedulerDone = true
}()
scheduler()
} else {
callMain()
}
return 0
}

Expand Down
Loading