在 Chrome 中,JavaScript 运行在 V8 引擎上,但是运行 WebAssembly 代码的引擎是什么?
浏览器如何突然能够通过 WebAssembly 提供改进的性能?这个 WebAssembly 引擎是在浏览器中始终可用,还是最近才添加到浏览器中?
最佳答案
自 2017 年 11 月以来,WebAssembly 仅受所有主要浏览器(Chrome、Firefox、Safari、Edge)支持,这意味着旧版本的浏览器不支持 WebAssembly。 ( blog post from mozilla )
要了解为什么 WebAssembly 比 Javascript 更快,请参阅 Lin Clark (link) 的精彩系列。
article 的结论是报价
WebAssembly is faster than JavaScript in many cases because:
- fetching WebAssembly takes less time because it is more compact than JavaScript, even when compressed.
- decoding WebAssembly takes less time than parsing JavaScript.
- compiling and optimizing takes less time because WebAssembly is closer to machine code than JavaScript and already has gone through optimization on the server side.
- reoptimizing doesn’t need to happen because WebAssembly has types and other information built in, so the JS engine doesn’t need to speculate when it optimizes the way it does with JavaScript.
- executing often takes less time because there are fewer compiler tricks and gotchas that the developer needs to know to write consistently performant code, plus WebAssembly’s set of instructions are more ideal for machines.
- garbage collection is not required since the memory is managed manually.
关于javascript - WebAssembly 使用什么引擎?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50787083/