Opt-in support for sign-extend (#339)

Allows users to do the following to enable sign-extension-ops:

```
r := wazero.NewRuntimeWithConfig(wazero.NewRuntimeConfig().WithFeatureSignExtensionOps(true))
```

Resolves #66

Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
Co-authored-by: Adrian Cole <adrian@tetrate.io>
This commit is contained in:
Takeshi Yoneda
2022-03-07 15:08:57 +09:00
committed by GitHub
parent cd52f18323
commit c6426160c2
23 changed files with 907 additions and 34 deletions

View File

@@ -62,6 +62,15 @@ func (r *RuntimeConfig) WithFeatureMutableGlobal(enabled bool) *RuntimeConfig {
return &RuntimeConfig{engine: r.engine, ctx: r.ctx, enabledFeatures: enabledFeatures}
}
// WithFeatureSignExtensionOps enables sign-extend operations. This defaults to false as the feature was not finished in
// WebAssembly 1.0 (20191205).
//
// See https://github.com/WebAssembly/spec/blob/main/proposals/sign-extension-ops/Overview.md
func (r *RuntimeConfig) WithFeatureSignExtensionOps(enabled bool) *RuntimeConfig {
enabledFeatures := r.enabledFeatures.Set(internalwasm.FeatureSignExtensionOps, enabled)
return &RuntimeConfig{engine: r.engine, ctx: r.ctx, enabledFeatures: enabledFeatures}
}
// DecodedModule is a WebAssembly 1.0 (20191205) text or binary encoded module to instantiate.
type DecodedModule struct {
name string