如何将Javascript翻译成字节码? [英] How is Javascript translated to bytecode?

查看:382
本文介绍了如何将Javascript翻译成字节码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法在网络上找到有关W3C语言如何编译为机器代码的信息。我知道网络和处理器之间的差距必须是某种程度的浏览器,但是它是如何工作的,以及在处理器中执行Javascript之前的步骤是什么?

I can't find information on the web how W3C languages compile to machine code. I know that the gap between the web and the processor must be somehow the browser, but how does it work and what are the steps till Javascript is executed in the processor?

推荐答案

这取决于实现; 规范是对该语言的完整描述,以及它应该如何工作,实现方式自由地以任何他们喜欢的方式满足该实现。一些实现似乎(从外部)运行它纯粹作为旧意义上的解释器;其他可能或可能不会编译为字节码; V8会编译为机器码(两次,用于应用中的热点)。

It's up to the implementation; the specification is the full description of the language and how it's supposed to work, implementations are free to satisfy that implementation in any way they like. Some implementations seem (from the outside) to run it purely as an interpreter in the old sense; others may or may not compile to bytecode; V8 compiles to machine code (twice, for hotspots in the app).

V8团队(V8是Chromium和Chrome中的JavaScript引擎)定期发布关于他们如何从V8中获得梦幻般的速度的描述。您可以在项目网站 Chromium blog

The V8 team (V8 being the JavaScript engine in Chromium and Chrome) periodically publish descriptions of how they get the fantastic speed out of V8 that they do. You may find some of that on the project site and the Chromium blog.

当然,您也可以踢任何开源实现的代码。 V8和SpiderMonkey(Mozilla的引擎)是我知道的两个主要开源的。

Naturally, you can also kick around the code of any of the open-source implementations. V8 and SpiderMonkey (Mozilla's engine) are the two major open-source ones I know.

这篇关于如何将Javascript翻译成字节码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆