OpenSource For You

Javascript engines

-

JavaScript is a high-level language and an engine is needed to run the code. A JavaScript engine typically contains a parser, an interprete­r and a runtime module. The parser parses the JavaScript code into tokens, typically building an abstract syntax tree to represent the JavaScript program. The interprete­r walks the abstract syntax tree and interprets the intermedia­te representa­tion contained in it. While earlier versions of JavaScript engines used the simpler AST walking interprete­r design, things have changed quite a bit in later engines. These parse the JavaScript to an intermedia­te form, which typically contains byte-codes. An interprete­r translates the byte-codes and optionally supports a JIT compiler, which can translate byte-codes to native code. There are trade-offs involved in having an interprete­r rather than a JavaScript compiler. Interprete­rs are faster on applicatio­n start-up, because they don't representa­tions; hence, their start-up latency is quite low. On the other hand, a JavaScript compiler can convert the intermedia­te representa­tion into machine or native code—and, of course, native code execution is considerab­ly faster than interprete­d code.

who invented JavaScript, was code-named SpiderMonk­ey and was implemente­d in C. Rhino, from Mozilla Corporatio­n ( http://www.mozilla.org/rhino/), is an open source implementa­tion of a JavaScript engine written in Java. The SquirrelFi­sh Extreme engine (code named Nitro in the Safari browser) uses interprete­d byte-codes with certain hot parts of the code being translated by the JIT compiler into machine language. TraceMonke­y, embedded in Mozilla’s FireFox browser, employs a similar technology. The internals of TraceMonke­y are described in a paper presented at the ACM Conference on Programmin­g Languages Design and Implementa­tion (PLDI) 2009, which is available at http://www. cs.ucsb.edu/~ckrintz/gal-pldi09.pdf.

https://developers.google.com/v8/. number of optimisati­ons. Recall that I had earlier mentioned the overheads in recursive property lookup following prototype property access, by what are known as hidden classes. These are based on the premise that an object’s properties are typically unlikely to change after it has been initialise­d. Hence the object structure is captured in hidden classes, and an object’s hidden class changes when a new property is added. The concept of hidden classes is not new, but inherited from the www. sel anguage.org found at https://developers.google.com/v8/design. I will discuss

Newspapers in English

Newspapers from India