feat(marine-js)!: replace old marine-js with common marine-runtime + backend traits impl for JS (#332)

* add js wasm backend crate + blank trait impls

* make wasmtime a default feature for runtime and core

* WIP: mock WASI, greeting almost works

* WIP: added @wasmer/wasi, moved some stuff to JsStore, implementing Caller

* finalize Caller

* remove old code

* changing js API + fmt

* update wasm-bindgen generated and patched code

* update call_module to throw error, fix non-logging tests

* add multi-module test + update js api

* fix last element getting

* refactor interface + pass envs

* get rid of make_*_result

* small refactor

* support passing log function

* get rid of some todos

* use String instead of Vec<u8> for wasi envs

* use Strings for wasi envs in marine js

* little fix

* self-review fixes, import ordering

* self-review fixes, import ordering

* make clippy happy + fmt

* self-review fixes

* self-review fixes

* self-review fixes

* revert example artifact change

* pr fixes

* add __wbg_adapter_N updating code

* add all-types test

* fix build

* update marine_js.js

* Fix I64 handling

* pr fixes

* fix import order

* add copyrights

* Add comments, slightly beautify code

* fmt

* make clippy happy

* update js interface

* split function interface, improve naming

* update Cargo.lock

* update to new wasm-backend traits

* wip

* js glue code update

* improve comment

* use typed index collection

* Add more comments

* Add more comments

* Fix warnings

* pr fixes

* pr fixes
This commit is contained in:
Valery Antopol
2023-07-25 19:49:55 +03:00
committed by GitHub
parent 0f9979ae11
commit a61ddfc404
53 changed files with 3825 additions and 7863 deletions

View File

@ -21,6 +21,7 @@ use crate::WasmBackend;
use crate::WType;
use std::borrow::Cow;
use std::fmt::Formatter;
/// A "Linker" object, that is used to match functions with module imports during instantiation.
/// Cloning is a cheap operation for this object. All clones refer to the same data in store.
@ -82,6 +83,17 @@ impl FuncSig {
}
}
impl std::fmt::Debug for FuncSig {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(
f,
"params: {:?}, returns: {:?}",
self.params(),
self.returns
)
}
}
pub type FuncFromImportCallContext<WB, Args, Rets> = Box<
dyn FnMut(&mut <WB as WasmBackend>::ContextMut<'_>, Args) -> RuntimeResult<Rets>
+ Sync

View File

@ -83,6 +83,16 @@ impl WValue {
Self::F64(x) => f64::to_bits(x) as u128,
}
}
/// Converts any value to i32. Floats are interpreted as plain bytes.
pub fn to_i32(&self) -> i32 {
match *self {
Self::I32(x) => x,
Self::I64(x) => x as i32,
Self::F32(x) => f32::to_bits(x) as i32,
Self::F64(x) => f64::to_bits(x) as i32,
}
}
}
impl std::fmt::Display for WType {