Javascript en­gines

OpenSource For You - - CODE SPORT -

JavaScript is a high-level lan­guage and an en­gine is needed to run the code. A JavaScript en­gine typ­i­cally con­tains a parser, an in­ter­preter and a run­time mod­ule. The parser parses the JavaScript code into to­kens, typ­i­cally build­ing an ab­stract syn­tax tree to rep­re­sent the JavaScript pro­gram. The in­ter­preter walks the ab­stract syn­tax tree and in­ter­prets the in­ter­me­di­ate rep­re­sen­ta­tion con­tained in it. While ear­lier ver­sions of JavaScript en­gines used the sim­pler AST walk­ing in­ter­preter de­sign, things have changed quite a bit in later en­gines. Th­ese parse the JavaScript to an in­ter­me­di­ate form, which typ­i­cally con­tains byte-codes. An in­ter­preter trans­lates the byte-codes and op­tion­ally sup­ports a JIT com­piler, which can trans­late byte-codes to na­tive code. There are trade-offs in­volved in hav­ing an in­ter­preter rather than a JavaScript com­piler. In­ter­preters are faster on ap­pli­ca­tion start-up, be­cause they don't rep­re­sen­ta­tions; hence, their start-up la­tency is quite low. On the other hand, a JavaScript com­piler can con­vert the in­ter­me­di­ate rep­re­sen­ta­tion into ma­chine or na­tive code—and, of course, na­tive code ex­e­cu­tion is con­sid­er­ably faster than in­ter­preted code.

who in­vented JavaScript, was code-named Spi­derMon­key and was im­ple­mented in C. Rhino, from Mozilla Cor­po­ra­tion ( http://www.mozilla.org/rhino/), is an open source im­ple­men­ta­tion of a JavaScript en­gine writ­ten in Java. The Squir­relFish Ex­treme en­gine (code named Nitro in the Sa­fari browser) uses in­ter­preted byte-codes with cer­tain hot parts of the code be­ing trans­lated by the JIT com­piler into ma­chine lan­guage. TraceMon­key, em­bed­ded in Mozilla’s Fire­Fox browser, em­ploys a sim­i­lar tech­nol­ogy. The in­ter­nals of TraceMon­key are de­scribed in a pa­per pre­sented at the ACM Con­fer­ence on Pro­gram­ming Lan­guages De­sign and Im­ple­men­ta­tion (PLDI) 2009, which is avail­able at http://www. cs.ucsb.edu/~ck­rintz/gal-pldi09.pdf.

https://de­vel­op­ers.google.com/v8/. num­ber of op­ti­mi­sa­tions. Re­call that I had ear­lier men­tioned the over­heads in re­cur­sive prop­erty lookup fol­low­ing pro­to­type prop­erty ac­cess, by what are known as hid­den classes. Th­ese are based on the premise that an ob­ject’s prop­er­ties are typ­i­cally un­likely to change af­ter it has been ini­tialised. Hence the ob­ject struc­ture is cap­tured in hid­den classes, and an ob­ject’s hid­den class changes when a new prop­erty is added. The con­cept of hid­den classes is not new, but in­her­ited from the www. sel an­guage.org found at https://de­vel­op­ers.google.com/v8/de­sign. I will dis­cuss

Newspapers in English

Newspapers from India

© PressReader. All rights reserved.