1, An interpreter evaluator page
http://cs.calstatela.edu/~abbott/Courses/CS_320a/JavaScript/evalJavaScript.html
2, WebKit’s core JavaScript engine just got a new interpreter, code-named SquirrelFish
SquirrelFish is fast—much faster than WebKit’s previous interpreter. Check out the numbers. On the SunSpider JavaScript benchmark, SquirrelFish is 1.6 times faster than WebKit’s previous interpreter.
http://webkit.org/blog/189/announcing-squirrelfish/
与之前的解释器使用遍历语法树的实现方式不同的是,SquirrelFish的实现采用字节码。
遍历语法树实现方式存在的高代价问题,在SquirrelFish字节码引擎中基本都不存在。首先,一个字节码流能够精确描述执行程序所需的操作,编译成字节码实际上隐性地跳过了不相关的语法结构。其次,字节码调度程序只是一个简单地从内存中直接读取,转而间接调度分支程序的过程。因此,执行字节码指令要比访问语法树节点快得多。第三,由于不再需要语法树,解释器无需继续在语法树节点间传送执行状态。
解释器使用字节码之后能够直接从字节码解释的所有的优化中获益匪浅,这也意味着SquirrelFish的速度还会继续得到提升。
在解析器使用字节码之后,我们目前实现的编译时优化有:
常量折叠(constant folding)
更强的拷贝传播
类型推断——包括精确和推测两种方式
基于表达式上下文的特化——尤其是void和boolean上下文
窥孔优化(peephole optimization)
逃逸分析 (escape analysis)
SquirrelFish团队特别对那些在同一领域工作的人们表示了感谢,正是他们的研究成果激发了SquirrelFish的开发灵感。
3, Some great introductory reading on these topics includes:(from http://webkit.org/blog/189/announcing-squirrelfish/)
The Structure and Performance of Efficient Interpreters (Introduces the fundamentals of virtual machine design and explains the importance of direct threading)
http://citeseer.ist.psu.edu/cache/papers/cs/32018/http:zSzzSzwww.jilp.orgzSzvol5zSzv5paper12.pdf/ertl03structure.pdf
Virtual Machine Showdown: Stack Versus Registers (Details the benefits of register machines, and the importance of copy propagation)
http://www.sagecertification.org/events/vee05/full_papers/p153-yunhe.pdf
The Implementation of Lua 5.0 (Outlines the implementation of a real-world register-based bytecode engine, with a sliding register window calling convention)
http://www.tecgraf.puc-rio.br/~lhf/ftp/doc/jucs05.pdf