diff --git a/crates/c-api/include/wasmtime.h b/crates/c-api/include/wasmtime.h index eb6253b728..351b15433e 100644 --- a/crates/c-api/include/wasmtime.h +++ b/crates/c-api/include/wasmtime.h @@ -740,7 +740,7 @@ WASM_API_EXTERN own wasmtime_error_t *wasmtime_instance_new( * returned error and module are owned by the caller. */ WASM_API_EXTERN own wasmtime_error_t *wasmtime_module_new( - wasm_store_t *store, + wasm_engine_t *engine, const wasm_byte_vec_t *binary, own wasm_module_t **ret ); diff --git a/crates/c-api/src/module.rs b/crates/c-api/src/module.rs index ede8401e2f..7d2f0ff7c4 100644 --- a/crates/c-api/src/module.rs +++ b/crates/c-api/src/module.rs @@ -1,6 +1,6 @@ use crate::{ - handle_result, wasm_byte_vec_t, wasm_exporttype_t, wasm_exporttype_vec_t, wasm_importtype_t, - wasm_importtype_vec_t, wasm_store_t, wasmtime_error_t, + handle_result, wasm_byte_vec_t, wasm_engine_t, wasm_exporttype_t, wasm_exporttype_vec_t, + wasm_importtype_t, wasm_importtype_vec_t, wasm_store_t, wasmtime_error_t, }; use std::ptr; use wasmtime::{Engine, Module}; @@ -29,7 +29,10 @@ pub extern "C" fn wasm_module_new( binary: &wasm_byte_vec_t, ) -> Option> { let mut ret = ptr::null_mut(); - match wasmtime_module_new(store, binary, &mut ret) { + let engine = wasm_engine_t { + engine: store.store.engine().clone(), + }; + match wasmtime_module_new(&engine, binary, &mut ret) { Some(_err) => None, None => { assert!(!ret.is_null()); @@ -40,13 +43,12 @@ pub extern "C" fn wasm_module_new( #[no_mangle] pub extern "C" fn wasmtime_module_new( - store: &wasm_store_t, + engine: &wasm_engine_t, binary: &wasm_byte_vec_t, ret: &mut *mut wasm_module_t, ) -> Option> { let binary = binary.as_slice(); - let store = &store.store; - handle_result(Module::from_binary(store.engine(), binary), |module| { + handle_result(Module::from_binary(&engine.engine, binary), |module| { let imports = module .imports() .map(|i| wasm_importtype_t::new(i.module().to_owned(), i.name().to_owned(), i.ty())) diff --git a/examples/externref.c b/examples/externref.c index 92785a2022..ded28bd072 100644 --- a/examples/externref.c +++ b/examples/externref.c @@ -66,7 +66,7 @@ int main() { // Now that we've got our binary webassembly we can compile our module. printf("Compiling module...\n"); wasm_module_t *module = NULL; - error = wasmtime_module_new(store, &wasm, &module); + error = wasmtime_module_new(engine, &wasm, &module); wasm_byte_vec_delete(&wasm); if (error != NULL) exit_with_error("failed to compile module", error, NULL); diff --git a/examples/fib-debug/main.c b/examples/fib-debug/main.c index e133f8d6ac..a4e22dee3c 100644 --- a/examples/fib-debug/main.c +++ b/examples/fib-debug/main.c @@ -43,7 +43,7 @@ int main(int argc, const char* argv[]) { // Compile. printf("Compiling module...\n"); wasm_module_t *module = NULL; - wasmtime_error_t* error = wasmtime_module_new(store, &binary, &module); + wasmtime_error_t* error = wasmtime_module_new(engine, &binary, &module); if (!module) exit_with_error("failed to compile module", error, NULL); wasm_byte_vec_delete(&binary); diff --git a/examples/gcd.c b/examples/gcd.c index bcbeed0940..285bc1593f 100644 --- a/examples/gcd.c +++ b/examples/gcd.c @@ -59,7 +59,7 @@ int main() { // Compile and instantiate our module wasm_module_t *module = NULL; - error = wasmtime_module_new(store, &wasm, &module); + error = wasmtime_module_new(engine, &wasm, &module); if (module == NULL) exit_with_error("failed to compile module", error, NULL); wasm_byte_vec_delete(&wasm); diff --git a/examples/hello.c b/examples/hello.c index f9d4b5982a..fd268a84de 100644 --- a/examples/hello.c +++ b/examples/hello.c @@ -67,7 +67,7 @@ int main() { // Now that we've got our binary webassembly we can compile our module. printf("Compiling module...\n"); wasm_module_t *module = NULL; - error = wasmtime_module_new(store, &wasm, &module); + error = wasmtime_module_new(engine, &wasm, &module); wasm_byte_vec_delete(&wasm); if (error != NULL) exit_with_error("failed to compile module", error, NULL); diff --git a/examples/hello.cc b/examples/hello.cc index 57cfc5f360..45ac5302ec 100644 --- a/examples/hello.cc +++ b/examples/hello.cc @@ -67,7 +67,7 @@ int main() { // Now that we've got our binary webassembly we can compile our module. printf("Compiling module...\n"); wasm_module_t *module = NULL; - error = wasmtime_module_new(store, &wasm, &module); + error = wasmtime_module_new(engine, &wasm, &module); wasm_byte_vec_delete(&wasm); if (error != NULL) exit_with_error("failed to compile module", error, NULL); diff --git a/examples/interrupt.c b/examples/interrupt.c index 81971b66bc..d2b5a3ac75 100644 --- a/examples/interrupt.c +++ b/examples/interrupt.c @@ -89,7 +89,7 @@ int main() { wasm_module_t *module = NULL; wasm_trap_t *trap = NULL; wasm_instance_t *instance = NULL; - error = wasmtime_module_new(store, &wasm, &module); + error = wasmtime_module_new(engine, &wasm, &module); wasm_byte_vec_delete(&wasm); if (error != NULL) exit_with_error("failed to compile module", error, NULL); diff --git a/examples/linking.c b/examples/linking.c index 7e6a29aed0..bc13f3cb97 100644 --- a/examples/linking.c +++ b/examples/linking.c @@ -45,10 +45,10 @@ int main() { wasmtime_error_t *error; wasm_module_t *linking1_module = NULL; wasm_module_t *linking2_module = NULL; - error = wasmtime_module_new(store, &linking1_wasm, &linking1_module); + error = wasmtime_module_new(engine, &linking1_wasm, &linking1_module); if (error != NULL) exit_with_error("failed to compile linking1", error, NULL); - error = wasmtime_module_new(store, &linking2_wasm, &linking2_module); + error = wasmtime_module_new(engine, &linking2_wasm, &linking2_module); if (error != NULL) exit_with_error("failed to compile linking2", error, NULL); wasm_byte_vec_delete(&linking1_wasm); diff --git a/examples/memory.c b/examples/memory.c index e2be709270..f430fe415b 100644 --- a/examples/memory.c +++ b/examples/memory.c @@ -158,7 +158,7 @@ int main(int argc, const char* argv[]) { // Compile. printf("Compiling module...\n"); wasm_module_t* module = NULL; - error = wasmtime_module_new(store, &binary, &module); + error = wasmtime_module_new(engine, &binary, &module); if (error) exit_with_error("failed to compile module", error, NULL); wasm_byte_vec_delete(&binary); diff --git a/examples/multi.c b/examples/multi.c index 3248ec0215..a56883884f 100644 --- a/examples/multi.c +++ b/examples/multi.c @@ -91,7 +91,7 @@ int main(int argc, const char* argv[]) { // Compile. printf("Compiling module...\n"); wasm_module_t* module = NULL; - error = wasmtime_module_new(store, &binary, &module); + error = wasmtime_module_new(engine, &binary, &module); if (error) exit_with_error("failed to compile module", error, NULL); diff --git a/examples/wasi/main.c b/examples/wasi/main.c index 68a978ccd2..2ad9592f4e 100644 --- a/examples/wasi/main.c +++ b/examples/wasi/main.c @@ -54,7 +54,7 @@ int main() { // Compile our modules wasm_module_t *module = NULL; - wasmtime_error_t *error = wasmtime_module_new(store, &wasm, &module); + wasmtime_error_t *error = wasmtime_module_new(engine, &wasm, &module); if (!module) exit_with_error("failed to compile module", error, NULL); wasm_byte_vec_delete(&wasm);