From 522d7b4741842106f17e52a19231e8050af9dc37 Mon Sep 17 00:00:00 2001 From: Jeroen Bobbeldijk Date: Fri, 19 Jul 2024 13:58:02 +0200 Subject: [PATCH 1/2] Add support for Emscripten 3.1.57 Signed-off-by: Jeroen Bobbeldijk --- internal/emscripten/emscripten.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/emscripten/emscripten.go b/internal/emscripten/emscripten.go index 4492df58c7..9606f26b58 100644 --- a/internal/emscripten/emscripten.go +++ b/internal/emscripten/emscripten.go @@ -110,21 +110,21 @@ func (v *InvokeFunc) Call(ctx context.Context, mod api.Module, stack []uint64) { // indirection function calls in Emscripten JS is like this: // // function invoke_iii(index,a1,a2) { - // var sp = stackSave(); + // var sp = emscripten_stack_get_current(); // try { // return getWasmTableEntry(index)(a1,a2); // } catch(e) { - // stackRestore(sp); + // _emscripten_stack_restore(sp); // if (e !== e+0) throw e; // _setThrew(1, 0); // } //} - // This is the equivalent of "var sp = stackSave();". + // This is the equivalent of "var sp = emscripten_stack_get_current();". // We reuse savedStack to save allocations. We allocate with a size of 2 // here to accommodate for the input and output of setThrew. var savedStack [2]uint64 - callOrPanic(ctx, mod, "stackSave", savedStack[:]) + callOrPanic(ctx, mod, "emscripten_stack_get_current", savedStack[:]) err := f.CallWithStack(ctx, stack) if err != nil { @@ -133,9 +133,9 @@ func (v *InvokeFunc) Call(ctx context.Context, mod api.Module, stack []uint64) { panic(err) } - // This is the equivalent of "stackRestore(sp);". + // This is the equivalent of "_emscripten_stack_restore(sp);". // Do not overwrite err here to preserve the original error. - callOrPanic(ctx, mod, "stackRestore", savedStack[:]) + callOrPanic(ctx, mod, "_emscripten_stack_restore", savedStack[:]) // If we encounter ThrowLongjmpError, this means that the C code did a // longjmp, which in turn called _emscripten_throw_longjmp and that is From 5afe7f1895632a87d9fac539af0c3fdf0cffe313 Mon Sep 17 00:00:00 2001 From: Takeshi Yoneda Date: Fri, 19 Jul 2024 08:07:46 -0700 Subject: [PATCH 2/2] update test data Signed-off-by: Takeshi Yoneda --- imports/emscripten/emscripten_test.go | 2 +- imports/emscripten/testdata/invoke.wasm | Bin 1855 -> 1790 bytes imports/emscripten/testdata/invoke.wat | 4 ++-- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/imports/emscripten/emscripten_test.go b/imports/emscripten/emscripten_test.go index a68aa93774..5bad84a137 100644 --- a/imports/emscripten/emscripten_test.go +++ b/imports/emscripten/emscripten_test.go @@ -30,7 +30,7 @@ var growWasm []byte // invokeWasm was generated by the following: // -// cd testdata; wat2wasm --debug-names invoke.wat +// cd testdata; wasm-tools parse invoke.wat -o invoke.wasm // //go:embed testdata/invoke.wasm var invokeWasm []byte diff --git a/imports/emscripten/testdata/invoke.wasm b/imports/emscripten/testdata/invoke.wasm index b2020dec7819f15e5ab1126020505f134aa4914e..aaa241a56f2724eddc8bcd2e038f18f761140062 100644 GIT binary patch delta 102 zcmdnb_m6i&6r)AH1XBK6aVqsxqU^HMCVr1Zthni53pP5&ZS_A+^>ml6$ delta 167 zcmW;GNe;nK0D$5DwWUf2O3m{;a{-rNXYutZb zBL5Y(alQGw!^Xb{q|C_c@F`Y`^3=nR>ZuP!E