微软表示 IE9 具有并行 Javascript 渲染和执行功能
新的 JavaScript 引擎通过 Windows 利用多个 CPU 内核来并行解释、编译和运行代码。
- http://technet.microsoft.com/en-us/library/gg699435.aspx
和
Chakra 引擎解释、编译和并行执行代码并利用多个 CPU 内核(如果可用)。
- http://msdn.microsoft.com/en-us/ie/ff468705.aspx
等等,什么?!?这是否意味着我们在 IE9 中拥有多线程并行 JavaScript 代码执行(在 Web Workers 之外)?
我认为这只是一个糟糕的营销噱头,但希望看到更多相关信息。也许他们意味着不同的浏览器窗口/选项卡/进程可以利用多个 CPU?
The new JavaScript engine takes advantage of multiple CPU cores through Windows to interpret, compile, and run code in parallel.
- http://technet.microsoft.com/en-us/library/gg699435.aspx
and
The Chakra engine interprets, compiles, and executes code in parallel and takes advantage of multiple CPU cores, when available.
- http://msdn.microsoft.com/en-us/ie/ff468705.aspx
Wait, what?!? Does this mean we've got multi-threaded parallel JavaScript code execution (outside of web-workers) in IE9?
I'm thinking this is just a bad marketing gimmick but would like to see some more info on this. Maybe they mean different browser windows/tabs/processes can utilize multiple CPUs?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
结论主要基于评论,因此作为社区 wiki 答案提供,以便该问题最终得到实际答案:
Microsoft 的意思很可能是(i)解释和/或运行的单独任务; (ii) 编译并行进行。他们很可能已经应用了像 Sun 的旧 HotSpot JVM 这样的技术,以便 Javascript 虚拟机在第一个实例中解释代码,因为它可以立即开始执行此操作。它还会 JIT 编译任何看起来足够频繁使用的代码,这样做是有好处的。它甚至可能有不同级别的编译器优化,需要慢慢调整。在这种情况下,它可能会使用多个核心来解释或运行一个代码片段,同时还编译任意多个其他代码片段,甚至重新编译并更好地优化正在运行的同一代码片段。
但是,在技术层面上,您也可以执行静态分析来确定回调何时在状态方面相互独立,并允许这些回调在触发事件提示时并行执行。通过这种方式,Javascript 虚拟机实际上可以并行解释/运行代码,而不影响该语言的语义串行性质。这样的系统在逻辑上类似于超标量 CPU 的操作,尽管移除程度要大得多并且复杂性要高得多。
Conclusions, based largely on the comments and hence provided as a community wiki answer so that this question ends up with an actual answer:
It's likely that Microsoft mean that the separate tasks of (i) interpreting and/or running; and (ii) compiling occur in parallel. It's probable that they've applied technology like Sun's old HotSpot JVM so that the Javascript virtual machine interprets code at the first instance because it can start doing that instantly. It also JIT compiles any code that appears to be used sufficiently frequently for doing so to be a benefit. It may even have different levels of compiler optimisation that it slowly dials up. In that case it may be using multiple cores to interpret or run one fragment of code while also compiling arbitrarily many others, or even while recompiling and better optimising the same piece of code that is being run.
However, it's also possible on a technical level that you could perform static analysis to determine when callbacks are mutually independent in terms of state, and allow those callbacks to execute in parallel if the triggering events prompted them to do so. In that way a Javascript virtual machine could actually interpret/run code in parallel without affecting the semantically serial nature of the language. Such a system would be logically similar to the operation of superscalar CPUs, albeit at a much greater remove and with significantly greater complexity.