SpiderMonkey
Encyclopedia
SpiderMonkey is the code name for the first-ever JavaScript engine
JavaScript engine
A JavaScript engine is specialized computer software which interprets and executes JavaScript . Although there are several uses for a JavaScript engine, it is most commonly used in web browsers.-History:...

, written by Brendan Eich
Brendan Eich
Brendan Eich is a computer programmer and creator of the JavaScript scripting language. He is the chief technology officer at the Mozilla Corporation.-Education:...

 at Netscape Communications, later released as open source
Open source
The term open source describes practices in production and development that promote access to the end product's source materials. Some consider open source a philosophy, others consider it a pragmatic methodology...

 and now maintained by the Mozilla Foundation
Mozilla Foundation
The Mozilla Foundation is a non-profit organization that exists to support and provide leadership for the open source Mozilla project. The organization sets the policies that govern development, operates key infrastructure and controls trademarks and other intellectual property...

.

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 itself was abandoned when "engineering management [decided] that the language must ‘look like Java’".)
In fall 1996, Eich, needing to "pay off [the] substantial technical debt
Technical debt
Technical debt are synonymous, neologistic metaphors referring to the eventual consequences of poor software architecture and software development within a codebase....

" left from the first year, "stayed home for two weeks to rewrite Mocha as the codebase that became known as SpiderMonkey". The name SpiderMonkey was chosen as a reference to the movie Beavis and Butt-head Do America
Beavis and Butt-head Do America
Beavis and Butt-head Do America is a 1996 animated feature film, based on the TV series, Beavis and Butt-Head. It was produced by Paramount Pictures in association with Geffen Pictures and MTV Films, and co-written and directed by creator Mike Judge. The film grossed $20.11 million in its opening...

, in which the character Tom Anderson mentions that the title characters were "whacking off like a couple of spider monkeys."
In 2011, Eich transferred "ownership" of the SpiderMonkey code to Dave Mandelin.

Standards

SpiderMonkey implements ECMA-262 edition 5 (ECMAScript
ECMAScript
ECMAScript is the scripting language standardized by Ecma International in the ECMA-262 specification and ISO/IEC 16262. The language is widely used for client-side scripting on the web, in the form of several well-known dialects such as JavaScript, JScript, and ActionScript.- History :JavaScript...

), along with ECMA-357 (E4X
E4X
ECMAScript for XML is a programming language extension that adds native XML support to ECMAScript . The goal is to provide an alternative to DOM interfaces that uses a simpler syntax for accessing XML documents. It also offers a new way of making XML visible...

) and several additional features.

Even though SpiderMonkey is used in Firefox, it does not itself provide host environments such as Document Object Model
Document Object Model
The Document Object Model is a cross-platform and language-independent convention for representing and interacting with objects in HTML, XHTML and XML documents. Aspects of the DOM may be addressed and manipulated within the syntax of the programming language in use...

 (DOM).

Internals

SpiderMonkey is written in C
C (programming language)
C is a general-purpose computer programming language developed between 1969 and 1973 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system....

 and contains a compiler
Compiler
A compiler is a computer program that transforms source code written in a programming language into another computer language...

, interpreter, two JIT
Just-in-time compilation
In computing, just-in-time compilation , also known as dynamic translation, is a method to improve the runtime performance of computer programs. Historically, computer programs had two modes of runtime operation, either interpreted or static compilation...

 compilers (JägerMonkey
JägerMonkey
JägerMonkey is a JavaScript engine released for Firefox 4 and later versions. It has "Method JIT" and a new assembler based on Safari's Nitro...

 and TraceMonkey), decompiler
Decompiler
A decompiler is the name given to a computer program that performs, as far as possible, the reverse operation to that of a compiler. That is, it translates a file containing information at a relatively low level of abstraction into a form having a higher level of abstraction...

, garbage collector
Garbage collection (computer science)
In computer science, garbage collection is a form of automatic memory management. The garbage collector, or just collector, attempts to reclaim garbage, or memory occupied by objects that are no longer in use by the program...

, and standard classes. A new JIT compiler, IonMonkey, is currently in development.

TraceMonkey

Mozilla has added optimization using "Trace Trees" to SpiderMonkey. Released June 30, 2009, Firefox 3.5
Mozilla Firefox 3.5
Mozilla Firefox 3.5 is a version of the Firefox web browser released in June 2009, adding a variety of new features to Firefox. Version 3.5 was touted as being twice as fast as 3.0...

 includes this new optimization technique which offers "performance improvements ranging between 20 and 40 times faster in some cases" (compared to Firefox 3). Because of improvements to JägerMonkey, it became unneeded and been disabled. It will be removed in Firefox 11.

JägerMonkey

JägerMonkey is an additional optimization to the engine in Firefox 4. It improves speed in cases where TraceMonkey optimizations fail to improve performance.

The most publicized optimization in JägerMonkey is "method-based JIT" (that compiles code one method at a time) using inline threading (see ) and implements PICs, but there were multiple other optimizations implemented for Firefox 4. To implement method JIT, Mozilla reused the assembler from Nitro, WebKit
WebKit
WebKit is a layout engine designed to allow web browsers to render web pages. WebKit powers Google Chrome and Apple Safari and by October 2011 held over 33% of the browser market share between them. It is also used as the basis for the experimental browser included with the Amazon Kindle ebook...

's JavaScript engine.

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 new JavaScript JIT compiler, which aims to enable many new optimizations in the SpiderMonkey JavaScript engine.

The new JIT infrastructure will feature SSA
Static single assignment form
In compiler design, static single assignment form is a property of an intermediate representation , which says that each variable is assigned exactly once...

 compiler intermediate representations, which will facilitate advanced optimizations such as type specialization, function inlining, linear-scan register allocation
Register allocation
In compiler optimization, register allocation is the process of assigning a large number of target program variables onto a small number of CPU registers...

, dead code elimination
Dead code elimination
In compiler theory, dead code elimination is a compiler optimization to remove code which does not affect the program results. Removing such code has two benefits: it shrinks program size, an important...

, and loop-invariant code motion
Loop-invariant code motion
In computer programming, loop-invariant code consists of statements or expressions which can be moved outside the body of a loop without affecting the semantics of the program...

.

Usage

SpiderMonkey is intended to be embedded in other applications that provide host environments for JavaScript. An incomplete list follows:
  • Mozilla Firefox
    Mozilla Firefox
    Mozilla Firefox is a free and open source web browser descended from the Mozilla Application Suite and managed by Mozilla Corporation. , Firefox is the second most widely used browser, with approximately 25% of worldwide usage share of web browsers...

    , Thunderbird
    Mozilla Thunderbird
    Mozilla Thunderbird is a free, open source, cross-platform e-mail and news client developed by the Mozilla Foundation. The project strategy is modeled after Mozilla Firefox, a project aimed at creating a web browser...

    , SeaMonkey
    SeaMonkey
    SeaMonkey is a free and open source cross-platform Internet suite. It is the continuation of the former Mozilla Application Suite, based on the same source code...

    , and other applications that use the Mozilla application framework
    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...

  • Adobe Acrobat
    Adobe Acrobat
    Adobe Acrobat is a family of application software developed by Adobe Systems to view, create, manipulate, print and manage files in Portable Document Format . All members of the family, except Adobe Reader , are commercial software, while the latter is available as freeware and can be downloaded...

     and Adobe Reader, Adobe Flash Professional
    Adobe Flash Professional
    Adobe Flash Professional is a multimedia authoring program used to create content for the Adobe Engagement Platform, such as web applications, games and movies, and content for mobile phones and other embedded devices.-History:...

    , and Adobe Dreamweaver.
  • GNOME
    GNOME
    GNOME is a desktop environment and graphical user interface that runs on top of a computer operating system. It is composed entirely of free and open source software...

     desktop environment, version 3 and later.
  • Yahoo! Widgets (formerly known as "Konfabulator")
  • UOX
    UOX
    UOX, or Ultima Offline eXperiment, is an Ultima Online server emulator that is written in C++ and released under the GPL. Today, the term UOX almost exclusively refers to the third version, UOX3.- Overview :...

    3, an Ultima Online
    Ultima Online
    Ultima Online is a graphical massively multiplayer online role-playing game , released on September 24, 1997, by Origin Systems. It was instrumental to the development of the genre, and is still running today...

    server emulator.
  • Sphere
    Sphere (program)
    Sphere is a cross-platform, open source computer program designed primarily to make role-playing games similar to those found on the SNES and Sega Genesis consoles. Sphere was originally coded by Chad Austin...

     suite of applications primarily intended to aid in the design of role-playing game
    Role-playing game
    A role-playing game is a game in which players assume the roles of characters in a fictional setting. Players take responsibility for acting out these roles within a narrative, either through literal acting, or through a process of structured decision-making or character development...

    s.
  • 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
    CouchDB
    Apache CouchDB, commonly referred to as CouchDB, is an open source document-oriented database written mostly in the Erlang programming language. It is part of the NoSQL group of data stores and is designed for local replication and to scale horizontally across a wide range of devices...

     database system written in Erlang - JavaScript is used for defining maps, filters, reduce functions and viewing data for example in HTML format.
  • MongoDB
    MongoDB
    MongoDB is an open source, high-performance, schema-free, document-oriented database written in the C++ programming language...

    , another NoSQL
    Nosql
    In computing, NoSQL is a broad class of database management systems that differ from the classic model of the relational database management system in some significant ways. These data stores may not require fixed table schemas, usually avoid join operations, and typically scale horizontally...

     database system uses SpiderMonkey for server-side JavaScript execution.
  • FreeSWITCH
    Freeswitch
    FreeSWITCH is a free and open source communications software for the creation of voice and messaging products. It is licensed under the Mozilla Public License , a free software license...

    , 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
    ELinks
    ELinks is a free text-based console 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 name...

    , a text-based web browser, uses SpiderMonkey to support JavaScript.
  • Parts of SpiderMonkey are used in the Wine
    Wine (software)
    Wine is a free software application that aims to allow computer programs written for Microsoft Windows to run on Unix-like operating systems. Wine also provides a software library, known as Winelib, against which developers can compile Windows applications to help port them to Unix-like...

     project's Jscript
    JScript
    JScript is a scripting language based on the ECMAScript standard that is used in Microsoft's Internet Explorer.JScript is implemented as a Windows Script engine. This means that it can be "plugged in" to any application that supports Windows Script, such as Internet Explorer, Active Server Pages,...

     (re-)implementation.
  • SpiderMonkey is also used in a number of other open-source projects, see https://developer.mozilla.org/en/SpiderMonkey/FOSS
  • Riak
    Riak
    Riak is a NoSQL database implementing the principles from Amazon's Dynamo paper.Riak has a pluggable backend for its core shard-partitioned storage, with the default storage backend being Bitcask as of the 0.12 release...

     uses SpiderMonkey as the runtime for Javascript MapReduce operations.
  • Synchronet
    Synchronet
    Synchronet is a multiplatform BBS software package, with current ports for Microsoft Windows, Linux, and BSD variants. Past versions also ran on MS-DOS and OS/2, but support for those platforms has been dropped in recent versions.-History:...

    , a BBS, E-Mail, Web and application server using the SpiderMonkey engine.
  • JavaScript OSA
    JavaScript OSA
    JavaScript OSA, , is a freeware inter-process communication scripting language for the Macintosh computer....

    , a SpiderMonkey inter-process communication
    Inter-process communication
    In computing, Inter-process communication is a set of methods for the exchange of data among multiple threads in one or more processes. Processes may be running on one or more computers connected by a network. IPC methods are divided into methods for message passing, synchronization, shared...

     language for the Macintosh computer


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

Several large organizations use SpiderMonkey for managing their JavaScript for front-end applications.

See also

  • Rhino
    Rhino (JavaScript engine)
    Rhino is an open source JavaScript engine. It is developed entirely in Java and managed by the Mozilla Foundation. The Foundation also provides another implementation of JavaScript engine written in C known as SpiderMonkey....

  • List of JavaScript engines

External links

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK