SpiderMonkey

Print Print
Reading time 9:29

SpiderMonkey
Spidermonkey-logo-2021.svg
Developer(s)Mozilla Foundation
Mozilla Corporation
Repository Edit this at Wikidata
Written inC, C++, Rust
Operating systemCross-platform
PlatformIA-32, x86-64, ARM, MIPS, SPARC[1]
TypeJavaScript engine
LicenseMPL 2.0[2]
Websitespidermonkey.dev

SpiderMonkey is the code name for the first JavaScript engine, written by Brendan Eich at Netscape Communications, later released as open source and currently maintained by the Mozilla Foundation. It is still used in the Firefox web browser.

History

Eich "wrote JavaScript in ten days" in 1995,[3] having been "recruited to Netscape with the promise of 'doing Scheme' in the browser".[4] (The idea of using Scheme was abandoned when "engineering management [decided] that the language must 'look like Java'".)[4] In late 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".[3] (Mocha was the original working name for the language.)[4][5] In 2011, Eich transferred management of the SpiderMonkey code to Dave Mandelin.[3]

Versions

SpiderMonkey version history
Version Release date Corresponding ECMAScript version Browser version Added functionality
Old version, no longer maintained: 1.0 March 1996 Netscape Navigator 2.0
Old version, no longer maintained: 1.1 August 1996 Netscape Navigator 3.0
Old version, no longer maintained: 1.2 June 1997 Netscape Navigator 4.0 - 4.05
Old version, no longer maintained: 1.3 October 1998 ECMA-262 1st + 2nd edition Netscape Navigator 4.06-4.7x
Old version, no longer maintained: 1.4 Netscape Server
Old version, no longer maintained: 1.5 November 2000 ECMA-262 3rd edition Netscape Navigator 6, Firefox 1.0
Old version, no longer maintained: 1.6 November 2005[6] Firefox 1.5 additional array methods, array and string generics, E4X
Old version, no longer maintained: 1.7 October 2006 Firefox 2.0 iterators and generators, let statement, array comprehensions, destructuring assignment
Old version, no longer maintained: 1.8 June 2008 Firefox 3.0 generator expressions, expression closures
Old version, no longer maintained: 1.8.5 March 2011 ECMA-262 5th edition Firefox 4.0 JSON support
Old version, no longer maintained: 1.8.8 January 2012 Firefox 10.0
Old version, no longer maintained: 17 November 2012 Firefox 17.0
Old version, no longer maintained: 24 September 2013 Firefox 24.0
Old version, no longer maintained: 31 July 2014 Firefox 31.0
Old version, no longer maintained: 38 May 2015 Firefox 38.0
Old version, no longer maintained: 45 March 2016 Firefox 45.0
Old version, no longer maintained: 52 March 2017 Firefox 52.0
Old version, no longer maintained: 60 May 2018 Firefox 60.0
Old version, no longer maintained: 68 July 2019 Firefox 68.0
Current stable version: 78 June 2020 Firefox 78.0
Future release: 90 2021 Firefox 90.0

Standards

SpiderMonkey implements the ECMA-262 specification (ECMAScript). ECMA-357 (ECMAScript for XML (E4X)) was dropped in early 2013.[7]

Internals

SpiderMonkey is written in C/C++ and contains an interpreter, the IonMonkey JIT compiler, and a garbage collector.

TraceMonkey

TraceMonkey[8] was the first JIT compiler written for the JavaScript language. Initially introduced as an option in a beta release and introduced in Brendan Eich's blog on August 23, 2008,[9] the compiler became part of the mainline release 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.[10]

Instead of compiling whole functions, TraceMonkey was a tracing JIT, which operates by recording control flow and data types during interpreter execution. This data then informed the construction of trace trees, highly specialized paths of native code.

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

JägerMonkey

JägerMonkey, internally named MethodJIT, was a whole-method JIT compiler designed to improve performance in cases where TraceMonkey could not generate stable native code.[12][13] It was first released in Firefox 4 and eventually entirely supplanted TraceMonkey. It has itself been replaced by IonMonkey.

JägerMonkey operated very differently from other compilers in its class: while typical compilers worked by constructing and optimizing a control-flow graph representing the function, JägerMonkey instead operated 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.[14]

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's 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.[15]

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.[16]

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.[17]

OdinMonkey

OdinMonkey is the name of Mozilla's new optimization module for asm.js, an easily compilable subset of JavaScript. OdinMonkey itself is not a JIT compiler, it uses the current JIT compiler. It's included with Firefox from release 22.

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
  • Data storage applications:
    • MongoDB moved from V8 to SpiderMonkey in version 3.2[18]
    • Riak uses SpiderMonkey as the runtime for JavaScript MapReduce operations[19]
    • CouchDB database system (written in Erlang). JavaScript is used for defining maps, filters, reduce functions and viewing data, for example in HTML format.
  • Adobe Acrobat and Adobe Reader, Adobe Flash Professional, and Adobe Dreamweaver. Adobe Acrobat DC uses Spidermonkey 24.2 with ECMA-357 support forward ported.[20]
  • GNOME desktop environment, version 3 and later
  • Yahoo! Widgets, formerly named Konfabulator
  • FreeSWITCH, open-source telephony engine, uses SpiderMonkey to allow users to write call management scripts in JavaScript
  • The text-based web browser ELinks uses SpiderMonkey to support JavaScript[21]
  • Parts of SpiderMonkey are used in the Wine project's JScript (re-)implementation[22]
  • 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
  • SpiderMonkey is also used in many other open-source projects; an external list is maintained at Mozilla's developer site.[23]

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

See also

References

  1. ^ "1.8.8 - SpiderMonkey | MDN". Developer.mozilla.org. 10 January 2013. Archived from the original on 2 May 2013. Retrieved 21 March 2013.
  2. ^ Mozilla Licensing Policies, mozilla.org, archived from the original on 2 April 2013, retrieved 26 March 2013
  3. ^ a b c Eich, Brendan (21 June 2011). "New JavaScript Engine Module Owner". BrendanEich.com. Archived from the original on 14 July 2011. Retrieved 1 July 2011.
  4. ^ a b c Eich, Brendan (3 April 2008). "Popularity". BrendanEich.com. Archived from the original on 3 July 2011. Retrieved 1 July 2011.
  5. ^ Eich, Brendan (19 August 2011). "Mapping the Monkeysphere". Archived from the original on 13 January 2013. Retrieved 19 August 2011.
  6. ^ "New in JavaScript 1.6". Archived from the original on 5 September 2015. Retrieved 28 July 2015.
  7. ^ "759422 – Remove use of e4x in account creation". Retrieved 5 February 2013.
  8. ^ "JavaScript:TraceMonkey, MozillaWiki". Retrieved 22 July 2020.
  9. ^ "TraceMonkey: JavaScript Lightspeed, Brendan Eich's Blog". Retrieved 22 July 2020.
  10. ^ Paul, Ryan (22 August 2008). "Firefox to get massive JavaScript performance boost". Ars Technica. Archived from the original on 6 May 2012. Retrieved 21 March 2013.
  11. ^ Nethercote, Nicholas (1 November 2011). "SpiderMonkey is on a diet | Nicholas Nethercote". Blog.mozilla.com. Archived from the original on 28 March 2012. Retrieved 21 March 2013.
  12. ^ "JaegerMonkey – Fast JavaScript, Always! » Mystery Bail Theater". Bailopan.net. 26 February 2010. Archived from the original on 24 March 2013. Retrieved 21 March 2013.
  13. ^ Paul, Ryan (9 March 2010). "Mozilla borrows from WebKit to build fast new JS engine". Ars Technica. Archived from the original on 16 April 2012. Retrieved 21 March 2013.
  14. ^ "JaegerMonkey - MozillaWiki". Wiki.mozilla.org. Archived from the original on 23 August 2013. Retrieved 21 March 2013.
  15. ^ "Platform/Features/IonMonkey - MozillaWiki". Wiki.mozilla.org. 11 February 2013. Archived from the original on 8 March 2013. Retrieved 21 March 2013.
  16. ^ "IonMonkey: Mozilla's new JavaScript JIT compiler". Infoq.com. Archived from the original on 8 December 2012. Retrieved 21 March 2013.
  17. ^ "Firefox Notes - Desktop". Mozilla.org. 8 January 2013. Archived from the original on 2 September 2014. Retrieved 21 March 2013.
  18. ^ "JavaScript Changes in MongoDB 3.2 — MongoDB Manual 3.4". Archived from the original on 6 June 2017. Retrieved 23 November 2016.
  19. ^ "The Release Riak 0.8 and JavaScript Map/Reduce". Archived from the original on 3 November 2011. Retrieved 24 April 2011.
  20. ^ "Acrobat DC SDK Documentation". help.adobe.com. Retrieved 27 February 2020. Core JavaScript engine has migrated to version 24.2 of SpiderMonkey (the underlying JavaScript engine from Mozilla).
  21. ^ Bolso, Erik Inge (8 March 2005). "2005 Text Mode Browser Roundup". Linux Journal. Archived from the original on 15 March 2010. Retrieved 5 August 2010.
  22. ^ wine-cvs mailing list Archived 7 February 2009 at the Wayback Machine, 16 September 2008: "jscript: Added regular expression compiler based on Mozilla regexp implementation"
  23. ^ "SpiderMonkey > FOSS". MDN Web Docs. Retrieved 2 April 2019.
  24. ^ "Introduction to the JavaScript shell". MDN. Mozilla Developer Network. 29 September 2010. Archived from the original on 29 June 2011. Retrieved 14 December 2010. 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 [...]

By: Wikipedia.org
Edited: 2021-06-18 12:37:46
Source: Wikipedia.org