wasmtime: Initial, partial support for externref
This is enough to get an `externref -> externref` identity function passing. However, `externref`s that are dropped by compiled Wasm code are (safely) leaked. Follow up work will leverage cranelift's stack maps to resolve this issue.
This commit is contained in:
@@ -16,7 +16,7 @@ wasmtime_c_api_macros::declare_ref!(wasm_module_t);
|
||||
|
||||
impl wasm_module_t {
|
||||
fn externref(&self) -> wasmtime::ExternRef {
|
||||
self.module.externref()
|
||||
self.module.clone().into()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ pub extern "C" fn wasmtime_module_new(
|
||||
ret: &mut *mut wasm_module_t,
|
||||
) -> Option<Box<wasmtime_error_t>> {
|
||||
let binary = binary.as_slice();
|
||||
let store = &store.store.borrow();
|
||||
let store = &store.store;
|
||||
handle_result(Module::from_binary(store, binary), |module| {
|
||||
let imports = module
|
||||
.imports()
|
||||
@@ -53,7 +53,7 @@ pub extern "C" fn wasmtime_module_new(
|
||||
.map(|e| wasm_exporttype_t::new(e.name().to_owned(), e.ty()))
|
||||
.collect::<Vec<_>>();
|
||||
let module = Box::new(wasm_module_t {
|
||||
module: HostRef::new(module),
|
||||
module: HostRef::new(store, module),
|
||||
imports,
|
||||
exports,
|
||||
});
|
||||
@@ -72,7 +72,7 @@ pub extern "C" fn wasmtime_module_validate(
|
||||
binary: &wasm_byte_vec_t,
|
||||
) -> Option<Box<wasmtime_error_t>> {
|
||||
let binary = binary.as_slice();
|
||||
let store = &store.store.borrow();
|
||||
let store = &store.store;
|
||||
handle_result(Module::validate(store, binary), |()| {})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user