HOME

TheInfoList



OR:

SpiderMonkey is an
open-source Open source is source code that is made freely available for possible modification and redistribution. Products include permission to use and view the source code, design documents, or content of the product. The open source model is a decentrali ...
JavaScript JavaScript (), often abbreviated as JS, is a programming language and core technology of the World Wide Web, alongside HTML and CSS. Ninety-nine percent of websites use JavaScript on the client side for webpage behavior. Web browsers have ...
and
WebAssembly WebAssembly (Wasm) defines a portable binary-code format and a corresponding text format for executable programs as well as software interfaces for facilitating communication between such programs and their host environment. The main goal of ...
engine by the
Mozilla Foundation The Mozilla Foundation is an American non-profit organization that exists to support and collectively lead the Open-source software, open source Mozilla project. Founded in July 2003, the organization sets the policies that govern development, ...
. The engine powers the
Firefox Mozilla Firefox, or simply Firefox, is a free and open-source web browser developed by the Mozilla Foundation and its subsidiary, the Mozilla Corporation. It uses the Gecko rendering engine to display web pages, which implements curr ...
Web browser A web browser, often shortened to browser, is an application for accessing websites. When a user requests a web page from a particular website, the browser retrieves its files from a web server and then displays the page on the user's scr ...
and has used multiple generations of JavaScript just-in-time (JIT) compilers, including TraceMonkey, JägerMonkey, IonMonkey, and the current WarpMonkey. It is the first
JavaScript engine The first engines for JavaScript were mere interpreters of the source code, but all relevant modern engines use just-in-time compilation for improved performance. JavaScript engines are typically developed by web browser vendors, and every maj ...
, written by
Brendan Eich Brendan Eich ( ; born July 4, 1961) is an American computer programmer and technology executive. He created the JavaScript programming language and co-founded the Mozilla project, the Mozilla Foundation, and the Mozilla Corporation. He serve ...
at
Netscape Netscape Communications Corporation (originally Mosaic Communications Corporation) was an American independent computer services company with headquarters in Mountain View, California, and then Dulles, Virginia. Its Netscape web browser was o ...
Communications, and later released as open source and currently maintained by the Mozilla Foundation. Its design allows it to be embedded in applications beyond Web browsers, with implementations including MongoDB database system, Adobe Acrobat, and the GNOME desktop environment.


History

Eich "wrote JavaScript in ten days" in 1995, having been "recruited to Netscape with the promise of 'doing Scheme' in the browser". (The idea of using Scheme was abandoned when "engineering management ecidedthat the language must 'look like
Java Java is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea (a part of Pacific Ocean) to the north. With a population of 156.9 million people (including Madura) in mid 2024, proje ...
.) In late 1996, Eich, needing to "pay off hesubstantial
technical debt In software development and other information technology fields, technical debt (also known as design debt or code debt) refers to the implied cost of additional work in the future resulting from choosing an expedient solution over a more robust o ...
" left from the first year, "stayed home for two weeks to rewrite Mocha as the codebase that became known as SpiderMonkey". (Mocha was the original working name for the language.) In 2011, Eich transferred management of the SpiderMonkey code to Dave Mandelin.


Versions


Standards

SpiderMonkey implements the ECMA-262 specification (
ECMAScript ECMAScript (; ES) is a standard for scripting languages, including JavaScript, JScript, and ActionScript. It is best known as a JavaScript standard intended to ensure the interoperability of web pages across different web browsers. It is stan ...
). ECMA-357 ( ECMAScript for XML (E4X)) was dropped in early 2013.


Internals

SpiderMonkey is written in C/ C++ and contains an
interpreter Interpreting is translation from a spoken or signed language into another language, usually in real time to facilitate live communication. It is distinguished from the translation of a written text, which can be more deliberative and make use o ...
, the WarpMonkey
JIT compiler In computing, just-in-time (JIT) compilation (also dynamic translation or run-time compilations) is compiler, compilation (of Source code, computer code) during execution of a program (at run time (program lifecycle phase), run time) rather than b ...
, and a garbage collector.


TraceMonkey

TraceMonkey 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, 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 Mozilla Firefox 3.0 is a version of the Firefox web browser released on June 17, 2008, by the Mozilla Corporation. Firefox 3.0 uses version 1.9 of the Gecko (layout engine), Gecko layout engine for displaying web pages. This version fixes many b ...
. Instead of compiling whole functions, TraceMonkey was a tracing JIT, which operates by recording
control flow In computer science, control flow (or flow of control) is the order in which individual statements, instructions or function calls of an imperative program are executed or evaluated. The emphasis on explicit control flow distinguishes an '' ...
and
data type In computer science and computer programming, a data type (or simply type) is a collection or grouping of data values, usually specified by a set of possible values, a set of allowed operations on these values, and/or a representation of these ...
s during interpreter execution. This data then informed the construction of trace trees, highly specialized paths of
native code In computer programming, machine code is computer program, computer code consisting of machine language instruction set architecture, instructions, which are used to control a computer's central processing unit (CPU). For conventional binary ...
. Improvements to JägerMonkey eventually made TraceMonkey obsolete, especially with the development of the SpiderMonkey
type inference Type inference, sometimes called type reconstruction, refers to the automatic detection of the type of an expression in a formal language. These include programming languages and mathematical type systems, but also natural languages in some bran ...
engine. TraceMonkey is absent from SpiderMonkey from Firefox 11 onward.


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 In computer programming, machine code is computer program, computer code consisting of machine language instruction set architecture, instructions, which are used to control a computer's central processing unit (CPU). For conventional binary ...
. 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 Bytecode (also called portable code or p-code) is a form of instruction set designed for efficient execution by a software interpreter. Unlike human-readable source code, bytecodes are compact numeric codes, constants, and references (normal ...
, 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 Type inference, sometimes called type reconstruction, refers to the automatic detection of the type of an expression in a formal language. These include programming languages and mathematical type systems, but also natural languages in some bran ...
. The difference between TraceMonkey and JägerMonkey JIT techniques and the need for both was explained i
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
dvanderdmandelin


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. IonMonkey was a more traditional compiler: it translated SpiderMonkey
bytecode Bytecode (also called portable code or p-code) is a form of instruction set designed for efficient execution by a software interpreter. Unlike human-readable source code, bytecodes are compact numeric codes, constants, and references (normal ...
into a control-flow graph, using static single assignment form (SSA) for the
intermediate representation An intermediate representation (IR) is the data structure or code used internally by a compiler or virtual machine to represent source code. An IR is designed to be conducive to further processing, such as optimization and translation. A "good" ...
. This architecture enabled well-known optimizations from other programming languages to be used for JavaScript, including type specialization, function inlining, linear-scan
register allocation In compiler optimization, register allocation is the process of assigning local automatic variables and Expression (computer science), expression results to a limited number of processor registers. Register allocation can happen over a basic bloc ...
,
dead code elimination In compiler theory, dead-code elimination (DCE, dead-code removal, dead-code stripping, or dead-code strip) is a compiler optimization to remove dead code (code that does not affect the program results). Removing such code has several benefits: i ...
, and
loop-invariant code motion In computer programming, loop-invariant code consists of statements or expressions (in an imperative programming, imperative programming language) that can be moved outside the body of a loop without affecting the semantics of the program. Loop-i ...
. The compiler can emit fast
native code In computer programming, machine code is computer program, computer code consisting of machine language instruction set architecture, instructions, which are used to control a computer's central processing unit (CPU). For conventional binary ...
translations of JavaScript functions on the ARM,
x86 x86 (also known as 80x86 or the 8086 family) is a family of complex instruction set computer (CISC) instruction set architectures initially developed by Intel, based on the 8086 microprocessor and its 8-bit-external-bus variant, the 8088. Th ...
, and
x86-64 x86-64 (also known as x64, x86_64, AMD64, and Intel 64) is a 64-bit extension of the x86 instruction set architecture, instruction set. It was announced in 1999 and first available in the AMD Opteron family in 2003. It introduces two new ope ...
platforms. It has been the default engine since Firefox 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. 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 An intermediate representation (IR) is the data structure or code used internally by a compiler or virtual machine to represent source code. An IR is designed to be conducive to further processing, such as optimization and translation. A "good" ...
(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.


Use

SpiderMonkey is intended to be embedded in other applications that provide host environments for JavaScript. An incomplete list follows: * Mozilla
Firefox Mozilla Firefox, or simply Firefox, is a free and open-source web browser developed by the Mozilla Foundation and its subsidiary, the Mozilla Corporation. It uses the Gecko rendering engine to display web pages, which implements curr ...
, Thunderbird,
SeaMonkey SeaMonkey is a free and open-source Internet suite. It is the continuation of the former Mozilla Application Suite, based on the same source code, which itself grew out of Netscape Communicator and formed the base of Netscape 6 and Netscape ...
, and other applications that use the
Mozilla application framework The Mozilla application framework is a collection of cross-platform Within computing, cross-platform software (also called multi-platform software, platform-agnostic software, or platform-independent software) is computer software that is desi ...
**
Forks In cutlery or kitchenware, a fork (from 'pitchfork') is a Eating utensil, utensil, now usually made of metal, whose long handle terminates in a head that branches into several narrow and often slightly curved tine (structural), tines with whic ...
of Firefox including the
Pale Moon Pale Moon is a free and open-source web browser licensed under the MPL-2.0 with an emphasis on customization. There are official releases for Microsoft Windows, FreeBSD, macOS, and Linux. Pale Moon originated as a fork of Firefox, but has subs ...
,
Basilisk In European bestiary, bestiaries and legends, a basilisk ( or ) is a legendary reptile reputed to be a Serpent symbolism, serpent king, who causes death to those who look into its eyes. According to the ''Natural History (Pliny), Naturalis Histo ...
and
Waterfox Waterfox is a free and open-source web browser and fork of Firefox. It claims to be ethical and user-centric, emphasizing performance and privacy. There are official Waterfox releases for Windows, macOS, Linux and Android. It was initially cr ...
web browsers. *Data storage applications: **
MongoDB MongoDB is a source-available, cross-platform, document-oriented database program. Classified as a NoSQL database product, MongoDB uses JSON-like documents with optional database schema, schemas. Released in February 2009 by 10gen (now MongoDB ...
moved from V8 to SpiderMonkey in version 3.2 ** Riak uses SpiderMonkey as the runtime for JavaScript MapReduce operations ** 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 Adobe Acrobat is a family of application software and web services developed by Adobe Inc. to view, create, manipulate, print and manage Portable Document Format (PDF) files. The family comprises Acrobat Reader (formerly Reader), Acrobat (former ...
and Adobe Reader, Adobe Flash Professional, and
Adobe Dreamweaver Adobe Dreamweaver is a proprietary web development tool from Adobe. It was created by Macromedia in 1997 and developed by them until Macromedia was acquired by Adobe Systems in 2005. Adobe Dreamweaver is available for the macOS and Windows oper ...
. Adobe Acrobat DC uses Spidermonkey 24.2 with ECMA-357 support forward ported. *
GNOME A gnome () is a mythological creature and diminutive spirit in Renaissance magic and alchemy, introduced by Paracelsus in the 16th century and widely adopted by authors, including those of modern fantasy literature. They are typically depict ...
desktop environment, version 3 and later *
Cinnamon Cinnamon is a spice obtained from the inner bark of several tree species from the genus ''Cinnamomum''. Cinnamon is used mainly as an aromatic condiment and flavouring additive in a wide variety of cuisines, sweet and savoury dishes, biscuits, b ...
desktop environment, version 1.0 and later *
Yahoo! Widgets Yahoo Widgets is a discontinued free application platform for Mac OS X and Microsoft Windows, specifically Windows XP, Vista and Windows 7. The software was previously called Konfabulator, but after being acquired by computer services company Yah ...
, formerly named Konfabulator * FreeSWITCH, open-source telephony engine, uses SpiderMonkey to allow users to write call management scripts in JavaScript * PythonMonkey uses SpiderMonkey to allow users to write programs where JavaScript and Python functions, types, and events interoperate and (where possible) share memory storage. * The text-based web browser
ELinks ELinks is a free text-based web browser for Linux, DOS, and Windows operating systems. It began in late 2001 as an experimental fork by Petr Baudiš of the Links Web browser, hence the E in the name. Since then, the E has come to stand for En ...
uses SpiderMonkey to support JavaScript * Parts of SpiderMonkey are used in the
Wine Wine is an alcoholic drink made from Fermentation in winemaking, fermented fruit. Yeast in winemaking, Yeast consumes the sugar in the fruit and converts it to ethanol and carbon dioxide, releasing heat in the process. Wine is most often made f ...
project's
JScript JScript is Microsoft's legacy dialect of the ECMAScript standard that is used in Microsoft's Internet Explorer web browser and HTML Applications, and as a standalone Windows scripting language. JScript is implemented as an Active Scripting eng ...
(re-)implementation * Synchronet, a BBS, e-mail, Web, and application server using the SpiderMonkey engine * JavaScript OSA, a SpiderMonkey
inter-process communication In computer science, interprocess communication (IPC) is the sharing of data between running Process (computing), processes in a computer system. Mechanisms for IPC may be provided by an operating system. Applications which use IPC are often cat ...
language for the Mac computer * '' 0 A.D.'', a real-time strategy game * Wasmer has incorporated SpiderMonkey into their WinterJS open-source project; a JavaScript runtime environment. * SpiderMonkey is also used in many other open-source projects; an external list is maintained at Mozilla's developer site. SpiderMonkey includes a JavaScript Shell for interactive JavaScript development and for command-line invocation of JavaScript program files.


See also

* Rhino (JavaScript engine) * List of ECMAScript engines


References


External links

* , SpiderMonkey (JavaScript-C) engine
Firefox (and Spidermonkey) Release Calendar
{{DEFAULTSORT:Spidermonkey (JavaScript engine) Cross-platform software JavaScript engines Mozilla Software using the Mozilla Public License