A few weeks ago we released Firefox 57, also known as Firefox Quantum. I work on SpiderMonkey performance and this year I spent a lot of time analyzing profiles and optimizing as many things as possible. I can't go through all SpiderMonkey performance improvements here: this year alone I landed almost 500 patches (most of them performance related, most of them pretty boring) and other…
The past months we have been working on CacheIR , an overhaul of the IC code in SpiderMonkey's JITs. CacheIR has allowed us to remove thousands of lines of boilerplate and code duplication. It has also made it much easier to add new optimizations. This post describes how CacheIR works, why it's much better than what we had before, and some plans we have for the future. IC stubs Both the…
Back in June, I added an option to SpiderMonkey to enable W^X protection of JIT code. The past weeks I've been working on fixing the remaining performance issues and yesterday I enabled W^X on the Nightly channel, on all platforms. What this means is that each page holding JIT code is either executable or writable, never both at the same time. Why? Almost all JITs (including the ones in…
(For tl;dr , see the Conclusion.) A few days ago, I wrote about Math.random() implementations in Safari and (older versions of) Chrome using only 32 bits of precision. As I mentioned in that blog post, I've been working on upgrading Math.random() in SpiderMonkey to XorShift128+. V8 has been using the same algorithm since last week. (Update Dec 1: WebKit is now also using XorShift128+!) The…
Last week, Mike Malone, CTO of Betable , wrote a very insightful and informative article on Math.random() and PRNGs in general. Mike pointed out V8/Chrome used a pretty bad algorithm to generate random numbers and, since this week, V8 uses a better algorithm. The article also mentioned the RNG we use in Firefox (it was copied from Java a long time ago) should be improved as well. I fully…
Last week I landed bug 1132183 , a pretty large patch rewriting the implementation of this in SpiderMonkey. How this Works In JS In JS, when a function is called, an implicit this argument is passed to it. In strict mode, this inside the function just returns that value: function f () { "use strict" ; return this ; } f . call ( 123 ); // 123 In non-strict functions, this always returns…
At Mozilla, we use Mercurial for the main Firefox repository. Mercurial, like Git, uses SHA1 hashes to identify a commit. Short hashes SHA1 hashes are fairly long, a string of 40 hex characters (160 bits), so Mercurial and Git allow using a prefix of that, as long as the prefix is unambiguous. Mercurial also typically only shows the first 12 characters (let’s call them short hashes ), for…
Last week I spent some time optimizing ES6 arrow functions. Arrow functions allow you to write function expressions like this: a . map ( s => s .length); Instead of the much more verbose: a . map ( function ( s ){ return s .length }); Arrow functions are not just syntactic sugar though, they also bind their this-value lexically. This means that, unlike normal functions, arrow functions use the…