Skip to content

fix(wasip2): export _initialize #4490

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
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
@@ -3,6 +3,7 @@
package runtime

import (
"sync"
"unsafe"

"internal/wasi/cli/v0.2.0/environment"
@@ -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
}