Komputer Sains    
   
Daftar Isi
(Sebelumnya) Spider-Man (1994 TV series)Spin coating (Berikutnya)

SpiderMonkey (JavaScript engine)

SpiderMonkey
Developer(s)Mozilla Foundation / Mozilla Corporation
Development statusActive
Written inC/C++
Operating systemCross-platform
PlatformIA-32, x86-64, ARM, MIPS, SPARC [1]
TypeJavaScript engine
LicenseMPL-GPL-LGPL tri-license
Websitedeveloper.mozilla.org/en/SpiderMonkey

SpiderMonkey is the code name for the first-ever JavaScript engine, written by Brendan Eich at Netscape Communications, later released as open source and now maintained by the Mozilla Foundation. SpiderMonkey currently provides JavaScript support for Mozilla Firefox and various embeddings such as the GNOME 3 desktop.

Contents

History

Eich "wrote JavaScript in ten days" in 1995,[2] having been "recruited to Netscape with the promise of 'doing Scheme' in the browser".[3] (The idea of using Scheme was abandoned when "engineering management [decided] that the language must ‘look like Java’".[3]) In the fall of 1996, Eich, needing to "pay off [the] substantial technical debt" left from the first year, "stayed home for two weeks to rewrite Mocha as the codebase that became known as SpiderMonkey".[2] The name SpiderMonkey was chosen as a reference to the movie Beavis and Butt-head Do America, in which the character Tom Anderson mentions that the title characters were "whacking off like a couple of spider monkeys."[4] In 2011, Eich transferred management, termed ownership, of the SpiderMonkey code to Dave Mandelin.[2]

Standards

SpiderMonkey implements ECMA-262 edition 5 (ECMAScript) and several added features. ECMA-357 (ECMAScript for XML (E4X)) was dropped in early 2013 .[5]

Even though SpiderMonkey is used in Firefox, it does not provide host environments such as Document Object Model (DOM).

Internals

SpiderMonkey is written in C/C++ and contains an interpreter, several JIT compilers (formerly TraceMonkey; JägerMonkey, and currently IonMonkey), a decompiler, and a garbage collector.

TraceMonkey

TraceMonkey is the first JIT compiler written for the JavaScript language. The compiler was first released as part of SpiderMonkey in Firefox 3.5, providing "performance improvements ranging between 20 and 40 times faster" than the baseline interpreter in Firefox 3.[6]

Instead of compiling whole functions, TraceMonkey is a tracing JIT that operates by recording control flow and data types during interpreter execution. This data then informs the construction of Trace Trees, highly specialized paths of native code.

Improvements to JägerMonkey have made TraceMonkey obsolete, especially with the development of the SpiderMonkey type inference engine. TraceMonkey is absent from SpiderMonkey from Firefox 11 onward.[7]

JägerMonkey

JägerMonkey, internally named MethodJIT, is a whole-method JIT compiler designed to improve performance in cases where TraceMonkey cannot generate stable native code.[8][9] It was first released in Firefox 4 and has since entirely supplanted TraceMonkey.

JägerMonkey operates very differently from other compilers in its class: while typical compilers work by constructing and optimizing a control flow graph representing the function, JägerMonkey instead operates by iterating linearly forward through SpiderMonkey bytecode, the internal function representation. Although this prohibits optimizations that require instruction reordering, JägerMonkey compiling has the advantage of being very fast, which is useful for JavaScript since recompiling due to changing variable types is frequent.

Mozilla implemented a number of critical optimizations in JägerMonkey, most importantly polymorphic inline caches and type inference.[10]

The difference between TraceMonkey and JägerMonkey JIT techniques and the need for both was explained in a hacks.mozilla.org article. A more in-depth explanation of the technical details was provided by Chris Leary, one of SpiderMonkey developers, in a blog post. More technical information can be found in other developer's blogs: dvander, dmandelin.

IonMonkey

IonMonkey is the name of Mozilla’s current JavaScript JIT compiler, which aims to enable many new optimizations that were impossible with the prior JägerMonkey architecture.[11]

IonMonkey is a more traditional compiler: it translates SpiderMonkey bytecode into a control flow graph, using static single assignment form (SSA) for the intermediate representation. This architecture enables well-known optimizations from other programming languages to be used for JavaScript, including type specialization, function inlining, linear-scan register allocation, dead code elimination, and loop-invariant code motion.[12]

The compiler can emit fast native code translations of JavaScript functions on the ARM, x86, and x86-64 platforms. It is the default engine since Firefox 18.[13]

Use

SpiderMonkey is intended to be embedded in other applications that provide host environments for JavaScript. An incomplete list follows:

  • Mozilla Firefox, Thunderbird, SeaMonkey, and other applications that use the Mozilla application framework
  • Adobe Acrobat and Adobe Reader, Adobe Flash Professional, and Adobe Dreamweaver
  • GNOME desktop environment, version 3 and later
  • Yahoo! Widgets, formerly named Konfabulator
  • UOX3, an Ultima Online server emulator
  • Sphere suite of applications primarily intended to aid in designing role-playing games.
  • The Methabot web crawler uses SpiderMonkey in a multi-threaded environment for running user-provided filetype and URL parsers
  • It is also used in CouchDB database system written in Erlang - JavaScript is used for defining maps, filters, reduce functions and viewing data for example in HTML format
  • MongoDB, another NoSQL database system uses SpiderMonkey for server-side JavaScript execution[14]
  • FreeSWITCH, open-source telephony engine, uses SpiderMonkey to provide users with ability to write call management scripts in JavaScript
  • SPOT SIP Engine, a standards-based commercial computer telephony product
  • ELinks, a text-based web browser, uses SpiderMonkey to support JavaScript[15]
  • Parts of SpiderMonkey are used in the Wine project's Jscript (re-)implementation[16]
  • SpiderMonkey is also used in many other open-source projects, see https://developer.mozilla.org/en/Spid erMonkey/FOSS
  • Riak uses SpiderMonkey as the runtime for JavaScript MapReduce operations[17]
  • Synchronet, a BBS, e-mail, Web, and application server using the SpiderMonkey engine
  • JavaScript OSA, a SpiderMonkey inter-process communication language for the Macintosh computer
  • 0 A.D., a real-time strategy game
  • SAP HANA Application Services, for creating business logic on the HANA engine/app server

SpiderMonkey includes a JavaScript Shell for interactive JavaScript development and for command-line invocation of JavaScript program files.[18]

Several[quantify] large organizations use SpiderMonkey to manage their JavaScript for front-end applications.

See also

References

  1. ^ https://developer.mozilla.org/en-US/d ocs/SpiderMonkey/1.8.8#Platform_suppo rt
  2. ^ a b c Eich, Brendan (21 June 2011). "New JavaScript Engine Module Owner". BrendanEich.com. http://brendaneich.com/2011/06/new-ja vascript-engine-module-owner/.
  3. ^ a b Eich, Brendan (3 April 2008). "Popularity". BrendanEich.com. http://brendaneich.com/2008/04/popula rity/.
  4. ^ Eich, Brendan (19 August 2011). "Mapping the Monkeysphere". http://blog.cdleary.com/2011/06/mappi ng-the-monkeysphere/#comment-22216311 5.
  5. ^ "759422 – Remove use of e4x in account creation". https://bugzilla.mozilla.org/show_bug .cgi?id=759422#c0. Retrieved 05 February 2013.
  6. ^ http://arstechnica.com/news.ars/post/ 20080822-firefox-to-get-massive-javas cript-performance-boost.html
  7. ^ http://blog.mozilla.com/nnethercote/2 011/11/01/spidermonkey-is-on-a-diet/
  8. ^ http://www.bailopan.net/blog/?p=683
  9. ^ http://arstechnica.com/open-source/ne ws/2010/03/mozilla-borrows-from-webki t-to-build-fast-new-js-engine.ars
  10. ^ https://wiki.mozilla.org/JaegerMonkey
  11. ^ https://wiki.mozilla.org/Platform/Fea tures/IonMonkey
  12. ^ http://www.infoq.com/news/2011/05/ion monkey
  13. ^ http://www.mozilla.org/en-US/firefox/ 18.0/releasenotes/
  14. ^ http://www.mongodb.org/display/DOCS/B uilding+Spider+Monkey
  15. ^ Bolso, Erik Inge (8 March 2005). "2005 Text Mode Browser Roundup". Linux Journal. http://www.linuxjournal.com/article/8 148?page=0,1. Retrieved 5 August 2010.
  16. ^ wine-cvs mailing list, September 16, 2008: “jscript: Added regular expression compiler based on Mozilla regexp implementation”
  17. ^ "The Release Riak 0.8 and JavaScript Map/Reduce". http://basho.com/blog/technical/2010/ 02/03/the-release-riak-0.8-and-javasc ript-mapreduce/. Retrieved 2011-04-24.
  18. ^ "Introduction to the JavaScript shell". MDN. Mozilla Developer Network. 2010-09-29. https://developer.mozilla.org/En/Spid erMonkey/Introduction_to_the_JavaScri pt_shell. Retrieved 2010-12-14. "The JavaScript shell is a command-line program included in the SpiderMonkey source distribution. [...] You can use it as an interactive shell [...] You can also pass in, on the command line, a JavaScript program file to run [...]"

External links

(Sebelumnya) Spider-Man (1994 TV series)Spin coating (Berikutnya)