I saw the following question and answer
Call webassembly from embedded v8 without JS
I tried to run the code in "Solution" with the latest version of v8, but it would not compile because the WasmCompiledModule::DeserializeOrCompile API is obsolete in V8 8.3 and later.
What is the alternative API to WasmCompiledModule::DeserializeOrCompile API
in the latest version?
Also, wasm-c-api which I know is a great one, but I would like to learn how to do it all myself, if possible.
What is the alternative API to
WasmCompiledModule::DeserializeOrCompile
API in the latest version?
As the answer to the linked question already mentions:
it will be renamed to
v8::WasmModuleObject
in next version
and, indeed, v8::WasmModuleObject
still exists in the latest V8 versions.
Also, wasm-c-api which I know is a great one, but I would like to learn how to do it all myself, if possible.
It's not the same thing.
If you want to use V8's Wasm engine without going through JS, then V8's implementation of the wasm-c-api is your only option.
If you want to use V8's regular JS-based API instead (including v8::WasmModuleObject
), then all calls into and out of Wasm will go through JS wrappers under the hood. You don't necessarily need to write any JS yourself, but the respective V8 API functions will create JS objects/functions internally, which the wasm-c-api does not.
That said, going through the regular V8 API has benefits in that it is more feature rich. Modern Wasm modules may import things like strings and regexp-handling functions, which the wasm-c-api doesn't support (yet?).