Skip to content
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

[rwasm] Call wasm module start before init #130

Merged
merged 4 commits into from
Aug 13, 2021
Merged
Show file tree
Hide file tree
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
20 changes: 18 additions & 2 deletions rwasm/ffi_environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,27 @@ func (w *wasmEnvironment) addInstance() error {
return errors.Wrap(err, "failed to NewInstance")
}

// if the module has exported an init, call it
// if the module has exported a WASI start, call it
wasiStart, err := inst.Exports.GetWasiStartFunction()
if err == nil && wasiStart != nil {
if _, err := wasiStart(); err != nil {
return errors.Wrap(err, "failed to wasiStart")
}
} else {
// if the module has exported a _start function, call it
_start, err := inst.Exports.GetFunction("_start")
if err == nil && _start != nil {
if _, err := _start(); err != nil {
return errors.Wrap(err, "failed to _start")
}
}
}

// if the module has exported an init function, call it
init, err := inst.Exports.GetFunction("init")
if err == nil && init != nil {
if _, err := init(); err != nil {
return errors.Wrap(err, "failed to init instance")
return errors.Wrap(err, "failed to init")
}
}

Expand Down
76 changes: 2 additions & 74 deletions rwasm/testdata/as-echo/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

79 changes: 2 additions & 77 deletions rwasm/testdata/as-fetch/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

79 changes: 2 additions & 77 deletions rwasm/testdata/as-get/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

75 changes: 2 additions & 73 deletions rwasm/testdata/as-graphql/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading