TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

ASM.JS and JavaScript V8/Node.js?

7 点作者 Pharohbot超过 10 年前
Could ASM.JS be implemented into the JavaScript V8 engine to make it much faster which in turn makes Node.js overall even faster than it is now? So basically all the JS you code with Node would be compiled to asm.js and/or Asm.js be added to V8 to create a faster VM and faster platform? Is it possible and will it happen?

2 条评论

kjksf超过 10 年前
Asm.js already runs on V8. It&#x27;s just not fast. If you want to see if&#x2F;when asm.js becomes fast in V8, see <a href="https://code.google.com/p/v8/issues/detail?id=2599" rel="nofollow">https:&#x2F;&#x2F;code.google.com&#x2F;p&#x2F;v8&#x2F;issues&#x2F;detail?id=2599</a><p>However, you don&#x27;t seem to understand what asm.js is.<p>Asm.js is not JavaScript.<p>Syntactically it does look like JavaScript but it&#x27;s really bytecode emulating CPU in JavaScript clothing.<p>As such asm.js is used to execute C code bases cross-compiled to asm.js with a tool like emscripten.<p>There is no such thing as &quot;compiling JavaScript to asm.js&quot; because there&#x27;s no point. V8 (and every other modern JS VM) already compiles JavaScript to optimized CPU instruction set so it doesn&#x27;t make sense to do JavaScript -&gt; asm.js -&gt; CPU instructions set.<p>To re-iterate: asm.js targets the same use case as p(nacl) i.e. compiling C&#x2F;C++ code bases to something that can be executed in the web.<p>See <a href="http://mrale.ph/blog/2013/03/28/why-asmjs-bothers-me.html" rel="nofollow">http:&#x2F;&#x2F;mrale.ph&#x2F;blog&#x2F;2013&#x2F;03&#x2F;28&#x2F;why-asmjs-bothers-me.html</a> for more info.
评论 #8639436 未加载
评论 #8639474 未加载
marcosscriven超过 10 年前
I&#x27;m not an asm.js expert by anyway means, but I did have some success using it. So here&#x27;s some basic facts:<p>1) asm.js <i>is</i> Javascript, albeit a strict subset<p>2) asm.js is not Emscripten. Emscripten is rather a tool that converts LLVM IR to asm.js - in fact, before asm.js was released, Emscripten still worked, albeit significantly slower.<p>3) While you can&#x27;t &#x27;compile&#x27; Javascript to asm.js, you could in theory manually convert it - the reason it&#x27;s so closely associated with C&#x2F;C++ is that there&#x27;s type information available to do the conversion to asm.js automatically<p>4) Just as an example, asm.js works by doing things like bitwise ORing numbers with zero to make it possible for the Javascript engine to immediately know you&#x27;re actually only dealing with integers. In that sense it gives you AOT-like potential, rather than running the loop a few hundred times to see what you&#x27;re getting before JITing it.<p>With V8, Google seem to be taking the approach it&#x27;s better to optimise more generally, rather than focussing on asm.js.