Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

SpiderMonkey

From Wikipedia, the free encyclopedia
JavaScript and WebAssembly engine
This article is about the software. For the primate, seeSpider monkey. For other uses, seeSpider monkey (disambiguation).

SpiderMonkey
Developers
Repositorygithub.com/mozilla-firefox/firefox/tree/main/js/src,github.com/mozilla-spidermonkey
Written inC,C++
Operating systemCross-platform
PlatformIA-32,x86-64,ARM,MIPS,SPARC,[1]RISC-V[2]
TypeJavaScript andWebAssembly engine
LicenseMPL 2.0[3]
Websitespidermonkey.dev

SpiderMonkey is anopen-sourceJavaScript andWebAssembly engine by theMozilla Foundation.[4] The engine powers theFirefoxWeb browser and has used multiple generations of JavaScriptjust-in-time (JIT) compilers, including TraceMonkey, JägerMonkey, IonMonkey, and the current WarpMonkey.

It is the firstJavaScript engine, written byBrendan Eich atNetscape 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

[edit]

Eich "wrote JavaScript in ten days" in 1995,[5]having been "recruited to Netscape with the promise of 'doingScheme' in the browser".[6](The idea of using Scheme was abandoned when "engineering management [decided] that the language must 'look likeJava'".)[6] In late 1996, Eich, needing to "pay off [the] substantialtechnical debt" left from the first year, "stayed home for two weeks to rewrite Mocha as the codebase that became known as SpiderMonkey".[5] (Mocha was the original working name for the language.)[6][7]In 2011, Eich transferred management of the SpiderMonkey code to Dave Mandelin.[5]

Versions

[edit]
See also:ECMAScript version history
SpiderMonkey version history
VersionRelease dateECMAScript versionBrowser versionAdded functionality[8][9][10][11][12]
Unsupported: 1.0
(Mocha)
September 1995[8]Netscape Navigator 2.0b1[13]
  • Basic syntax mostly fromC,>>> (unsigned shift) fromJava,for-in statement andfunction declaration fromAWK.[8]
  • var,with,this,obj.prop andobj[prop] syntax, automatic semicolon insertion,<!-- comments.
  • number, string, boolean, object and function types; undefined and null
  • Object,String,Date classes and methods,Math object,eval(),parseInt(),parseFloat(),isNaN()
  • Function'sarguments property (quirk: merely an alias for the function object)
Unsupported: 1.1
(Mocha)
August 1996Basis for ES1Netscape Navigator 3.0
  • Finished originally envisioned language design that was cut short due to Netscape Navigator 2.0's feature freeze.[8]
  • prototype-based inheritance (fromSelf) via function'sprototype property.
  • typeof,void anddelete var operators.
  • Array,Boolean,Function,Number,String classes.
  • Automatic type coercions. Wrapper objects when accessing a primitive's property.
Unsupported: 1.2June 1997Basis for ES3Netscape Navigator 4.0-4.05
  • New engine codenamed "SpiderMonkey", replacing the original Mocha.
  • Regular expressions,function expressions, nested functions.
  • do-while,switch, statement labels,break/continue with label,delete obj.prop,__proto__ pseudo-property.
  • Array ([...]), Object ({prop: ...}) and RegExp (/.../) literals.
  • Array methods: push, pop, shift, splice, unshift, concat, slice
  • String methods: charCodeAt, fromCharCode, match, replace, search, substr
  • Function andarguments are distinct objects,arguments.callee, function'sarity property.
  • Non-standard: removed automatic coercions for== (restored in 1.3),watch()/unwatch(),import/export statements and signed scripts.
Unsupported: 1.3October 1998ES1 + ES2
(compliant with the standard)
Netscape Navigator 4.06-4.7x
  • Full ECMAScript compliance, Unicode support,=== and!==.[14]
  • Type coercion for== reverted to JS1.1 semantics.
  • if(x=y) no longer converts toif(x==y).
  • Non-nullish objects are truthy in conditionals, even aBoolean object that wrapsfalse.
  • Globalundefined binding (idiom before:void(0))[8][15]
Unsupported: 1.4Netscape Server
  • try-catch-finally statement,in andinstanceof operators.
  • No indirecteval() (later reverted), removedObject.prototype.eval().
  • Function'sarguments property is now a variable.arity property deprecated in favor oflength.
Unsupported: 1.5November 2000ES3Netscape Navigator 6, Firefox 1.0
  • ES3 features: runtime errors reported as exceptions, regex enhancements (non-greedy quantifiers, non-capturing groups, lookahead assertions, m flag), Number formatting methods (toExponential, toFixed, toPrecision)
  • Getters and setters.
  • Multiplecatch clauses intry-catch.
  • Functions can be declared inside an expression andif clause.
  • const declaration (not part of ES3, adopted in ES6)
Unsupported: 1.6November 2005E4XFirefox 1.5
  • Array methods: indexOf, lastIndexOf, every, filter, forEach, map, some
  • Array and String generics
  • E4X andfor each...in statement
Unsupported: 1.7October 2006Firefox 2.0
  • Iterators and generators,for...of,yield,let statement, destructuring assignment.
  • Non-standard: array comprehensions.
Unsupported: 1.8June 2008Firefox 3.0
  • Array methods: reduce, reduceRight
  • Non-standard: expression closures and generator comprehensions.
Unsupported: 1.8.1June 2009Firefox 3.5[16]
  • TraceMonkey:tracing JIT[17]
  • JSON support, Object.getPrototypeOf(), String methods: trim, trimLeft, trimRight, startsWith.
  • Switched to C++ from plain C for building the engine.
Unsupported: 1.8.5March 2011ES5Firefox 4.0[18]
  • JägerMonkey: method JIT
  • Object manipulation and protection methods, Array.isArray(), Date.prototype.toJSON(), Function.prototype.bind()
  • Strict mode
  • Trailing comma not accepted byJSON.parse()
  • Proxy class and typed arrays (not part of ES5, adopted in ES6)
Unsupported: 1.8.8January 2012Firefox 10.0
  • Regular expressions object no longer callable, Function.prototype.isGenerator() method (in 5.0).
  • ES6 WeakMap (in 6.0)
  • Function.arity removed (in 7.0)
  • E4X deprecated (in 10.0)
Unsupported: 17November 2012Firefox 17.0
  • ArrayBuffer.prototype.slice() (in 12.0)
  • ES6 for...of and Map/Set (in 13.0)
  • ES6 default and rest parameters, new Number methods, DataView interface (in 15.0)
  • ES6 spread operator for array initializers (in 16.0)
  • String methods: startsWith, endsWith, contains. Iterator improvements. E4X disabled for web (in 17.0)
Unsupported: 24September 2013Firefox 24.0
  • IonMonkey: optimizing JIT compiler (in 18.0)[19]
  • ES6 Proxy, String.prototype.contains() method (in 18.0),
  • for each...in deprecated, Math.imul() (in 20.0)
  • Map/Set methods: keys, values, entries (in 20.0/24.0)
  • E4X removed, parseInt no longer treats strings with leading "0" as octal (in 21.0)
  • ES6 arrow functions, Object.is() (in 22.0)
  • OdinMonkey:asm.js optimization module (in 22.0)
Unsupported: 31July 2014Firefox 31.0
Unsupported: 38May 2015Firefox 38.0
Unsupported: 45March 2016Firefox 45.0
Unsupported: 52March 2017ES6Firefox 52.0
  • Nearly complete ES6 compliance by 52.0-53.0. Proper Tail Calls the only remaining long-standing issue.[20]
Unsupported: 60May 2018Firefox 60.0
Unsupported: 68July 2019Firefox 68.0
Unsupported: 78June 2020Firefox 78.0
  • Switched regex engine from YARR to V8's Irregexp.[21]
Unsupported: 91August 2021Firefox 91.0
  • WarpMonkey JIT replaced IonMonkey in 83.0.[22]
Unsupported: 102June 2022Firefox 102.0
Unsupported: 103July 2022Firefox 103.0
Latest version:131September 2024[23]Firefox 131.0
Legend:
Unsupported
Supported
Latest version
Preview version
Future version

Standards

[edit]

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

Internals

[edit]

SpiderMonkey is written inC/C++ and contains aninterpreter, the WarpMonkeyJIT compiler, and agarbage collector.

TraceMonkey

[edit]

TraceMonkey[17] 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,[25] the compiler became part of the mainline release as part of SpiderMonkey inFirefox 3.5, providing "performance improvements ranging between 20 and 40 times faster" than the baseline interpreter inFirefox 3.[26]

Instead of compiling whole functions, TraceMonkey was atracing JIT, which operates by recordingcontrol flow anddata types during interpreter execution. This data then informed the construction oftrace trees, highly specialized paths ofnative code.

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

JägerMonkey

[edit]

JägerMonkey, internally named MethodJIT, was a whole-method JIT compiler designed to improve performance in cases where TraceMonkey could not generate stablenative code.[28][29] It was first released inFirefox 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 acontrol-flow graph representing the function, JägerMonkey instead operated by iterating linearly forward through SpiderMonkeybytecode, 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 importantlypolymorphic inline caches andtype inference.[30]

The difference between TraceMonkey and JägerMonkey JIT techniques and the need for both was explained ina 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 postArchived 9 December 2012 atarchive.today. More technical information can be found in other developer's blogs:dvander,dmandelin.

IonMonkey

[edit]

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

IonMonkey was a more traditional compiler: it translated SpiderMonkeybytecode into acontrol-flow graph, usingstatic single assignment form (SSA) for theintermediate representation. This architecture enabled well-known optimizations from other programming languages to be used for JavaScript, including type specialization,function inlining, linear-scanregister allocation,dead code elimination, andloop-invariant code motion.[32]

The compiler can emit fastnative code translations of JavaScript functions on theARM,x86, andx86-64 platforms. It has been the default engine since Firefox 18.[19]

OdinMonkey

[edit]

OdinMonkey is the name of Mozilla's new optimization module forasm.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.[33]

WarpMonkey

[edit]

The WarpMonkey JIT replaces the former IonMonkey engine from version 83.[22] 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-levelIntermediate 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.[34]

Use

[edit]

SpiderMonkey is intended to be embedded in other applications that provide host environments for JavaScript. An incomplete list follows:

  • MozillaFirefox,Thunderbird,SeaMonkey, and other applications that use theMozilla application framework
  • Data storage applications:
    • MongoDB moved fromV8 to SpiderMonkey in version 3.2[35]
    • Riak uses SpiderMonkey as the runtime for JavaScript MapReduce operations[36]
    • CouchDB database system (written inErlang). 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, andAdobe Dreamweaver. Adobe Acrobat DC uses Spidermonkey 24.2 with ECMA-357 support forward ported.[37]
  • GNOME desktop environment, version 3 and later
  • Cinnamon desktop environment, version 1.0 and later
  • Yahoo! Widgets, 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.[38]
  • The text-based web browserELinks uses SpiderMonkey to support JavaScript[39]
  • Parts of SpiderMonkey are used in theWine project'sJScript (re-)implementation[40]
  • Synchronet, a BBS, e-mail, Web, and application server using the SpiderMonkey engine
  • JavaScript OSA, a SpiderMonkeyinter-process communication language for theMac 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.[41]

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

See also

[edit]

References

[edit]
  1. ^"1.8.8 – SpiderMonkey | MDN". Developer.mozilla.org. 10 January 2013.Archived from the original on 2 May 2013. Retrieved21 March 2013.
  2. ^"SpiderMonkey Newsletter (Firefox 110-111)".spidermonkey.dev. 16 February 2023. Retrieved27 December 2023.
  3. ^Mozilla Licensing Policies, mozilla.org,archived from the original on 2 April 2013, retrieved26 March 2013
  4. ^"Home".SpiderMonkey JavaScript/WebAssembly Engine. Retrieved24 April 2023.
  5. ^abcEich, Brendan (21 June 2011)."New JavaScript Engine Module Owner". BrendanEich.com.Archived from the original on 14 July 2011. Retrieved1 July 2011.
  6. ^abcEich, Brendan (3 April 2008)."Popularity". BrendanEich.com.Archived from the original on 3 July 2011. Retrieved1 July 2011.
  7. ^Eich, Brendan (19 August 2011)."Mapping the Monkeysphere".Archived from the original on 13 January 2013. Retrieved19 August 2011.
  8. ^abcdeWirfs-Brock, Allen; Eich, Brendan (2020)."#".Proceedings of the ACM on Programming Languages.4 (HOPL).doi:10.1145/3386327.
  9. ^"Core JavaScript Reference v1.4 - New Features in this Release". Netscape Communications Corporation. 1998.
  10. ^https://web.archive.org/web/20140829071706/https://developer.mozilla.org/en-US/docs/Web/JavaScript/New_in_JavaScript/1.5
  11. ^http://www.jsdb.org/jsguide/intro.html#1023167
  12. ^"New in JavaScript 1.6". Archived fromthe original on 5 September 2015. Retrieved28 July 2015.
  13. ^"Netscape Navigator 2.0b1 for Windows". Archived fromthe original on 19 April 1997. (The first beta version with JavaScript support, marketed as LiveScript at that point.)
  14. ^"Client-Side JavaScript Guide"(PDF). Version 1.3. Netscape Communications Corporation. 1999. Retrieved23 September 2025.
  15. ^https://github.com/Historic-Spidermonkey-Source-Code/JavaScript-1.4.2/blob/main/src/jsconfig.h#L212
  16. ^"Firefox 3.5 for developers".MDN Web Docs. Mozilla. 30 June 2009. Retrieved23 September 2025.
  17. ^ab"#". Retrieved22 July 2020.
  18. ^"Firefox 4 for developers".MDN Web Docs. Mozilla. 22 March 2011. Retrieved23 September 2025.
  19. ^ab"Firefox Notes - Desktop". Mozilla.org. 8 January 2013.Archived from the original on 2 September 2014. Retrieved21 March 2013.
  20. ^https://web.archive.org/web/20170430175540/http://kangax.github.io/compat-table/es6/
  21. ^https://hacks.mozilla.org/2020/06/a-new-regexp-engine-in-spidermonkey/
  22. ^ab"Warp: Improved JS performance in Firefox 83 – Mozilla Hacks - the Web developer blog".Mozilla Hacks – the Web developer blog. 13 November 2020. Retrieved28 August 2021.
  23. ^"Directory Listing: /pub/firefox/releases/131.0/source/".archive.mozilla.org. Archived fromthe original on 7 October 2024. Retrieved20 March 2025.
  24. ^"759422 – Remove use of e4x in account creation". Retrieved5 February 2013.
  25. ^"TraceMonkey: JavaScript Lightspeed, Brendan Eich's Blog". Retrieved22 July 2020.
  26. ^Paul, Ryan (22 August 2008)."Firefox to get massive JavaScript performance boost". Ars Technica.Archived from the original on 6 May 2012. Retrieved21 March 2013.
  27. ^Nethercote, Nicholas (1 November 2011)."SpiderMonkey is on a diet | Nicholas Nethercote". Blog.mozilla.com.Archived from the original on 28 March 2012. Retrieved21 March 2013.
  28. ^"JaegerMonkey – Fast JavaScript, Always! » Mystery Bail Theater". Bailopan.net. 26 February 2010.Archived from the original on 24 March 2013. Retrieved21 March 2013.
  29. ^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. Retrieved21 March 2013.
  30. ^"JaegerMonkey - MozillaWiki". Wiki.mozilla.org.Archived from the original on 23 August 2013. Retrieved21 March 2013.
  31. ^"Platform/Features/IonMonkey - MozillaWiki". Wiki.mozilla.org. 11 February 2013.Archived from the original on 8 March 2013. Retrieved21 March 2013.
  32. ^"IonMonkey: Mozilla's new JavaScript JIT compiler". Infoq.com.Archived from the original on 8 December 2012. Retrieved21 March 2013.
  33. ^"Firefox Notes - Desktop". Archived fromthe original on 3 September 2014.
  34. ^"SpiderMonkey — Firefox Source Docs documentation".firefox-source-docs.mozilla.org. Retrieved28 August 2021.
  35. ^"JavaScript Changes in MongoDB 3.2 — MongoDB Manual 3.4".Archived from the original on 6 June 2017. Retrieved23 November 2016.
  36. ^"The Release Riak 0.8 and JavaScript Map/Reduce".Archived from the original on 3 November 2011. Retrieved24 April 2011.
  37. ^"Acrobat DC SDK Documentation".helpx.adobe.com. Retrieved5 November 2021.
  38. ^"Distributive-Network/PythonMonkey: A Mozilla SpiderMonkey JavaScript engine embedded into the Python VM, using the Python engine to provide the JS host environment".GitHub. 7 July 2023. Retrieved10 July 2023.
  39. ^Bolso, Erik Inge (8 March 2005)."2005 Text Mode Browser Roundup".Linux Journal.Archived from the original on 15 March 2010. Retrieved5 August 2010.
  40. ^wine-cvs mailing listArchived 7 February 2009 at theWayback Machine, 16 September 2008: "jscript: Added regular expression compiler based on Mozilla regexp implementation"
  41. ^"SpiderMonkey > FOSS".MDN Web Docs. Retrieved2 April 2019.
  42. ^"Introduction to the JavaScript shell".MDN. Mozilla Developer Network. 29 September 2010. Archived fromthe original on 29 June 2011. Retrieved14 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 [...]

External links

[edit]
Projects
Mozilla
Labs
Mozilla
Research
Mozilla
Foundation
Firefox
Origins
Frameworks
Components
Typefaces
Discontinued
Forks
Discontinued projects are initalics. Some projects abandoned by Mozilla that are still maintained by third parties are inunderline.
Organization
Foundation
Official affiliates
People
Community
Other topics
Dialects
Engines
Frameworks
Client-side
Server-side
Multiple
  • Cappuccino
Libraries
People
Other
Retrieved from "https://en.wikipedia.org/w/index.php?title=SpiderMonkey&oldid=1319188751"
Categories:
Hidden categories:

[8]ページ先頭

©2009-2025 Movatter.jp