With the release of Google Chrome, the Web should be said to be a new growth in the old tree. Without a breakthrough in technology itself, every step is moving forward at a faster speed. For example:
◆ JavaScript. Now, every browser is comparing who executes faster. When you catch up with me, there is no doubt that the Web becomes faster and the application capabilities become more and more powerful. The Internet Explorer 6 and FF2 have now become the "History" of the old ox.
◆ The Web standardization speed is getting faster and faster, and the popularization of CSS and HTML 5 is getting faster and faster. Mobile phones are also quickly aligned with Web standards from WAP. In the past, more Web development tends to lean towards IE, and more are now tilted towards standardization.
◆ Battles with Flash, especially apple's distinctive banners that do not support Flash, especially when Flash is abandoned on pre-sold iPad, promoting the rapid expansion of HTML 5 functions from traditional text images to 2D, animation, video and other fields will pose a threat to private technologies such as Flash. BKJIA Editor note: Adobe executives have recently responded, "It may take a short time for HTML 5 to catch up with Flash. Moreover, it may never catch up with it ")
All of this means that the Web is working towards the 2nd spring festival. This article tries to collect the JavaScript acceleration mechanisms of mainstream browsers and explore how far JavaScript will take in the future?
Firefox 3.6 Trace JIT Technology
Under the pressure of Chrome, Firefox quickly released the TraceMonkey engine, which features:
1. The JS interpreter first converts the source code into the JavaScript bytecode LIR), and each bytecode is SSAStatic Single Assignment. This Bytecode is similar to Java Bytecode in some format. The difference is that JavaScript bytecode lacks type information. Therefore, in the process of interpretation, it needs to be selectively processed based on the current data. Therefore, each command involves more complex runtime type checks and dynamic dispatch.
2. TraceMonkey first runs the command in interpreted mode, but redirects the loop backward.) special attention: every backward jump command indicates the beginning of a loop. TraceJIT focuses on loop optimization, when a loop starts, TraceMoney tries to trace all the commands in a loop and pull a flat trace tree ).
3. Each execution clue has assumed its internal type information. During the execution of this clue, the related Bytecode can be understood as having been replaced by a typed Bytecode similar to Java's Bytecode. This type of bytecode is directly executed in the form of machine code after simple JIT compilation. When the clue execution starts, the type information will be checked. If the type does not match, a new execution clue may be generated.
4. Execution clues include methods inline and other technologies.
It should be said that this Trace technology is completely different from the previous method level JIT. In suitable applications, Trace JIT has higher execution efficiency than V8.
V8
Chrome V8 is undoubtedly the fuse of this browser war, and it still takes time to verify its success. V8 optimization mechanism:
◆ Fast Property Access. Quick object attribute access. It is characterized by converting JS access to object attributes from a dynamic search process to static access similar to Java/C ++. There is no doubt that in JavaScript, object attribute access is the most frequent type of operations, and this dynamic search process is actually quite time-consuming.
◆ Dynamic machine code generation. This is also related to quick attribute access. It converts a dynamic JS object into a static layout object similar to Java.
◆ Effective GC. V8 provides a GC mechanism for stop-the-world, generational, and accurate. FF does not provide a generational GC. In practical application, the generational GC is obviously more efficient than the non-generational GC. This is also required by Java Hotspot.
Others, Opera 10.50 claims to have launched the fastest JS engine in the world. However, since there is no documentation, it is not clear about its internal mechanism.
Prediction:
The FF optimization mechanism is different from the V8 optimization mechanism. The two are completely complementary. Therefore, we can imagine that if we introduce V8's optimization mechanism, such as fast object attribute access and generational GC, combined with the Trace JIT technology, we believe that the speed will increase significantly. Similarly, for V8, if Trace technology is introduced to make a more accurate prediction of the runtime type, the execution speed should be significantly improved.
To sum up, these optimization technologies give JavaScript more powerful processing capabilities, allowing browsers to "download and execute" larger applications more quickly. So that the functions originally needed to be completed in the "native" language can be supported in the script language at the beginning.