
WebAssembly in Action
A browser’s JavaScript engine monitors the code until it’s satisfied it knows the variable
types before it can convert that section of JavaScript into machine code.
With WebAssembly, your code is compiled into the WebAssembly binary format ahead of
time. Because the variable types are all known in advance, when the browser loads the
WebAssembly file, the JavaScript engine doesn’t need to monitor the code. It can compile
the binary format straight into machine code.
JavaScript
Browser
function add(a, b){
return (a + b);
}
01110001001...
JavaScript compiled
to machine code
C++ Wasm
Developer
C++ compiled to
WebAssembly binary
Wasm
Browser
WebAssembly binary
compiled to machine code
01110001001...
评论0