Conversation
Pure Elixir implementation that decodes .wasm binaries into structured
data — types, imports, exports, function bodies with decoded opcodes,
memories, tables, globals, data segments, and custom sections.
Opcodes use the same {offset, name, ...operands} tuple format as
QuickBEAM.Bytecode.
- QuickBEAM.WASM.disasm/1 — full module disassembly
- QuickBEAM.WASM.validate/1 — structural validation
- QuickBEAM.WASM.exports/1 — list module exports
- QuickBEAM.WASM.imports/1 — list module imports
- QuickBEAM.WASM.Module — decoded module struct
- QuickBEAM.WASM.Function — decoded function struct
- QuickBEAM.WASM.Parser — LEB128, sections, all MVP opcodes
Vendor WAMR (WebAssembly Micro Runtime) in interpreter mode and expose compile/start/call/stop/memory APIs as NIFs. - Vendor WAMR core: interpreter, common runtime, platform layer, memory allocator, utils (~57KB code footprint) - C bridge (wamr_bridge.c) wraps WAMR embedding API - Zig NIF layer (wasm_nif.zig) with WasmModule/WasmInstance resources - Elixir API: QuickBEAM.WASM.compile/1, start/2, call/3, stop/1, memory_size/1, memory_grow/2, read_memory/3, write_memory/3 All 27 WASM tests pass (19 parser + 8 runtime).
Implements the standard WebAssembly JS API as a TypeScript polyfill
backed by WAMR through Beam.callSync handlers.
Supported:
- WebAssembly.compile(bytes) → Promise<Module>
- WebAssembly.instantiate(bytes|module, imports?) → Promise<{module, instance}>
- WebAssembly.validate(bytes) → boolean
- new WebAssembly.Module(bytes)
- new WebAssembly.Instance(module)
- WebAssembly.Module.exports(mod)
- instance.exports.funcName(...args)
- WebAssembly.Memory, Table, Global constructors
- CompileError, LinkError, RuntimeError error types
7 new JS API tests (34 total).
- QuickBEAM.WASM.start/1 returns a pid (like QuickBEAM.start/1) - QuickBEAM.WASM.call/3 goes through GenServer (like QuickBEAM.call/3) - QuickBEAM.WASM.stop/1 stops the GenServer - child_spec/1 and start_link/1 for supervision trees - Named instances: start(module: bytes, name: :my_wasm) - Raw NIF compile/start are internal (@doc false) 36 tests (19 parser + 7 runtime + 7 JS API + 3 supervision).
drain_jobs() silently swallowed exceptions thrown during JS_ExecutePendingJob (ret < 0 treated as ret == 0). Add drain_jobs_or_set_error() that detects negative return values and extracts the exception from the correct JSContext. Replace drain_jobs() in do_eval, do_call, do_load_bytecode, and do_load_module. Also factor set_error_term into set_error_term_from_ctx to handle exceptions from a different context than self.ctx.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pure Elixir WASM binary parser + WAMR interpreter integration.
Elixir API — supervised instances, same conventions as
QuickBEAM.start/1:JS WebAssembly API — spec-compliant global inside QuickBEAM runtimes:
Disassembler — pure Elixir
.wasmparser, same{offset, name, ...operands}tuples asQuickBEAM.Bytecode:Memory access:
36 tests (19 parser, 10 runtime, 7 JS API).