File tree Expand file tree Collapse file tree 1 file changed +26
-3
lines changed
Expand file tree Collapse file tree 1 file changed +26
-3
lines changed Original file line number Diff line number Diff line change 33package runtime
44
55import (
6+ "sync"
67 "unsafe"
78
89 "internal/wasi/cli/v0.2.0/environment"
@@ -11,12 +12,34 @@ import (
1112
1213type timeUnit int64
1314
14- //export wasi:cli/run@0.2.0#run
15- func __wasi_cli_run_run () uint32 {
15+ var callInitAll = sync .OnceFunc (initAll )
16+
17+ var initialize = sync .OnceFunc (func () {
1618 // These need to be initialized early so that the heap can be initialized.
1719 heapStart = uintptr (unsafe .Pointer (& heapStartSymbol ))
1820 heapEnd = uintptr (wasm_memory_size (0 ) * wasmPageSize )
19- run ()
21+ initHeap ()
22+ })
23+
24+ //export _initialize
25+ func _initialize () {
26+ initialize ()
27+ callInitAll ()
28+ }
29+
30+ //export wasi:cli/run@0.2.0#run
31+ func __wasi_cli_run_run () uint32 {
32+ initialize ()
33+ if hasScheduler {
34+ go func () {
35+ callInitAll ()
36+ callMain ()
37+ schedulerDone = true
38+ }()
39+ scheduler ()
40+ } else {
41+ callMain ()
42+ }
2043 return 0
2144}
2245
You can’t perform that action at this time.
0 commit comments