Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement
reference-types
Wasm proposal (#635)
* add reference_types flag to Config * enable all Wasm spec tests again Many are failing at the moment since reference-types is not yet implemented in wasmi. The goal of this PR is to make all tests pass again. * make table.copy and table.init instructions take table parameters * make call.indirect take table parameter * make FuncIdx use NonZeroU32 This allows to have size_of<Func> == size_of<Option<Func>> * remove some From impls for Value * create FuncRef type in wasmi * add more Func and FuncRef size_of tests * add test comment * add FuncRef <-> UntypedValue conversions * add ValueType::FuncRef * make Value no longer Copy This is in preparation for the introduction of the ExternRef type that is going to be a non-Copy type since internally it will be reference counted. * add ExternRef type to wasmi * fix no_std compilation * fix another silly no_std compile error * remove From<&Value> impl for UntypedValue * re-design ExternRef It no longer owns its data itself but uses to the store to do so just like any other entity in wasmi. * add accessor methods to Value Thesse methods were taken over from the Wasmtime API. * apply clippy suggestion * make Value no longer impl PartialEq Just like in the Wasmtime API. Better mirroring. * improve docs * add ExternRef to Value This also removes the Display impl for Value. The wasmi CLI tool now instead implements its own way to display Value which makes more sense anyways. * remove Display impl for FuncType The Display implementation now resides in wasmi_cli which was its only user and makes more sense since Display impls usually are biased. * add Default derive for ExternRef * remove PartialEq impl of FuncRef * remove TryInto API from Value This better mirrors the Wasmtime API. * remove Value::try_into * add From<FuncRef> and From<ExternRef> for Value * fix UntypedValue <-> [Func|Extern]Ref bugs with null values * apply rustfmt * fix internal doc link * add additional conversion checks for safety * apply rustfmt * add element type to TableType Note that the Table is still working as before. * make Table use ValueType and Value Internally TableEntity uses UntypedValue for efficiency reasons. * fix bug in Arena::get_pair_mut * make Table::get return Option instead of Result * implement Table::{get, set} instructions * add docs * implement table.size Wasm instruction * implement table.grow Wasm instruction * add docs to TableEntity::grow_untyped * implement Table[Entity]::fill method * implement table.fill Wasm instruction * add missing spectest global_i64 definition * implement more Wast decodings for reference-types * implement typed_select, ref.null and ref.is_null Wasm instructions * allow reftypes in Element parsing * cleanup assert * add ValueType::{is_num, is_ref} methods These are copied over from the Wasmtime API. * properly adjust stack height for new table instructions * allow RefNull and FuncRef in InitExpr * dispatch on ValueType for evaluating InitExpr * change error message to be closer to what Wasm spec testsuite expects * improve wast testsuite * fix bug in ExternObjectEntity::data and add test * extend wast testsuite * adjust TableOutOfBounds trap message and relax assertions * apply rustfmt * apply clippy suggestions * adjust trap message * improve trap message * handle Wasm declared element segments * account for element type when matching table types * cleanup instantiation code a bit * perform some renames and further cleanups * more cleanups * more linker cleanups * improve LinkerError * more cleanups * apply rustfmt * update docs for satisfies methods * apply clippy suggestion * fix internal doc link * improve docs * rename methods * refactor check_subtype * apply clippy suggestions * implement ref.func Wasm instruction * fix ModuleResources::global_get method * improve global.get optimization * minor cleanup * update Wasm spec testsuite * remove debug println * cleanup testsuite runner * remove unnecessary match arm even Wasmtime does not know how to compare funcrefs according to the Wast specification. Therefore I think it has not been designed, yet. * add print_i64 to Wasm spec testsuite module * use Self were possible * add temporary fix * fix TableEntity::copy_within * improve Table docs * fix bug in Arena::get_pair_mut * cleanup code after bug fix * add element type check to table.copy * move comment * add missing #[repr(transparent)] * cleanup error handling * move more into chained iter in TableEntity::init * fix bug in table.init procedures * improve Wasm spec testsuite runner * simplify MemoryType::is_subtype_of check * simplify TableType::is_subtype_of procesures * cleanup * rename method * improve MemoryError and TableError for subtyping * cleanup linker errors for invalid subtypes * improve Wasm spec testsuite runner error reporting * apply rustfmt * add Memory::import_ty method This fixes a bug with import subtyping. Apparently subtyping is concerned with dynamic types and not with static types. * add Table::import_ty method for same reason as Memory::import_ty * make Table::import_ty pub(crate) * rename import_ty -> dynamic_ty better name for the same thing * remove clippy allowance * table.init bail out earlier for len == 0 * apply rustfmt * canonicalize FuncRef::null instances Now all FuncRef::null() instances are always guaranteed to be encoded as 0. * fi spelling in doc * move safety comment to unsafe block * canonicalize ExternRef::null() values properly * fix bug in Executor::visit_table_copy
- Loading branch information