SpiderMonkey (JavaScript Engine)

Short description: JavaScript engine maintained by the Mozilla Foundation

SpiderMonkey

Developer(s)| Mozilla Foundation
Mozilla Corporation
Written in| C, C++, Rust
Operating system| Cross-platform
Platform| IA-32, x86-64, ARM, MIPS, SPARC[1]
Type| JavaScript engine
License| MPL 2.0[2]
Website| spidermonkey.dev

SpiderMonkey is 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.[3]

## Contents

* 1 History
* 1.1 Versions
* 2 Standards
* 3 Internals
* 3.1 TraceMonkey
* 3.2 JägerMonkey
* 3.3 IonMonkey
* 3.4 OdinMonkey
* 3.5 WarpMonkey
* 4 Use
* 5 See also
* 6 References
* 7 External links

## History

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

### Versions

SpiderMonkey version history  Version  | Release date  | Corresponding ECMAScript version  | Browser version  | Added functionality

|
|
|
|

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

## Standards

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

## Internals

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

### TraceMonkey

TraceMonkey[9] 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,[10] 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.[11]

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

### 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.[13][14] 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.[15]

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 was a JavaScript JIT compiler of Mozilla, which was aimed to enable many new optimizations that were impossible with the prior JägerMonkey architecture.[16]

IonMonkey was a more traditional compiler: it translated SpiderMonkey bytecode into a control-flow graph, using static single assignment form (SSA) for the intermediate representation. This architecture enabled 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.[17]

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

### 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.

### WarpMonkey

The WarpMonkey JIT replaces the former IonMonkey engine from version 83.[19] It is able to inline other scripts and specialize code based on the data and arguments being processed. It translates the bytecode and Inline Cache data into a Mid-level Intermediate Representation (Ion MIR) representation. This graph is transformed and optimized before being lowered to a Low-level Intermediate Representation (Ion LIR). This LIR performs register allocation and then generates native machine code in a process called Code Generation. The optimizations here assume that a script continues to see data similar what has been seen before. The Baseline JITs are essential to success here because they generate ICs that match observed data. If after a script is compiled with Warp, it encounters data that it is not prepared to handle it performs a bailout. The bailout mechanism reconstructs the native machine stack frame to match the layout used by the Baseline Interpreter and then branches to that interpreter as though we were running it all along. Building this stack frame may use special side-table saved by Warp to reconstruct values that are not otherwise available.[20]

## 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
* Forks of Firefox including the Pale Moon, Basilisk and Waterfox web browsers.
* Data storage applications:
* MongoDB moved from V8 to SpiderMonkey in version 3.2[21]
* Riak uses SpiderMonkey as the runtime for JavaScript MapReduce operations[22]
* 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.[23][|permanent dead link|dead link}}]
* 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[24]
* Parts of SpiderMonkey are used in the Wine project's JScript (re-)implementation[25]
* 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.[26]
* Sparx Systems Enterprise Architect, a commercial UML, SysML, BPMN, ArchiMate modelling tool: scripts can be created within the project to call the tool's own API

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

## See also

* Rhino (JavaScript engine)
* List of ECMAScript engines

## References

1. ↑ "1.8.8 - SpiderMonkey | MDN". Developer.mozilla.org. 10 January 2013. https://developer.mozilla.org/en-US/docs/SpiderMonkey/1.8.8#Platform_support.
2. ↑ Mozilla Licensing Policies, mozilla.org, https://www.mozilla.org/foundation/licensing.html, retrieved 26 March 2013
3. ↑ "Home" (in en-US). https://spidermonkey.dev/.
4. ↑ 4.0 4.1 4.2 Eich, Brendan (21 June 2011). "New JavaScript Engine Module Owner". BrendanEich.com. http://brendaneich.com/2011/06/new-javascript-engine-module-owner/.
5. ↑ 5.0 5.1 5.2 Eich, Brendan (3 April 2008). "Popularity". BrendanEich.com. http://brendaneich.com/2008/04/popularity/.
6. ↑ Eich, Brendan (19 August 2011). "Mapping the Monkeysphere". http://blog.cdleary.com/2011/06/mapping-the-monkeysphere/#comment-222163115.
7. ↑ "New in JavaScript 1.6". https://developer.mozilla.org/en-US/docs/Web/JavaScript/New_in_JavaScript/1.6.
8. ↑ "759422 - Remove use of e4x in account creation". https://bugzilla.mozilla.org/show_bug.cgi?id=759422#c0.
9. ↑ "JavaScript:TraceMonkey, MozillaWiki". https://wiki.mozilla.org/JavaScript:TraceMonkey.
10. ↑ "TraceMonkey: JavaScript Lightspeed, Brendan Eich's Blog". https://brendaneich.com/2008/08/tracemonkey-javascript-lightspeed/.
11. ↑ Paul, Ryan (22 August 2008). "Firefox to get massive JavaScript performance boost". Ars Technica. https://arstechnica.com/news.ars/post/20080822-firefox-to-get-massive-javascript-performance-boost.html.
12. ↑ Nethercote, Nicholas (1 November 2011). "SpiderMonkey is on a diet | Nicholas Nethercote". Blog.mozilla.com. http://blog.mozilla.com/nnethercote/2011/11/01/spidermonkey-is-on-a-diet/.
13. ↑ "JaegerMonkey – Fast JavaScript, Always! » Mystery Bail Theater". Bailopan.net. 26 February 2010. http://www.bailopan.net/blog/?p=683.
14. ↑ Paul, Ryan (9 March 2010). "Mozilla borrows from WebKit to build fast new JS engine". Ars Technica. https://arstechnica.com/open-source/news/2010/03/mozilla-borrows-from-webkit-to-build-fast-new-js-engine.ars.
15. ↑ "JaegerMonkey - MozillaWiki". Wiki.mozilla.org. https://wiki.mozilla.org/JaegerMonkey.
16. ↑ "Platform/Features/IonMonkey - MozillaWiki". Wiki.mozilla.org. 11 February 2013. https://wiki.mozilla.org/Platform/Features/IonMonkey.
17. ↑ "IonMonkey: Mozilla’s new JavaScript JIT compiler". Infoq.com. http://www.infoq.com/news/2011/05/ionmonkey.
18. ↑ "Firefox Notes - Desktop". Mozilla.org. 8 January 2013. https://website-archive.mozilla.org/www.mozilla.org/firefox_releasenotes/en-US/firefox/18.0/releasenotes/.
19. ↑ "Warp: Improved JS performance in Firefox 83 – Mozilla Hacks - the Web developer blog" (in en-US). 13 November 2020. https://hacks.mozilla.org/2020/11/warp-improved-js-performance-in-firefox-83.
20. ↑ "SpiderMonkey — Firefox Source Docs documentation". https://firefox-source-docs.mozilla.org/js/index.html.
21. ↑ "JavaScript Changes in MongoDB 3.2 — MongoDB Manual 3.4". https://docs.mongodb.com/manual/release-notes/3.2-javascript.
22. ↑ "The Release Riak 0.8 and JavaScript Map/Reduce". http://basho.com/blog/technical/2010/02/03/the-release-riak-0.8-and-javascript-mapreduce/.
23. ↑ "Acrobat DC SDK Documentation". https://help.adobe.com/en_US/acrobat/acrobat_dc_sdk/2015/HTMLHelp/#t=Acro12_MasterBook/JS_API_AcroJSChanges/Acrobat_DC_changes.htm. "Core JavaScript engine has migrated to version 24.2 of SpiderMonkey (the underlying JavaScript engine from Mozilla)."
24. ↑ Bolso, Erik Inge (8 March 2005). "2005 Text Mode Browser Roundup". Linux Journal. http://www.linuxjournal.com/article/8148?page=0,1.
25. ↑ wine-cvs mailing list , 16 September 2008: "jscript: Added regular expression compiler based on Mozilla regexp implementation"
26. ↑ "SpiderMonkey > FOSS" (in en). https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey/FOSS.
27. ↑ "Introduction to the JavaScript shell". MDN. Mozilla Developer Network. 29 September 2010. https://developer.mozilla.org/En/SpiderMonkey/Introduction_to_the_JavaScript_shell. "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

* , SpiderMonkey (JavaScript-C) engine
* Documentation for SpiderMonkey
* Spidermonkey's page for Open Source Links
* Are We Fast Yet? (Official benchmark and comparison)

* v
* t
* e

Mozilla

Projects

| Mozilla
Labs|

* Bugzilla
* ChatZilla
* Electrolysis Project
* Jetpack
* Lightning
* Persona
* Prism
* Raindrop
* Skywriter
* Sunbird
* PDF.js
* Sync
* Tinderbox
* Ubiquity

|

Mozilla
Research|

* asm.js
* Daala
* Firefox OS
* OpenFlint
* Open Media
* Rust
* Servo
* Shumway
* WebAssembly
* WebVR

Mozilla
Foundation|

* Mozilla Location Service
* SeaMonkey
* Thunderbird

| Firefox|

* Firefox Browser

* 1
* 1.5
* 2
* 3
* 3.5
* 3.6
* 4
* 5–current
* Future releases
* for Android
* Preview
* for iOS
* Focus

* Firefox Lockwise
* Firefox Monitor
* Firefox Send
* IRL - Online Life is Real Life

|

Origins|

* Mozilla Application Suite
* Netscape Navigator
* Netscape Communicator
* Netscape Communications
* Beonex Communicator

Forks|

* Basilisk
* BurningDog
* Classilla
* Flock
* Gnuzilla
* Goanna
* Iceape
* IceCat
* Icedove
* Iceowl
* Miro
* Netscape 9
* Pale Moon
* Portable Edition
* Swiftfox
* Swiftweasel
* TenFourFox
* UXP
* Waterfox
* xB Browser

Frameworks|

* Add-on
* Gecko
* Necko
* NPAPI
* XPConnect
* XBL
* XPCOM
* XPInstall
* XUL
* XULRunner

Components|

* Composer
* NSPR
* NSS
* Rhino
* SpiderMonkey
* Tamarin

Typefaces|

* Fira Sans
* Zilla Slab

Discontinued|

* Calendar Project
* Camino
* Firefox Home
* Grendel
* Minimo

Discontinued projects are in italics. Some projects abandoned by Mozilla that are still maintained by third parties are in bold.

Organization

| Foundation|

* Former Mozilla Organization
* Mozilla Foundation

|

Subsidiaries|

* Mozilla Corporation
* Mozilla Messaging
* Mozilla Online

Official affiliates|

* Mozilla China
* Mozilla Europe
* Mozilla Japan
* Mozilla Taiwan

People|

* Mitchell Baker
* David W. Barron
* Sheeri Cabral
* Tantek Çelik
* Brendan Eich
* John Hammink
* Robert O'Callahan
* Johnny Stenbäck
* Doug Turner
* Boris Zbarsky

Community

* mozdev.org
* Mozilla Add-ons
* MDN Web Docs
* MozillaZine
* Spread Firefox

Other topics

* The Book of Mozilla
* Code Rush
* Mozilla Public License
* Localizations
* Mascot
* Rebranding / forking

* v
* t
* e

ECMAScript

Dialects|

* ActionScript
* Caja
* JavaScript
* engines
* asm.js
* JScript
* JScript .NET
* QtScript
* TypeScript
* WMLScript

Engines
(comparison)|

* Carakan
* Futhark
* InScript
* JavaScriptCore
* JScript
* KJS
* Linear B
* Narcissus
* QtScript
* Rhino
* SpiderMonkey
* TraceMonkey
* JägerMonkey
* Tamarin
* V8
* ChakraCore
* Chakra
* JScript .NET
* Nashorn

Frameworks|

| Client-side|

* Chaplin.js
* Dojo
* Echo
* Ext JS
* Google Web Toolkit
* jQuery
* Lively Kernel
* midori
* MochiKit
* MooTools
* Prototype
* Pyjs
* qooxdoo
* Rialto
* Rico
* script.aculo.us
* SmartClient
* SproutCore
* Spry
* Wakanda Framework

|

Server-side|

* AppJet
* Jaxer
* Node.js
* WakandaDB

Multiple|

* Cappuccino
* Objective-J
* PureMVC

Libraries|

* Backbone.js
* SWFObject
* SWFAddress
* Underscore.js

People|

* Brendan Eich
* Douglas Crockford
* John Resig
* Scott Isaacs

Other|

* DHTML
* Ecma International
* JSDoc
* JSGI
* JSHint
* JSLint
* JSON
* JSSS
* Sputnik
* SunSpider
* Asynchronous module definition
* CommonJS

Lists
JavaScript libraries
Ajax frameworks
Comparisons
JavaScript frameworks
server-side JavaScript

0.00

(0 votes)

|

Retrieved from "https://handwiki.org/wiki/index.php?title=Software:SpiderMonkey_(JavaScript_Engine)&oldid=1070117"
*[v]: View this template
*[t]: Discuss this template
*[e]: Edit this template