From 53aaa56ce8ccd753bbd8c8547e5e54513fe84f05 Mon Sep 17 00:00:00 2001 From: Diego <96022404+dzfrias@users.noreply.github.com> Date: Sun, 16 Jun 2024 07:07:20 -0700 Subject: [PATCH] LibWasm: Add missing spec extern and prevent spec extern re-use Add the missing `print` function to the spectest namespace. Also, spec externs cannot be re-used because operations that modify "memory", for example, will carry over into subsequent spec test runs. This can be remedied in the future by implementing some sort of garbage collector for allocations in the store. (cherry picked from commit 1e19be412f17f99e5c3979ccf790c3ca90d637d6) --- Tests/LibWasm/test-wasm.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Tests/LibWasm/test-wasm.cpp b/Tests/LibWasm/test-wasm.cpp index d524239ebf..1584c2db40 100644 --- a/Tests/LibWasm/test-wasm.cpp +++ b/Tests/LibWasm/test-wasm.cpp @@ -80,8 +80,9 @@ private: static HashMap const& spec_test_namespace() { - if (!s_spec_test_namespace.is_empty()) - return s_spec_test_namespace; + Wasm::FunctionType print_type { {}, {} }; + auto address_print = alloc_noop_function(print_type); + s_spec_test_namespace.set({ "spectest", "print", print_type }, Wasm::ExternValue { *address_print }); Wasm::FunctionType print_i32_type { { Wasm::ValueType(Wasm::ValueType::I32) }, {} }; auto address_i32 = alloc_noop_function(print_i32_type);