Skip to content

Commit

Permalink
Move call back to old position
Browse files Browse the repository at this point in the history
Signed-off-by: Jeroen Bobbeldijk <[email protected]>
  • Loading branch information
jerbob92 committed Aug 9, 2023
1 parent 4ba67dc commit 140b7a1
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions internal/emscripten/emscripten.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,13 @@ func (v *InvokeFunc) Call(ctx context.Context, mod api.Module, stack []uint64) {
tableOffset := wasm.Index(stack[0]) // position in the module's only table.
copy(stack, stack[1:]) // pop the tableOffset.

// Lookup the table index we will call.
t := m.Tables[0] // Note: Emscripten doesn't use multiple tables
f, err := m.Engine.LookupFunction(t, typeID, tableOffset)
if err != nil {
panic(err)
}

// The Go implementation below mimics the Emscripten JS behaviour to support
// longjmps from indirect function calls. The implementation of these
// indirection function calls in Emscripten JS is like this:
Expand All @@ -127,12 +134,6 @@ func (v *InvokeFunc) Call(ctx context.Context, mod api.Module, stack []uint64) {
panic(err)
}

// Lookup the table index we will call.
t := m.Tables[0] // Note: Emscripten doesn't use multiple tables
f, err := m.Engine.LookupFunction(t, typeID, tableOffset)
if err != nil {
panic(err)
}
err = f.CallWithStack(ctx, stack)
if err != nil {
// Module closed: any calls will just fail with the same error.
Expand Down

0 comments on commit 140b7a1

Please sign in to comment.