- 浏览: 229033 次
- 性别:
- 来自: 北京
文章分类
最新评论
-
jj7jj7jj:
容我来补一刀~1,function(){ ...
执行JS匿名函数的N种方式 -
duwu:
根本就不能用,试了好多天,一次都没发送成功,发了根本就没有任何 ...
邮件发新浪微博 -
ganky:
终于搞定了,我郁闷啊……我是用JAVA写的,在登录成功后使用g ...
基于web飞信接口的飞信应答机器人 -
ganky:
之前也有搞了一下,只实现了登录,因为一直找不到webim_se ...
基于web飞信接口的飞信应答机器人 -
kewin:
现在127行了哦
基于web飞信接口的飞信应答机器人
announcing-squirrelfish
Why It’s Fast
Like the interpreters for many scripting languages, WebKit’s previous JavaScript interpreter was a simple syntax tree walker. To execute a program, it would first parse the program into a tree of statements and expressions. For example, the expression “x + y” might parse to
+
/ \
x y
Having created a syntax tree, the interpreter would recursively visit the nodes in the tree, performing their operations and propagating execution state. This execution model incurred a few types of run-time cost.
In our first rounds of optimization, we squeezed out as much performance as we could without changing this underlying architecture. Doing so allowed us to regression test each optimization we wrote. It also set a very high bar for any replacement technology. Finally, having realized the full potential of the syntax tree architecture, we switched to bytecode.
SquirrelFish’s bytecode engine elegantly eliminates almost all of the overhead of a tree-walking interpreter. First, a bytecode stream exactly describes the operations needed to execute a program. Compiling to bytecode implicitly strips away irrelevant grammatical structure. Second, a bytecode dispatch is a single direct memory read, followed by a single indirect branch. Therefore, executing a bytecode instruction is much faster than visiting a syntax tree node. Third, with the syntax tree gone, the interpreter no longer needs to propagate execution state between syntax tree nodes.
The bytecode’s register representation and calling convention work together to produce other speedups, as well. For example, jumping to the first instruction in a JavaScript function, which used to require two C++ function calls, one of them virtual, now requires just a single bytecode dispatch. At the same time, the bytecode compiler, which knows how to strip away many forms of intermediate copying, can often arrange to pass arguments to a JavaScript function without any copying.
squirrelfish-bytecode
引用
Why It’s Fast
Like the interpreters for many scripting languages, WebKit’s previous JavaScript interpreter was a simple syntax tree walker. To execute a program, it would first parse the program into a tree of statements and expressions. For example, the expression “x + y” might parse to
+
/ \
x y
Having created a syntax tree, the interpreter would recursively visit the nodes in the tree, performing their operations and propagating execution state. This execution model incurred a few types of run-time cost.
- First, a syntax tree describes a program’s grammatical structure, not the operations needed to execute it. Therefore, during execution, the interpreter would repeatedly visit nodes that did no useful work. For example, for the block “{ x++; }”, the interpreter would first visit the block node “{…}”, which did nothing, and then visit its first child, the increment node “x++”, which incremented x.
- Second, even nodes that did useful work were expensive to visit. Each visit required a virtual function call and return, which meant a couple of indirect memory reads to retrieve the function being called, and two indirect branches—one for the call, and one for the return. On modern hardware, “indirect” is a synonym for “slow”, since indirection tends to defeat caching and branch prediction.
- Third, to propagate execution state between nodes, the interpreter had to pass around a bunch of data. For example, when processing a subtree involving a local variable, the interpreter would copy the variable’s value between all the nodes in the subtree. So, starting at the “x” part of the expression “f((x) + 1)”, a variable node “x” would return x to a parentheses node “(x)”, which would return x to a plus node “(x) + 1”. Then, the plus node would return (x) + 1 to an argument list node “((x) + 1)”, which would copy that value into an argument list object, which, in turn, it would pass to the function node for f. Sheesh!
In our first rounds of optimization, we squeezed out as much performance as we could without changing this underlying architecture. Doing so allowed us to regression test each optimization we wrote. It also set a very high bar for any replacement technology. Finally, having realized the full potential of the syntax tree architecture, we switched to bytecode.
SquirrelFish’s bytecode engine elegantly eliminates almost all of the overhead of a tree-walking interpreter. First, a bytecode stream exactly describes the operations needed to execute a program. Compiling to bytecode implicitly strips away irrelevant grammatical structure. Second, a bytecode dispatch is a single direct memory read, followed by a single indirect branch. Therefore, executing a bytecode instruction is much faster than visiting a syntax tree node. Third, with the syntax tree gone, the interpreter no longer needs to propagate execution state between syntax tree nodes.
The bytecode’s register representation and calling convention work together to produce other speedups, as well. For example, jumping to the first instruction in a JavaScript function, which used to require two C++ function calls, one of them virtual, now requires just a single bytecode dispatch. At the same time, the bytecode compiler, which knows how to strip away many forms of intermediate copying, can often arrange to pass arguments to a JavaScript function without any copying.
squirrelfish-bytecode
发表评论
-
莫名其妙的javascript效果--期待合理解释
2009-09-24 16:31 844在浏览器地址栏输入下面的文本,回车。看看在IE(6)、fire ... -
Asynchronous Flash and XML
2009-08-19 21:25 1021http://www.aflax.org/ 引用Aflaxtm ... -
模拟实现console.dir函数
2009-08-13 20:48 2118function dir(obj,name,initCon ... -
method_missing in JavaScript(SpiderMonkey)
2009-08-13 20:15 1126ruby的method_missing魔法在JavaSc ... -
折磨人的XMLHttpRequest跨域请求
2009-07-29 22:29 1462听说firefox3.5的XMLHttpRequest对象支持 ... -
with-statement-considered-harmful
2009-06-26 21:00 782var obj ={a:1}; with(obj){ ... -
dojo.connect与createSequence
2009-06-21 15:20 1481Ext(YUI)扩展的Function.prototype.c ... -
dojo.require使用XMLHTTPRequest同步请求加载js
2009-06-21 14:29 2792dojo.require使用XMLHTTPRequest同步请 ... -
Ext.override在IE下不能重载constructor的原因
2009-06-21 09:56 2423下面的代码在firefox、chrome、safari、ope ... -
Adobe spry js框架的数据绑定很不错
2009-06-18 13:09 1025http://labs.adobe.com/technolog ... -
collaborative-map-reduce-in-the-browser
2009-06-13 16:18 869collaborative-map-reduce-in-the ... -
Efficient JavaScript code
2009-06-13 14:12 858http://userjs.org/help/tutorial ... -
javascript-outside-of-the-browser
2009-06-13 14:09 885javascript-outside-of-the-brows ... -
JavaScript shells
2009-06-13 13:54 717JavaScript_shells除了这个页面列举的,rinh ... -
jquery1.3源码中有趣的链接--globalEval
2009-06-11 23:02 1095http://webreflection.blogspot.c ... -
processingjs中有趣的接
2009-06-11 22:50 976processingjshttp://processingjs ... -
一个梦想--编写一个基于浏览器的JavaScript编辑器
2009-06-11 21:09 1812为什么这个梦想中的JavaScript编辑器要使用JavaSc ... -
JavaScript String match 和indexOf方法的性能测试
2009-06-08 21:42 6344function add(str,count){ if ... -
执行JS匿名函数的N种方式
2009-06-08 20:51 1821定义并且立即执行JS匿名函数有几种方法哪?我的结论是有无数种, ... -
Map/Reduce-javascript版
2009-06-07 23:28 1423/** * URL访问频率统计 * map函数 处 ...
相关推荐
对于JavaScript,由于其在不同浏览器中可能存在兼容性问题,因此进行多浏览器的单元测试显得尤为重要。本文将探讨如何集成多浏览器的JavaScript单元测试工具,以确保代码在多种浏览器环境下都能正常工作。 **选择...
- **最初的命名**:JavaScript最初被命名为“LiveScript”,但由于Java语言在当时的流行度非常高,因此将其重新命名为JavaScript,旨在借助Java的名气来推广这门新语言。 - **ECMAScript规范**:随着JavaScript的...
名词引擎,编译器与作用域浏览器不同,其引擎也不同,例如Chrome采用的是v8,Safari采用的是SquirrelFish Extreme。编译器:编译过程主要分为“词法分析”,“语法分析”和“代码生成”。作用域(范围):根据名称...
Opera在某些情况下表现优于这些浏览器,但仍然不及基于V8和SquirrelFish的引擎。 总的来说,使用局部变量可以减少标识符解析的复杂度,提高代码执行效率。这不仅适用于变量的读取,也适用于变量的写入操作。此外,...
内置的Chromelite浏览器在Android 1.5中采用了最新的Webkit引擎和Squirrelfish JavaScript引擎,网页加载速度更快,浏览体验更佳。此外,还新增了网页内容复制、页内搜索功能,以及对网页默认编码的自定义设置。这些...
1.6.8 Monkeys、Squirrelfish和其他JavaScript引擎 19 1.7 小结 20 第2章 Canvas API 22 2.1 HTML5 Canvas概述 22 2.1.1 历史 22 2.1.2 canvas是什么 23 2.1.3 canvas坐标 23 2.1.4 什么情况下不用canvas 24 2.1.5 ...
1.6.8 Monkeys、Squirrelfish和其他JavaScript引擎 19 1.7 小结 20 第2章 Canvas API 22 2.1 HTML5 Canvas概述 22 2.1.1 历史 22 2.1.2 canvas是什么 23 2.1.3 canvas坐标 23 2.1.4 什么情况下不用canvas 24 2.1.5 ...
1.6.8 Monkeys、Squirrelfish和其他JavaScript引擎 19 1.7 小结 20 第2章 Canvas API 22 2.1 HTML5 Canvas概述 22 2.1.1 历史 22 2.1.2 canvas是什么 23 2.1.3 canvas坐标 23 2.1.4 什么情况下不用canvas 24 2.1.5 ...
1.6.8 Monkeys、Squirrelfish和其他JavaScript引擎 19 1.7 小结 20 第2章 Canvas API 22 2.1 HTML5 Canvas概述 22 2.1.1 历史 22 2.1.2 canvas是什么 23 2.1.3 canvas坐标 23 2.1.4 什么情况下不用canvas 24 2.1.5 ...
1.6.8 monkeys、squirrelfish和其他javascript引擎 19 1.7 小结 20 .第2章 canvas api 22 2.1 html5 canvas概述 22 2.1.1 历史 22 2.1.2 canvas是什么 23 2.1.3 canvas坐标 23 2.1.4 什么情况下不用canvas 24...
1.6.8 Monkeys、Squirrelfish和其他JavaScript引擎 19 1.7 小结 20 第2章 Canvas API 22 2.1 HTML5 Canvas概述 22 2.1.1 历史 22 2.1.2 canvas是什么 23 2.1.3 canvas坐标 23 2.1.4 什么情况下不用canvas 24 ...
1.6.8 Monkeys、Squirrelfish和其他JavaScript引擎 19 1.7 小结 20 第2章 Canvas API 22 2.1 HTML5 Canvas概述 22 2.1.1 历史 22 2.1.2 canvas是什么 23 2.1.3 canvas坐标 23 2.1.4 什么情况下不用canvas 24 ...
1.6.8 Monkeys、Squirrelfish和其他JavaScript引擎 19 1.7 小结 20 第2章 Canvas API 22 2.1 HTML5 Canvas概述 22 2.1.1 历史 22 2.1.2 canvas是什么 23 2.1.3 canvas坐标 23 2.1.4 什么情况下不用canvas 24 ...
1.6.8 Monkeys、Squirrelfish和其他JavaScript引擎 19 1.7 小结 20 第2章 Canvas API 22 2.1 HTML5 Canvas概述 22 2.1.1 历史 22 2.1.2 canvas是什么 23 2.1.3 canvas坐标 23 2.1.4 什么情况下不用canvas 24 ...
1.6.8 Monkeys、Squirrelfish和其他JavaScript引擎 19 1.7 小结 20 第2章 Canvas API 22 2.1 HTML5 Canvas概述 22 2.1.1 历史 22 2.1.2 canvas是什么 23 2.1.3 canvas坐标 23 2.1.4 什么情况下不用canvas 24 ...
然而,随着Google Chrome和WebKit午夜版等新浏览器的出现,采用优化后的JavaScript引擎(如V8和SquirrelFish)之后,访问变量时即使作用域链深度增加,性能也不会明显下降。这些优化包括改进标识符解析过程,从而...
1.6.8 Monkeys、Squirrelfish和其他JavaScript引擎 19 1.7 小结 21 第2章 Canvas API 22 2.1 HTML5 Canvas概述 22 2.1.1 历史 22 2.1.2 canvas是什么 23 2.1.3 canvas坐标 23 2.1.4 什么情况下不用canvas 23 ...
8. **external**:集成的开源软件组件,如Webkit、SquirrelFish等。 9. **frameworks**:核心框架的代码,包括Java和C++两部分,提供了应用程序运行所需的基本服务和API。 10. **hardware**:硬件抽象层(HAL),...