Skip to content

WASM API improvements#837

Merged
saghul merged 5 commits intomasterfrom
wasm-improvements
Mar 9, 2026
Merged

WASM API improvements#837
saghul merged 5 commits intomasterfrom
wasm-improvements

Conversation

@saghul
Copy link
Copy Markdown
Owner

@saghul saghul commented Mar 9, 2026

  • wasm: implement WebAssembly.Memory
  • wasm: refactor function calling and fix memory grow error
  • wasm: add WebAssembly.Global
  • wasm: add function import support
  • wasm: add externref, funcref, Table, and validate() support

saghul added 4 commits March 9, 2026 22:13
Extract tjs__call_wasm_func_inst() helper from tjs_wasm_callfunction()
for reusable WASM function invocation. Use JS_ThrowRangeError directly
for memory grow failures instead of generic tjs_throw_wasm_error.
Implement function imports from JS into WASM modules using WAMR's
raw native registration API. Modules are loaded with deferred symbol
resolution (no_resolve), JS callbacks are registered as native
trampolines grouped by module name, then resolved before instantiation.

- Import trampoline bridges WAMR native calls to JS functions
    (i32/i64/f32/f64 params and returns)
- JS exceptions from imported functions are preserved and re-thrown
- Upfront LinkError validation for missing imports
- Module.imports() now returns real import metadata
@saghul saghul force-pushed the wasm-improvements branch from b3dcd12 to 632ff63 Compare March 9, 2026 21:36
- externref in function params/returns for exported functions
- externref globals (read/write)
- externref and funcref tables via WebAssembly.Table API
- Table exports on Instance
- WebAssembly.validate()

NOTE: externref in imported functions is not supported due to two
apparent WAMR bugs in invoke_native_raw (valkind assert for externref, and
wrong argv_src offset for externref params).
@saghul saghul force-pushed the wasm-improvements branch from 632ff63 to f552802 Compare March 9, 2026 21:39
@saghul saghul marked this pull request as ready for review March 9, 2026 21:39
@saghul saghul merged commit 5ccd1f2 into master Mar 9, 2026
30 checks passed
@saghul saghul deleted the wasm-improvements branch March 9, 2026 22:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant