Adds ability to disable mutable globals and improves decode perf (#315)
This adds `RuntimeConfig.WithFeatureMutableGlobal(enabled bool)`, which allows disabling of mutable globals. When disabled, any attempt to add a mutable global, either explicitly or implicitly via decoding wasm will fail. To support this, there's a new `Features` bitflag that can allow up to 63 feature toggles without passing structs. While here, I fixed a significant performance problem in decoding binary: Before ``` BenchmarkCodecExample/binary.DecodeModule-16 184243 5623 ns/op 3848 B/op 184 allocs/op ``` Now ``` BenchmarkCodecExample/binary.DecodeModule-16 294084 3520 ns/op 2176 B/op 91 allocs/op ``` Signed-off-by: Adrian Cole <adrian@tetrate.io>
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
package internalwasm
|
||||
|
||||
import (
|
||||
"context"
|
||||
gobinary "encoding/binary"
|
||||
"testing"
|
||||
|
||||
@@ -257,7 +256,7 @@ func TestPublicModule_Global(t *testing.T) {
|
||||
for _, tt := range tests {
|
||||
tc := tt
|
||||
|
||||
s := NewStore(context.Background(), &catchContext{})
|
||||
s := newStore()
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
// Instantiate the module and get the export of the above global
|
||||
module, err := s.Instantiate(tc.module, "")
|
||||
|
||||
Reference in New Issue
Block a user