-
Notifications
You must be signed in to change notification settings - Fork 50
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Repository reproducing the problem: https://github.com/doehyunbaek/wasabi_multimodule_fidx
Currently, resolveTableIdx relies on name property of the function to resolve function index.
wasabi/crates/wasabi/js/runtime.js
Lines 45 to 51 in 21a322b
| // NOTE We want to get the _index_ of the resolved function to the analysis code, but the | |
| // WebAssembly API only gives us a _function object_. | |
| // HACK We can abuse the `.name` property of the function object to get the index. | |
| // See the MDN, which says the "name property is the toString() result of the function's | |
| // index in the wasm module". | |
| // https://developer.mozilla.org/en-US/docs/WebAssembly/Exported_functions | |
| const resolvedFunctionIdx = parseInt(resolvedFunction.name); |
This does not work when the function is imported from other WebAssembly instance and the index of the function in its imported module and the index of the function in its declared module is different, e.g.
module1.wat
(module
(func $private_func_0 (;0;) )
(func $private_func_1 (;1;) )
(func $shared_func (;2;) (param $0 i32) (result i32)
local.get $0
i32.const 1
i32.add
)
(export "shared_func" (func $shared_func))
)module2.wat
(module
(import "env" "shared_func" (func $shared_func (;0;) ))
)For module2, resolveTableIdx would resolve shared_func to 2, which is different from expected behavior, which is 0.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working