Javascript编译还是双路解释

Javascript编译还是双路解释

本文介绍了Javascript编译还是双路解释?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是一位被认可的新手JavaScript程序员,并且正试图学习更多。所以我转向你们寻求帮助,这个简单的问题:)。我正在阅读的O'Reilly书一直提到JavaScript代码的编译时间。我对函数式编程(方案等)的知识告诉我,JavaScript实际上是由浏览器解释的,很可能需要两次通过JavaScript。

I'm an admitted novice JavaScript programmer and am attempting to learn more. So I turn to you folks for help, with this easy question :). The O'Reilly book that I'm reading keeps referring to the compile-time of the JavaScript code. My knowledge of functional programming (scheme and the likes) tells me that the JavaScript is actually interpreted by the browser, most likely requiring two passes through the JavaScript.

我在评估中错误吗?或者,本书的编译时间实际上只是解释器的第一遍,类似于Perl或Python的功能?谢谢!

Am I incorrect in my assessment? Or is the compile-time that the book references actually just the first pass of the interpreter, similar to how Perl or Python would function? Thanks!

推荐答案

它依赖于浏览器。查看WebKit的SquirrelFish Extreme和Google V8,看看最快的事情是什么,并查看Mozilla的JaegerMonkey的实现。

It is browser-dependent. Look up WebKit's SquirrelFish Extreme and Google V8 to see what's at the fastest end of things, and look at Mozilla's JaegerMonkey for that implementation.

AFIAK V8和SFX是JIT,所以他们将JS代码编译为本机。 JaegerMonkey和TraceMonkey在Firefox中结合,形成一个系统,如果代码被追踪得更快,TraceMonkey就会执行它,如果代码的本地速度更快,JaegerMonkey就像SFX一样编译它。

AFIAK V8 and SFX are JITs, so they compile JS code to native. JaegerMonkey and TraceMonkey combine in Firefox to form a system where if code would be faster traced, TraceMonkey executes it, and if code were faster native, JaegerMonkey compiles it, just like SFX.

这篇关于Javascript编译还是双路解释?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-21 15:51