| 1 | = JavaScriptCore = |
| 2 | |
| 3 | JavaScriptCore is the built-in JavaScript engine for WebKit. It currently implements [http://en.wikipedia.org/wiki/ECMAScript ECMAScript] as in [http://www.ecma-international.org/publications/standards/Ecma-262.htm ECMA-262 specification]. |
| 4 | |
| 5 | JavaScriptCore is often referred with different names, such as [http://www.webkit.org/blog/189/announcing-squirrelfish/ SquirrelFish] and [http://www.webkit.org/blog/214/introducing-squirrelfish-extreme/ SquirrelFish Extreme]. Within the context of Safari, Nitro and Nitro Extreme (the marketing terms from Apple) are also commonly used. However, the name of the project and the library is always '''JavaScriptCore'''. |
| 6 | |
| 7 | JavaScriptCode source code resides in WebKit source tree, it's under [http://trac.webkit.org/browser/trunk/Source/JavaScriptCore Source/JavaScriptCore] directory. |
| 8 | |
| 9 | Note that while Chromium uses WebKit as the rendering engine, it [http://googlecode.blogspot.com/2008/09/google-chrome-chromium-and-v8-launch.html does not] use JavaScriptCore as the JavaScript engine. Rather, Chromium uses [http://code.google.com/p/v8/ V8] (which is not a WebKit project). |
| 10 | |
| 11 | == Core Engine == |
| 12 | |
| 13 | Like a typical scripting engine, JavaScriptCore consists of the following building blocks: lexer, parser, and interpreter. |
| 14 | |
| 15 | '''Lexer''' is responsible for the [http://en.wikipedia.org/wiki/Lexical_analysis lexical analysis], i.e. breaking down the script source into a series of ''tokens''. JavaScriptCore lexer is hand-written, it is mostly in [http://trac.webkit.org/browser/trunk/Source/JavaScriptCore/parser/Lexer.h parser/Lexer.h] and [http://trac.webkit.org/browser/trunk/Source/JavaScriptCore/parser/Lexer.cpp parser/Lexer.cpp]. |
| 16 | |
| 17 | '''Parser''' carries out the [http://en.wikipedia.org/wiki/Parser syntactic analysis], i.e. consuming the tokens from the lexer and building the corresponding syntax tree. JavaScriptCore uses a hand-written [http://en.wikipedia.org/wiki/Recursive_descent_parser recursive descent parser], the code is in |
| 18 | [http://trac.webkit.org/browser/trunk/Source/JavaScriptCore/parser/JSParser.h parser/JSParser.h] and [http://trac.webkit.org/browser/trunk/Source/JavaScriptCore/parser/JSParser.cpp parser/JSParser.cpp]. |
| 19 | |
| 20 | '''Interpreter''' executes the bytecodes produced by the parser. JavaScriptCore has two types of interpreter: bytecode-based and JIT-based. The former runs the bytecodes in a virtual machine, the latter uses JIT (Just-in-time) compiling approach to produce native machine codes in order to have a faster execution. The bulk of the interpreter code is in [http://trac.webkit.org/browser/trunk/Source/JavaScriptCore/interpreter interpreter/] subdirectory with the JIT compiler in [http://trac.webkit.org/browser/trunk/Source/JavaScriptCore/jit jit/] subdirectory. |
| 21 | |
| 22 | (More to be written) |
| 23 | |
| 24 | == Runtime == |
| 25 | |
| 26 | (To be written) |
| 27 | |
| 28 | == Binding == |
| 29 | |
| 30 | (To be written) |