TraceMonkey
   HOME

TheInfoList



OR:

SpiderMonkey is the first
JavaScript engine A JavaScript engine is a software component that executes JavaScript code. The first JavaScript engines were mere interpreters, but all relevant modern engines use just-in-time compilation for improved performance. JavaScript engines are typica ...
, 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 served ...
at Netscape Communications, later released as open source and currently maintained by the
Mozilla Foundation The Mozilla Foundation (stylized as moz://a) is an American non-profit organization that exists to support and collectively lead the open source Mozilla project. Founded in July 2003, the organization sets the policies that govern development, ...
. It is used in 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 current ...
web browser A web browser is application software 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 screen. Browsers are used o ...
.


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.) In late 1996, Eich, needing to "pay off hesubstantial
technical debt In software development, technical debt (also known as design debt or code debt) is the implied cost of additional rework caused by choosing an easy (limited) solution now instead of using a better approach that would take longer. Analogous with ...
" 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 JavaScript standard intended to ensure the interoperability of web pages across different browsers. It is standardized by Ecma International in the documenECMA-262 ECMAScript is commonly used for client-side scripting o ...
). ECMA-357 (
ECMAScript for XML ECMAScript for XML (E4X) is the standarprogramming language extension that adds native XML support to ECMAScript (which includes ActionScript, JavaScript, and JScript). The goal is to provide an alternative to DOM interfaces that uses a simpler syn ...
(E4X)) was dropped in early 2013.


Internals

SpiderMonkey is written in C/
C++ C++ (pronounced "C plus plus") is a high-level general-purpose programming language created by Danish computer scientist Bjarne Stroustrup as an extension of the C programming language, or "C with Classes". The language has expanded significan ...
and contains an interpreter, the IonMonkey
JIT compiler In computing, just-in-time (JIT) compilation (also dynamic translation or run-time compilations) is a way of executing computer code that involves compilation during execution of a program (at run time) rather than before execution. This may cons ...
, 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. 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 ''im ...
and data types during interpreter execution. This data then informed the construction of
trace tree Trace may refer to: Arts and entertainment Music * ''Trace'' (Son Volt album), 1995 * ''Trace'' (Died Pretty album), 1993 * Trace (band), a Dutch progressive rock band * ''The Trace'' (album) Other uses in arts and entertainment * ''Trace'' ...
s, highly specialized paths of
native code In computer programming, machine code is any low-level programming language, consisting of machine language instructions, which are used to control a computer's central processing unit (CPU). Each instruction causes the CPU to perform a ver ...
. Improvements to JägerMonkey eventually made TraceMonkey obsolete, especially with the development of the SpiderMonkey
type inference Type inference 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 branches of computer science and linguistic ...
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 any low-level programming language, consisting of machine language instructions, which are used to control a computer's central processing unit (CPU). Each instruction causes the CPU to perform a ver ...
. 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 In computer science, a control-flow graph (CFG) is a representation, using graph notation, of all paths that might be traversed through a program during its execution. The control-flow graph was discovered by Frances E. Allen, who noted that ...
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 (norma ...
, 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 cache Inline caching is an optimization technique employed by some language runtimes, and first developed for Smalltalk. The goal of inline caching is to speed up runtime method binding by remembering the results of a previous method lookup directly ...
s and
type inference Type inference 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 branches of computer science and linguistic ...
. 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 (norma ...
into a
control-flow graph In computer science, a control-flow graph (CFG) is a representation, using graph notation, of all paths that might be traversed through a program during its execution. The control-flow graph was discovered by Frances E. Allen, who noted that ...
, using
static single assignment form In compiler design, static single assignment form (often abbreviated as SSA form or simply SSA) is a property of an intermediate representation (IR) that requires each variable to be assigned exactly once and defined before it is used. Existing var ...
(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 results to a limited number of processor registers. Register allocation can happen over a basic block (''local register allocatio ...
,
dead code elimination In compiler theory, dead-code elimination (also known as DCE, dead-code removal, dead-code stripping, or dead-code strip) is a compiler optimization to remove code which does not affect the program results. Removing such code has several benefits: ...
, and
loop-invariant code motion In computer programming, loop-invariant code consists of statements or expressions (in an imperative programming language) that can be moved outside the body of a loop without affecting the semantics of the program. Loop-invariant code motion ( ...
. The compiler can emit fast
native code In computer programming, machine code is any low-level programming language, consisting of machine language instructions, which are used to control a computer's central processing unit (CPU). Each instruction causes the CPU to perform a ver ...
translations of JavaScript functions on the
ARM In human anatomy, the arm refers to the upper limb in common usage, although academically the term specifically means the upper arm between the glenohumeral joint (shoulder joint) and the elbow joint. The distal part of the upper limb between th ...
,
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 Intel 8086 microprocessor and its 8088 variant. The 8086 was intr ...
, and
x86-64 x86-64 (also known as x64, x86_64, AMD64, and Intel 64) is a 64-bit version of the x86 instruction set, first released in 1999. It introduced two new modes of operation, 64-bit mode and compatibility mode, along with a new 4-level paging ...
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 current ...
,
Thunderbird Thunderbird, thunder bird or thunderbirds may refer to: * Thunderbird (mythology), a legendary creature in certain North American indigenous peoples' history and culture * Ford Thunderbird, a car Birds * Dromornithidae, extinct flightless birds ...
,
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 software components that make up the Mozilla applications. It was originally known as XPFE, an abbreviation of cross-platform front end. It was also known as XPToolkit. To avoid co ...
** Forks of Firefox including the
Pale Moon Pale Moon is an open-source web browser with an emphasis on customization; its motto is "Your browser, Your way". There are official releases for Microsoft Windows and Linux, as well as contributed builds for various platforms. Pale Moon origi ...
,
Basilisk In European bestiaries and legends, a basilisk ( or ) is a legendary reptile reputed to be a serpent king, who causes death to those who look into its eyes. According to the ''Naturalis Historia'' of Pliny the Elder, the basilisk of Cyrene i ...
and
Waterfox Waterfox is an open-source web browser that is forked from Firefox and developed by System1. There are official Waterfox releases for Windows, macOS, and Linux. Divisions Waterfox Waterfox shares core features and technologies like the Gecko b ...
web browsers. *Data storage applications: **
MongoDB MongoDB is a source-available cross-platform document-oriented database program. Classified as a NoSQL database program, MongoDB uses JSON-like documents with optional schemas. MongoDB is developed by MongoDB Inc. and licensed under the Ser ...
moved from V8 to SpiderMonkey in version 3.2 **
Riak Riak (pronounced "ree-ack" ) is a distributed NoSQL key-value data store based on Amazon's Dynamo paper, including its "tunable AP" approach, that is tunable consistency, to the tradeoffs imposed by the CAP Theorem. Riak offers high availability, ...
uses SpiderMonkey as the runtime for JavaScript MapReduce operations **
CouchDB Apache CouchDB is an open-source document-oriented NoSQL database, implemented in Erlang. CouchDB uses multiple formats and protocols to store, transfer, and process its data. It uses JSON to store data, JavaScript as its query language using ...
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 Dreamweaver is a proprietary web development tool from Adobe Inc. 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 ...
. Adobe Acrobat DC uses Spidermonkey 24.2 with ECMA-357 support forward ported. * GNOME desktop environment, version 3 and later * Yahoo! Widgets, formerly named Konfabulator *
FreeSWITCH FreeSWITCH is free and open-source server software for real-time communication applications, including WebRTC, video, and voice over Internet Protocol (VoIP). It runs on Linux, Windows, macOS, and FreeBSD. FreeSWITCH is used to build private b ...
, open-source telephony engine, uses SpiderMonkey to allow users to write call management scripts in JavaScript * The text-based web browser
ELinks ELinks is a free text-based web browser for Unix-like 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 Enhanced or Ex ...
uses SpiderMonkey to support JavaScript * Parts of SpiderMonkey are used in the
Wine Wine is an alcoholic drink typically made from fermented grapes. Yeast consumes the sugar in the grapes and converts it to ethanol and carbon dioxide, releasing heat in the process. Different varieties of grapes and strains of yeasts are m ...
project's
JScript JScript is Microsoft's legacy dialect of the ECMAScript standard that is used in Microsoft's Internet Explorer 11 and older. JScript is implemented as an Active Scripting engine. This means that it can be "plugged in" to OLE Automation applic ...
(re-)implementation * Synchronet, a BBS, e-mail, Web, and application server using the SpiderMonkey engine * JavaScript OSA, a SpiderMonkey inter-process communication language for the
Macintosh The Mac (known as Macintosh until 1999) is a family of personal computers designed and marketed by Apple Inc. Macs are known for their ease of use and minimalist designs, and are popular among students, creative professionals, and software en ...
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. SpiderMonkey includes a JavaScript Shell for interactive JavaScript development and for command-line invocation of JavaScript program files.


See also

*
Rhino (JavaScript engine) Rhino is a JavaScript engine written fully in Java and managed by the Mozilla Foundation as open source software. It is separate from the SpiderMonkey engine, which is also developed by Mozilla, but written in C++ and used in Mozilla Firefox. ...
*
List of ECMAScript engines An ECMAScript engine is a program that executes source code written in a version of the ECMAScript language standard, for example, JavaScript. Just-in-time compilation engines These are new generation ECMAScript engines for web browsers, all i ...


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 license