Skip to content

Commit

Permalink
triple, pkg_version, use engine
Browse files Browse the repository at this point in the history
  • Loading branch information
yurydelendik committed Jul 16, 2020
1 parent ed254d4 commit ac6c064
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 14 deletions.
2 changes: 1 addition & 1 deletion crates/c-api/include/wasmtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -945,7 +945,7 @@ WASM_API_EXTERN own wasmtime_error_t* wasmtime_module_serialize(
* returned error and module are owned by the caller.
*/
WASM_API_EXTERN own wasmtime_error_t *wasmtime_module_deserialize(
wasm_store_t *store,
wasm_engine_t *engine,
const wasm_byte_vec_t *serialized,
own wasm_module_t **ret
);
Expand Down
8 changes: 4 additions & 4 deletions crates/c-api/src/module.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down Expand Up @@ -144,12 +144,12 @@ pub extern "C" fn wasmtime_module_serialize(

#[no_mangle]
pub unsafe extern "C" fn wasmtime_module_deserialize(
store: &wasm_store_t,
engine: &wasm_engine_t,
binary: &wasm_byte_vec_t,
ret: &mut *mut wasm_module_t,
) -> Option<Box<wasmtime_error_t>> {
handle_result(
Module::deserialize(&store.store.engine(), binary.as_slice()),
Module::deserialize(&engine.engine, binary.as_slice()),
|module| {
let imports = module
.imports()
Expand Down
7 changes: 5 additions & 2 deletions crates/wasmtime/src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -639,8 +639,11 @@ impl Config {
self.flags.hash(state);
self.tunables.hash(state);

let tripple = Triple::host();
tripple.hash(state);
let triple = Triple::host();
triple.hash(state);

// Catch accidental bugs of reusing across wasmtime versions.
env!("CARGO_PKG_VERSION").hash(state);
}
}

Expand Down
9 changes: 2 additions & 7 deletions examples/serialize.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,6 @@ int serialize(wasm_byte_vec_t* buffer) {
wasm_engine_t *engine = wasm_engine_new();
assert(engine != NULL);

// With an engine we can create a *store* which is a long-lived group of wasm
// modules.
wasm_store_t *store = wasm_store_new(engine);
assert(store != NULL);

// Read our input file, which in this case is a wasm text file.
FILE* file = fopen("examples/hello.wat", "r");
assert(file != NULL);
Expand All @@ -67,7 +62,7 @@ int serialize(wasm_byte_vec_t* buffer) {
// and serialize into buffer.
printf("Compiling and serializing 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);
Expand Down Expand Up @@ -98,7 +93,7 @@ int deserialize(wasm_byte_vec_t* buffer) {
// Deserialize compiled module.
printf("Deserialize module...\n");
wasm_module_t *module = NULL;
wasmtime_error_t *error = wasmtime_module_deserialize(store, buffer, &module);
wasmtime_error_t *error = wasmtime_module_deserialize(engine, buffer, &module);
if (error != NULL)
exit_with_error("failed to compile module", error, NULL);

Expand Down

0 comments on commit ac6c064

Please sign in to comment.