Skip to content

Commit

Permalink
fix(wasip2): export _initialize
Browse files Browse the repository at this point in the history
Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
  • Loading branch information
rvolosatovs committed Oct 2, 2024
1 parent 9d14489 commit e3e59dd
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 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,31 @@ import (

type timeUnit int64

//export wasi:cli/run@0.2.0#run
func __wasi_cli_run_run() uint32 {
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()
initAll()
})

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

//export wasi:cli/run@0.2.0#run
func __wasi_cli_run_run() uint32 {
initialize()
if hasScheduler {
go func() {
callMain()
schedulerDone = true
}()
scheduler()
} else {
callMain()
}
return 0
}

Expand Down

0 comments on commit e3e59dd

Please sign in to comment.