Clone data segments when specified with load args (#3463)
Follow-up on https://github.com/bytecodealliance/wasm-micro-runtime/pull/3389, specifically: https://github.com/bytecodealliance/wasm-micro-runtime/pull/3389#discussion_r1600872451 If we want to free the wasm binary buffer early, we need to clone the data segments into the module. That's because, in case of [passive data segments](https://webassembly.github.io/threads/core/syntax/modules.html#syntax-data), they can be referred during wasm execution.
This commit is contained in:
@ -89,6 +89,12 @@ main(int argc, char *argv_main[])
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (wasm_runtime_is_underlying_binary_freeable(module)) {
|
||||
printf("Able to free wasm binary buffer.\n");
|
||||
wasm_runtime_free(buffer);
|
||||
buffer = NULL;
|
||||
}
|
||||
|
||||
module_inst = wasm_runtime_instantiate(module, stack_size, heap_size,
|
||||
error_buf, sizeof(error_buf));
|
||||
if (!module_inst) {
|
||||
@ -96,12 +102,6 @@ main(int argc, char *argv_main[])
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (wasm_runtime_is_underlying_binary_freeable(module_inst)) {
|
||||
printf("Able to free wasm binary buffer.\n");
|
||||
wasm_runtime_free(buffer);
|
||||
buffer = NULL;
|
||||
}
|
||||
|
||||
char *args[1] = { "3" };
|
||||
success = wasm_application_execute_func(module_inst, "mul7", 1, args);
|
||||
if (!success) {
|
||||
|
||||
Reference in New Issue
Block a user