All notable changes to this project will be documented in this file.
The format is loosely based on Keep a Changelog,
and this project adheres to Semantic Versioning.
Additionally we have an Internal
section for changes that are of interest to developers.
Dates in this file are formattes as YYYY-MM-DD
.
- Added support for the
tail-call
Wasm proposal. (wasmi-labs#683) - Added support for
Linker
defined host functions. (wasmi-labs#692)- Apparently this PR introduced some performance wins for the Wasm target according to our tests. This information shall be taken with a grain of salt since we are not sure why those performance improvement occured since the PR's functionality is orthogonal to Wasm engine performance.
- Required precursor refactoring PR: wasmi-labs#681
- The
wasmi_wasi
crate now more closely mirrors thewasmtime_wasi
crate API. (wasmi-labs#700)
- Refactor the
wasmi
Wasm engine to handle Wasm calls and returns in its core. (#694)- This improved performance of Wasm function calls significantly at the cost of host function call performance.
- Also this seemed to have impacts Wasm target performance quite positively, too.
- The
Store
now handles Wasm functions and host functions separately. (wasmi-labs#686)- This allows to store Wasm functions into the
StoreInner
type which was an important step towards the major refactoring in (#694) - It was expected that host function call performance would degrade by this PR but our tests actually showed that the opposite was true and Wasm target performance was improved overall.
- This allows to store Wasm functions into the
- Introduce
ValueStackPtr
abstraction for thewasmi
engine core. (wasmi-labs#688)- This change significantly improved performance especially on the Wasm target according to our tests.
- Optimize
memory.{load,store}
when reading or writing single bytes. (wasmi-labs#689)- The performance wins were more modest than we hoped but still measurable.
- Use
StoreContextMut<T>
instead ofimpl AsContextMut
in thewasmi
engine core. (wasmi-labs#685)- This is a simple refactoring with the goal to make the Rust compiler have a simpler job at
optimizing certain functions in the engine's inner workings since
StoreContextMut
provides more information to the compiler.
- This is a simple refactoring with the goal to make the Rust compiler have a simpler job at
optimizing certain functions in the engine's inner workings since
- Added support for fuel metering in the
wasmi
CLI. (wasmi-labs#679)- Users can now specify an amount of fuel via
--fuel N
to commit for the execution. Upon success thewasmi
CLI will display the total amount of consumed and remaining fuel.
- Users can now specify an amount of fuel via
- Fixed a bug that
wasmi
CLI did not preserve the WASI exit status. (wasmi-labs#677)- Thanks to YAMAMOTO Takashi @yamt for reporting the issue.
- The
wasmi
CLI now properly displays exported functions if--invoke x
was provided andx
was not found. (wasmi-labs#678) - Applied minor fixes to
Config
docs. (wasmi-labs#673)
- Defer charging fuel for costly bulk
memory
and bulktable
operations. (wasmi-labs#676)- Note that the check to assert that enough fuel is provided for these costly operation is still happening before the actual computation and only the charging is deferred to after a successful run. The reason behind this is that all the affected operations fail fast and therefore should not cost lots of fuel in case of failure.
- Fixed a bug where resuming a resumable function from a host function with more outputs than
inputs could lead to incorrect behavior or runtime panics. (wasmi-labs#671)
- Thanks to Pierre Krieger (tomaka) for reporting and crafting an initial minimal test case.
wasmi
CLI: Add WASI support. (wasmi-labs#597)- Big shoutout to Onigbinde Oluwamuyiwa Elijah for contributing this to
wasmi
!
- Big shoutout to Onigbinde Oluwamuyiwa Elijah for contributing this to
- Add built-in support for fuel metering. (wasmi-labs#653)
- This allows to control the runtime of Wasm executions in a deterministic fasion
effectively avoiding the halting problem by charging for executed instructions.
Not using the feature will not affect the execution efficiency of
wasmi
for users.
- This allows to control the runtime of Wasm executions in a deterministic fasion
effectively avoiding the halting problem by charging for executed instructions.
Not using the feature will not affect the execution efficiency of
- Add
Pages::checked_sub
method. (wasmi-labs#660) - Add
Func::new
constructor. (wasmi-labs#662)- This allows to create
Func
instances from closures without statically known types.
- This allows to create
- Update to
wasmparser-nostd
version0.100.1
. (wasmi-labs#666)
- Clean up and reorganization of the
wasmi_cli
crate. (wasmi-labs#655) - Refactoring of internal host call API. (wasmi-labs#664)
- Added
Config::floats
option to enable or disable Wasm float operators during Wasm validation. Trap::downcast_mut
andTrap::downcast
methods. (wasmi-labs#650)- This helps users to downcast into
T: HostError
.
- This helps users to downcast into
- Added
WasmType
impls forFuncRef
andExternRef
types. (wasmi-labs#642)- This allows
FuncRef
andExternRef
instances to be used inTypedFunc
parameters and results.
- This allows
- Removed from
From
impls fromwasmparser-nostd
types towasmi
types.- For example
From<wasmparser::FuncType> for wasmi::FuncType
got removed.
- For example
- Update the
wasmparser-nostd
dependency from version0.91.0
to0.99.0
. (wasmi-labs#640) - The
Trap
type is no longerClone
. (wasmi-labs#650)
- Resolved plenty of technical debt and improved structure of the
wasmi
crate.
- Added support for the
bulk-memory
Wasm proposal. (wasmi-labs#628) - Added support for the
reference-types
Wasm proposal. (wasmi-labs#635) - Added
ValueType::{is_ref, is_num
} methods. (wasmi-labs#635) - Added
Value::{i32, i64, f32, f64, externref, funcref}
accessor methods toValue
.
- Fix a bug with
Table
andMemory
imports not respecting the current size. (wasmi-labs#635)- This sometimes led to the problem that valid
Table
andMemory
imports could incorrectly be rejected for having an invalid size for the subtype check. - This has been fixed as part of the
reference-types
Wasm proposal implementation.
- This sometimes led to the problem that valid
- Use more references in places to provide the compiler with more optimization opportunities. (wasmi-labs#634)
- This led to a speed-up across the board for Wasm targets of about 15-20%.
- Move the
Value
type fromwasmi_core
towasmi
. (wasmi-labs#636)- This change was necessary in order to support the
reference-types
Wasm proposal.
- This change was necessary in order to support the
- There has been some consequences from implementing the
reference-types
Wasm proposal which are listed below:- The
Value
type no longer implementsCopy
andPartialEq
. - The
From<&Value> for UntypedValue
impl has been removed. - Remove some
From
impls forValue
. - Moved some
Display
impls for types likeFuncType
andValue
to thewasmi_cli
crate. - Remove the
try_into
API from theValue
type.- Users should use the new accessor methods as in the Wasmtime API.
- The
- Update
wast
dependency from version0.44
to0.52
. (wasmi-labs#632) - Update the Wasm spec testsuite to the most recent commit:
3a04b2cf9
- Improve error reporting for the internal Wasm spec testsuite runner.
- It will now show proper span information in many more cases.
Note: This is the Wasmtime API Compatibility update.
- Add
Module::get_export
method. (wasmi-labs#617)
- Removed
ModuleError
export from crate root. (wasmi-labs#618)- Now
ModuleError
is exported fromcrate::errors
just like all the other error types.
- Now
- Refactor and cleanup traits underlying to
IntoFunc
. (wasmi-labs#620)- This is only the first step in moving closer to the Wasmtime API traits.
- Mirror Wasmtime API more closely. (wasmi-labs#615, wasmi-labs#616)
- Renamed
Caller::host_data
method toCaller::data
. - Renamed
Caller::host_data_mut
method toCaller::data_mut
. - Add
Extern::ty
method and theExternType
type. - Rename
ExportItem
toExportType
:- Rename the
ExportItem::kind
method toty
and returnExternType
instead ofExportItemKind
. - Remove the no longer used
ExportItemKind
entirely.
- Rename the
- The
ExportsIter
now yields items of the new typeExport
instead of pairs of(&str, Extern)
. - Rename
ModuleImport
toImportType
.- Rename
ImportType::item_type
toty
. - Rename
ImportType::field
toname
. - Properly forward
&str
lifetimes inImportType::{module, name}
. - Replace
ModuleImportType
byExternType
.
- Rename
- Add new convenience methods to
Instance
:Instance::get_func
Instance::get_typed_func
Instance::get_global
Instance::get_table
Instance::get_memory
- Rename getters for querying types of runtime objects:
Func::func_type
=>Func::ty
Global::global_type
=>Global::ty
Table::table_type
=>Table::ty
Memory::memory_type
=>Memory::ty
Value::value_type
=>Value::ty
- Remove
Global::value_type
getter.- Use
global.ty().content()
instead.
- Use
- Remove
Global::is_mutable
getter.- Use
global.ty().mutability().is_mut()
instead.
- Use
- Rename
Mutability::Mutable
toVar
. - Add
Mutability::is_mut
getter.- While this API is not included in Wasmtime it is a useful convenience method.
- Rename
TableType::initial
method tominimum
. - Rename
Table::len
method tosize
. Table
andTableType
now operate onu32
instead ofusize
just like in Wasmtime.- This affects
Table::{new, size, set, get, grow}
methods andTableType::{new, minimum, maximum}
methods and their users.
- This affects
- Renamed
- Add missing
TypedFunc::call_resumable
API. (wasmi-labs#605)- So far resumable calls were only available for the
Func
type. However, there was no technical reason why it was not implemented forTypedFunc
so this mirrored API now exists. - This also cleans up rough edges with the
Func::call_resumable
API.
- So far resumable calls were only available for the
- Clean up the
wasmi_core
crate API. (wasmi-labs#607, wasmi-labs#608, wasmi-labs#609)- This removes plenty of traits from the public interface of the crate which greatly simplifies the API surface for users.
- The
UntypedValue
type gained some new methods to replace functionality that was provided in parts by the removed traits.
- The
wasmi
crate now follows the Wasmtime API a bit more closely. (wasmi-labs#613)StoreContext
new methods:fn engine(&self) -> &Engine
fn data(&self) -> &T
StoreContextMut
new methods:fn engine(&self) -> &Engine
fn data(&self) -> &T
fn data_mut(&mut self) -> &mut T
- Renamed
Store::state
method toStore::data
. - Renamed
Store::state_mut
method toStore::data_mut
. - Renamed
Store::into_state
method toStore::into_data
.
- The
Store
andEngine
types are better decoupled from their generic parts. (wasmi-labs#610, wasmi-labs#611)- This might reduce binary bloat and may have positive effects on the performance. In fact we measured significant performance improvements on the Wasm target.
- Add support for resumable function calls. (wasmi-labs#598)
- This feature allows to resume a function call upon encountering a host trap.
- Add support for concurrently running function executions using a single
wasmi
engine.- This feature also allows to call Wasm functions from host functions. (wasmi-labs#590)
- Add initial naive WASI support for
wasmi
using the newwasmi_wasi
crate. (wasmi-labs#557)- Special thanks to Onigbinde Oluwamuyiwa Elijah for carrying the WASI support efforts!
- Also thanks to Yuyi Wang for testing and improving initial WASI support. (wasmi-labs#592, wasmi-labs#571, wasmi-labs#568)
- Note: There is ongoing work to integrate WASI support in
wasmi_cli
so that thewasmi
CLI will then be able to execute arbitrarywasm-wasi
files out of the box in the future.
- Add
Module::imports
that allows to query Wasm module imports. (wasmi-labs#573, wasmi-labs#583)
- Fix a bug that imported linear memories and tables were initialized twice upon instantiation. (wasmi-labs#593)
- The
wasmi
CLI now properly hints for file path arguments. (wasmi-labs#596)
- The
wasmi::Trap
type is now more similar to Wasmtime'sTrap
type. (wasmi-labs#559) - The
wasmi::Store
type is nowSend
andSync
as intended. (wasmi-labs#566) - The
wasmi
CLI now prints exported functions names if the function name CLI argument is missing. (wasmi-labs#579) - Improve feedback when running a Wasm module without exported function using
wasmi
CLI. (wasmi-labs#584)
- Contribution documentation about fuzz testing. (wasmi-labs#529)
- Removed some deprecated functions in the
wasmi_core
crate. (wasmi-labs#545)
- Fixed a critical performance regression introduced in Rust 1.65. (wasmi-labs#518)
- While the PR's main job was to clean up some code it was found out that it also fixes a critical performance regression introduced in Rust 1.65.
- You can read more about this performance regression in this thread.
- Fixed handling of edge cases with respect to Wasm linear memory. (wasmi-labs#449)
- This allows for
wasmi
to properly setup and use linear memory instances of up to 4GB.
- This allows for
- Optimize and improve Wasm instantiation. (wasmi-labs#531)
- Optimize
global.get
of immutable non-imported globals. (wasmi-labs#533)- Also added a benchmark test for this. (wasmi-labs#532)
- Implemented miscellaneous improvements to our CI system.
- wasmi-labs#539 (and more)
- Miscellaneous clean ups in
wasmi_core
andwasmi
's executor.
- Fixed a potential undefined behavior as reported by the
miri
tool with respect to its experimental stacked borrows. (wasmi-labs#524)
- Optimized Wasm to
wasmi
translation phase by removing unnecessary Wasm validation type checks. (wasmi-labs#527)- Speedups were in the range of 15%.
Linker::instantiate
now takes&self
instead of&mut self
. (wasmi-labs#512)- This allows users to easily predefine a linker and reused its definitions as shared resource.
- Fixed a bug were
Caller::new
was public. (wasmi-labs#514)- It is now a private method as it was meant to be.
- Optimized
TypedFunc::call
at slight cost ofFunc::call
. (wasmi-labs#522)- For many parameters and return values the measured improvements are in the range of 25%. Note that this is only significant for a large amount of host to Wasm calls of small functions.
- Added new benchmarks and cleaned up benchmarking code in general.
- Add
miri
testing towasmi
CI (wasmi-labs#523)
- Optimize for common cases for branch and return instructions.
(wasmi-labs#493)
- This led to up to 10% performance improvement according to our benchmarks in some cases.
- Removed extraneous
S: impl AsContext
generic parameter fromFunc::typed
method. - Make
IntoFunc
,WasmType
andWasmRet
traits publicly available. - Add missing impl for
WasmRet
forResult<T, Trap> where T: WasmType
.- Without this impl it was impossible to provide closures to
Func::wrap
that returnedResult<T, Trap>
whereT: WasmType
, onlyResult<(), Trap>
orResult<(T,), Trap>
was possible before.
- Without this impl it was impossible to provide closures to
- Added
wasmi_arena
crate which defines all internally used arena data structures. (wasmi-labs#502) - Update to
clap 4.0
inwasmi_cli
. (wasmi-labs#498) - Many more improvements to our internal benchmarking CI. (wasmi-labs#494, wasmi-labs#501, wasmi-labs#506, wasmi-labs#509)
- Added Contibution Guidelines and Code of Conduct to the repository. (wasmi-labs#485)
- Optimized instruction dispatch in the
wasmi
interpreter. (wasmi-labs#478, wasmi-labs#482)- This yielded combined speed-ups of ~20% across the board.
- As a side effect we also refactored the way we compute branching offsets at Wasm module compilation time which improved performance of Wasm module compilation by roughly 5%.
- Our CI now also benchmarks
wasmi
when ran inside Wasmtime as Wasm. (wasmi-labs#483, wasmi-labs#487)- This allows us to optimize
wasmi
towards Wasm performance more easily in the future.
- This allows us to optimize
- Added
Memory::data_and_store_mut
API inspired by Wasmtime's API. (wasmi-labs#448)
- Updated
wasmparser-nostd
dependency from0.90.0
to0.91.0
.- This improved performance of Wasm module compilation by ~10%.
- Updated
wasmi_core
from0.3.0
to0.4.0
. - Optimized execution of several Wasm float to int conversion instructions. (wasmi-labs#439)
- We measured a performance improvement of 6000% or in other words those instructions are now 60 times faster than before.
- This allowed us to remove the big
num-rational
dependency fromwasmi_core
for some nice speed-ups in compilation time ofwasmi
itself.
- Optimized
global.get
andglobal.set
Wasm instruction execution. (wasmi-labs#427)- This improved performance of those instructions by up to 17%.
- Optimized Wasm value stack emulation. (wasmi-labs#459)
- This improved performance of compute intense workloads by up to 23%.
- Added automated continuous benchmarking to
wasmi
. (wasmi-labs#422)- This allows us to have a more consistent overview over the performance of
wasmi
.
- This allows us to have a more consistent overview over the performance of
- Updated
criterion
benchmarking framework to version0.4.0
. - Reuse allocations during Wasm validation and translation:
- Wasm validation and translation combined. (wasmi-labs#462)
- Wasm
br_table
translations. (wasmi-labs#440)
- Enabled more useful
clippy
lints forwasmi
andwasmi_core
. (wasmi-labs#438) - Reorganized the
wasmi
workspace. (wasmi-labs#466)
- Update
wasmparser-nostd
dependency from version0.83.0
->0.90.0
. Link:- This significantly improved
wasmi
's Wasm parsing, validation and Wasm towasmi
bytecode translation performance.
- This significantly improved
- Transition to the new
wasmparser::VisitOperator
API. Link- This again significantly improved
wasmi
's Wasm parsing, validation and Wasm towasmi
bytecode translation performance by avoiding many unnecessary unpredictable branches in the process.
- This again significantly improved
- Fixed bugs found during fuzzing the translation phase of
wasmi
. Link - Fix
Read
trait implementation forno_std
compilations. Link
- Update to
wasmi_core
version0.3.0
. - Changed API of
wasmi::Config
in order to better reflect the API ofwasmtime::Config
. - Refactor
Trap
type to be of pointer size which resulted in significant performance wins across the board especially for call intense work loads. Link
- Removed support for virtual memory based Wasm linear memory.
We decided to remove support since benchmarks showed that our current
implementation actually regresses performance compared to our naive
Vec
based implementation. Link
- The
wasmi::Engine
now caches the bytes of the default linear memory for performance wins inmemory.store
andmemory.load
intense work loads. Link - The
wasmi
engine internals have been reorganized and modernised to improve performance on function call intense work loads. This resulted in performance improvements across the board. Link - The Wasm to
wasmi
bytecode translation now properly reuses heap allocations across function translation units which improved translation performance by roughly 10%. Link - Optimized the
wasmi
engine Wasm value stack implementation for significant performance wins across the board. Link - Shrunk size of some internal identifier types for minor performance wins. Link
- Added initial naive fuzz testing for Wasm parsing, validation and Wasm to
wasmi
bytecode translation. Link
-
Added support for the following Wasm proposals:
- Import and export of mutable globals
- Non-trapping float-to-int conversions
- Sign-extension operators
- Multi-value
We plan to support more Wasm proposals in the future.
-
Wasmi has been entirely redesigned and reimplemented. This work resulted in an entirely new API that is heavily inspired by the Wasmtime API, a brand new Wasm execution engine that performs roughly 30-40% better than the previous engine according to our benchmarks, the support of many Wasm proposals and Wasm parsing and validation using the battle tested
wasmparser
crate by the BytecodeAlliance.The new
wasmi
design allows to reuse the Wasm execution engine resources instead of spinning up a new Wasm execution engine for every function call.Note: If you plan to use
wasmi
it is of critical importance to compilewasmi
using the following Cargoprofile
settings:[profile.release] lto = "fat" codegen-units = 1
If you do not use these profile settings you might risk regressing performance of
wasmi
by up to 400%. You can read more about this issue here.
- Removed support for resuming function execution.
We may consider to add this feature back into the new engine.
If you are a user of
wasmi
and want this feature please feel free to open an issue and provide us with your use case.
- Support allocating 4GB of memory (wasmi-labs#452)
Note: Yanked because of missing wasmi_core
bump.
Note: This is the last major release of the legacy wasmi
engine.
Future releases are using the new Wasm execution engines
that are currently in development.
We may consider to publish new major versions of this Wasm engine
as wasmi-legacy
crate.
- Update dependency:
wasmi-validation v0.4.2 -> v0.5.0
wasmi
now depends on thewasmi_core
crate.- Deprecated
RuntimeValue::decode_{f32,f64}
methods.- Reason: These methods expose details about the
F32
andF64
types. TheRuntimeValue
type providesfrom_bits
methods for similar purposes. - Replacement: Replace those deprecated methods with
F{32,64}::from_bits().into()
respectively.
- Reason: These methods expose details about the
- Refactor traps in
wasmi
: PR- This change also renames
TrapKind
toTrapCode
. - The
wasmi
crate now properly reuses theTrapCode
definitions from thewasmi_core
crate.
- This change also renames
- Updated dependency:
parity-wasm v0.42 -> v0.45
memory_units v0.3.0 -> v0.4.0
- Rename
RuntimeValue
toValue
internally. - Now uses
wat
crate dependency instead ofwabt
for reading.wat
files in tests. - Updated dev-dependencies:
assert_matches: v1.1 -> v1.5
rand 0.4.2 -> 0.8.2
- Fix some
clippy
warnings.
- Make
wasmi
traps more conformant with the Wasm specification. (wasmi-labs#300) - Fixed a bug in
{f32, f64}_copysign
implementations. (wasmi-labs#293) - Fixed a bug in
{f32, f64}_{min, max}
implementations. (wasmi-labs#295)
- Optimized Wasm to host calls. (wasmi-labs#291)
- In some artificial benchmarks we saw improvements of up to 42%!
- Introduce a more efficient
LittleEndianConvert
trait. (wasmi-labs#290)
- Refactor and clean up benchmarking code and added more benchmarks.
- Apply some clippy suggestions with respect ot
#[must_use]
. (wasmi-labs#288) - Improve Rust code formatting of imports.
- Improve debug impl of
ValueStack
so that only the live parts are printed.
- Support for virtual memory usage on Windows 64-bit platforms.
- Technically we now support the same set of platforms as the
region
crate does: https://github.com/darfink/region-rs#platforms
- Technically we now support the same set of platforms as the
- The
wasmi
andwasmi-validation
crates now both use Rust edition 2021. - The
README
now better teaches how to test and benchmark the crate. - Updated
num-rational
from version0.2.2
->0.4.0
.
- Deprecated
MemoryInstance::get
method.- Users are recommended to use
MemoryInstance::get_value
orMemoryInstance::get_into
methods instead.
- Users are recommended to use
- Removed support for virtual memory on 32-bit platforms.
- Note that the existing support was supposedly not more efficient than the
Vec
based fallback implementation anyways due to technical design.
- Note that the existing support was supposedly not more efficient than the
- Removed the
core
crate feature that previously has been required forno_std
builds.- Now users only have to specify
--no-default-features
for ano_std
build.
- Now users only have to specify
- Fully deploy GitHub Actions CI and remove deprecated Travis based CI. Added CI jobs for:
- Testing on Linux, MacOS and Windows
- Checking docs and dead links in docs.
- Audit crate dependencies for vulnerabilities.
- Check Wasm builds.
- File test coverage reports to codecov.io.
- Added possibility to forward
reduced_stack_buffers
crate feature toparity-wasm
crate.
- Added a default
rustfmt.toml
configuration file. - Fixed some warnings associated to Rust edition 2021.
- Note: The crate itself remains in Rust edition 2018.
- Updated
parity-wasm
from verion0.41
to0.42
. - Bumped
wasmi-validation
from version0.3.1
to0.4.0
.