Repository navigation
0.13.0
Adds an encoder: a module written as text or built in Erlang can be written
out as .wasm bytes, and text loads with the same handle as its binary. One
fix: a module that leaves out a data count section it needs is refused.
Changes
- New: encode a module to the binary format.
wasm:encode/1writes a
module as.wasmbytes. It takes text as{wat, Source}, a module you
compiled or built in Erlang, or a handle fromwasm:load/1, so you can
turn text into a.wasmfile without a toolchain, or hand a module you
changed to another engine. The same module always gives the same bytes. A
later release that changed those bytes would change the SHA-256 of every
module encoded with it, and so break anything that names modules by their
digest; it will be announced as a breaking change. - New: load the text format.
wasm:load/1andwasm:load/2take
{wat, Source}, andwasm:load_file/1reads a.watfile as text; both
encode it before loading. A module loaded from text and the same module
loaded from its.wasmshare one cache entry and one handle. Until now
text could only be compiled, and each compile gave it a new identity that
nothing shared. - Fixed: a module could leave out its data count section in two cases.
The binary format requires the data count section whenever code names a
data segment, and a module is malformed without it. The check looked
inside every kind of block buttry_table, and did not count the garbage
collection instructionsarray.new_dataandarray.init_data, so a module
that named a data segment only in those ways was read. It is refused now,
as it is elsewhere.