Add support for Emscripten version 3.1.57 (#2290)
This update the imports/emscripten package implementation so that it can support v3.1.57+ which came with a breaking change: https://github.com/emscripten-core/emscripten/pull/21555 Signed-off-by: Jeroen Bobbeldijk <jeroen@klippa.com>
This commit is contained in:
@@ -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
|
||||
|
||||
BIN
imports/emscripten/testdata/invoke.wasm
vendored
BIN
imports/emscripten/testdata/invoke.wasm
vendored
Binary file not shown.
4
imports/emscripten/testdata/invoke.wat
vendored
4
imports/emscripten/testdata/invoke.wat
vendored
@@ -15,9 +15,9 @@
|
||||
(table 22 22 funcref)
|
||||
|
||||
(global $__stack_pointer (mut i32) (i32.const 65536))
|
||||
(func $stackSave (export "stackSave") (result i32)
|
||||
(func $stackSave (export "emscripten_stack_get_current") (result i32)
|
||||
global.get $__stack_pointer)
|
||||
(func $stackRestore (export "stackRestore") (param i32)
|
||||
(func $stackRestore (export "_emscripten_stack_restore") (param i32)
|
||||
local.get 0
|
||||
global.set $__stack_pointer)
|
||||
(func $setThrew (export "setThrew") (param i32 i32))
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user