我很想知道网上大会(Wasm)的代码在浏览器中是如何运作的。 我的理解是,浏览器中的 Java成文法由 Java本发动机执行,但我对谁执行Wasm binary不知。 是否也是 Java本发动机?
Additionally, I d like to understand how asynchronous JavaScript functions interact with Wasm. When we load a Wasm binary through JavaScript and call an exported Wasm function, it s added to the JavaScript call stack. But what happens if the Wasm function calls an asynchronous JavaScript function inside its body? Is the callback of the asynchronous function added to the JS queue stack? Do JS and Wasm share the same call stack and event queue, or do they each have their own? If they each have their own stacks and queues, how do they coordinate execution?
让我们在瓦萨姆模块中说,我们把联合材料作为同义功能进口,把它称作我们的一项 was子功能。
(import "env" "async_js"
(func $async_js (param i32) (result i32)))
(func $fnc (result i32)
(call $async_js (i32.const 1))
;; other code here
)
现在,当装上 was子模块时,我们便称起 f功能。
wasm.instance.exports.fnc()
So, the JS async function is called, the callback of the JS async function is added to the js queue stack and the rest of the wasm fnc function is executed, right? but how does the browser know where to continue or how to switch between wasm and js?