From 7f1a7197f32364cf9020fe1ed9d40f4f16a80739 Mon Sep 17 00:00:00 2001 From: Xe Iaso Date: Tue, 30 Sep 2025 14:39:56 +0000 Subject: [PATCH] fix(wasm): use interpreter on aarch64 for now Signed-off-by: Xe Iaso --- wasm/wasm.go | 14 +++++++++++++- wasm/wasm_test.go | 8 ++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/wasm/wasm.go b/wasm/wasm.go index 9a5d9058..fe6a27a5 100644 --- a/wasm/wasm.go +++ b/wasm/wasm.go @@ -7,6 +7,7 @@ import ( "io" "math" "os" + "runtime" "strconv" "sync" "time" @@ -45,7 +46,18 @@ func NewRunner(ctx context.Context, fname string, fin io.ReadCloser) (*Runner, e return nil, fmt.Errorf("wasm: can't read from fin: %w", err) } - r := wazero.NewRuntime(ctx) + var cfg wazero.RuntimeConfig + + switch runtime.GOARCH { + case "amd64": + cfg = wazero.NewRuntimeConfigCompiler() + default: + cfg = wazero.NewRuntimeConfigInterpreter() + } + + cfg = cfg.WithMemoryLimitPages(512) + + r := wazero.NewRuntimeWithConfig(ctx, cfg) _, err = r.NewHostModuleBuilder("anubis"). NewFunctionBuilder(). diff --git a/wasm/wasm_test.go b/wasm/wasm_test.go index f1409f3f..03639ae9 100644 --- a/wasm/wasm_test.go +++ b/wasm/wasm_test.go @@ -5,6 +5,7 @@ import ( "crypto/sha256" "fmt" "io/fs" + "path/filepath" "testing" "time" @@ -58,6 +59,9 @@ func TestAlgos(t *testing.T) { for _, kind := range []string{"baseline", "simd128"} { for _, fname := range fnames { + if filepath.Ext(fname.Name()) != ".wasm" { + continue + } t.Run(kind+"/"+fname.Name(), func(t *testing.T) { abiTest(t, kind, fname.Name(), 16) }) @@ -139,6 +143,10 @@ func BenchmarkValidate(b *testing.B) { difficulty = 16 } + if filepath.Ext(fname) != ".wasm" { + continue + } + b.Run(fname, func(b *testing.B) { fin, err := web.Static.Open("static/wasm/simd128/" + fname) if err != nil {