{"id":378,"date":"2014-12-16T13:14:48","date_gmt":"2014-12-16T18:14:48","guid":{"rendered":"http:\/\/blog.mozilla.org\/nfroyd\/?p=378"},"modified":"2014-12-16T13:14:48","modified_gmt":"2014-12-16T18:14:48","slug":"whats-new-in-xpcom","status":"publish","type":"post","link":"https:\/\/blog.mozilla.org\/nfroyd\/2014\/12\/16\/whats-new-in-xpcom\/","title":{"rendered":"what&#8217;s new in xpcom"},"content":{"rendered":"<p>I was talking to somebody at Mozilla&#8217;s recent all-hands meeting in Portland, and in the course of attempting to provide a reasonable answer for &#8220;What have you been doing lately?&#8221;, I said that I had been doing a lot of reviews, mostly because of my newfound duties as XPCOM module owner. My conversational partner responded with some surprise that people were still modifying code in XPCOM at such a clip that reviews would be a burden. I responded that while the code was not rapidly changing, people were still finding reasons to do significant modifications to XPCOM code, and I mentioned a few recent examples.<\/p>\n<p>But in light of that conversation, it&#8217;s good to broadcast some of the work I&#8217;ve had the privilege of reviewing this year.\u00a0 I apologize in advance for not citing everybody; in particular, my reviews email folder only goes back to August, so I have a very incomplete record of what I&#8217;ve reviewed in the past year.\u00a0 In no particular order:<\/p>\n<ul>\n<li>Randall Barker has been working on building a standalone WebRTC library, which necessitates <a href=\"https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=1093934\">building a standalone XPCOM<\/a>, as our WebRTC code depends on things like XPCOM timers and threads.<\/li>\n<li>Brian Birtles wrote a series of patches that implemented <a href=\"https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=1039924\">a version of <tt>TimeDuration<\/tt> that uses saturating-esque arithmetic<\/a>, which is useful for animation code.<\/li>\n<li>Birunthan Mohanathas wrote <a href=\"https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=1046841\">a rather large series of patches for completely converting xpcom\/ to Gecko style<\/a>, not all of which are featured in the linked bug.\u00a0 He submitted numerous patches, re-indenting code, renaming arguments, and fixing other style violations, all easily reviewable.\u00a0 xpcom\/ is a better place for his work.<\/li>\n<li>Eric Rahm made some significant changes to how the deadlock detector works, <a href=\"https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=1027921\">improving its memory usage<\/a> and <a href=\"https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=1050445\">redoing how we store callstacks<\/a>.\u00a0 The upshot here is that the deadlock detector is significantly faster, and no longer requires trace-malloc to provide callstacks.<\/li>\n<li>Ben Kelly implemented <a href=\"https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=1098004\">XPCOM streams that perform snappy compression<\/a> on the data being written to or from them, as part of his ongoing work on Service Workers.\u00a0 We did think about using the stream converter service for this one, but the APIs didn&#8217;t match up very nicely with how the streams were actually getting used.<\/li>\n<li>Mike Hommey wrote <a href=\"https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=1083686\">a tool to record and replay memory allocations made by Firefox<\/a>.\u00a0 In the course of doing so, he discovered a nasty infinite loop made possible by using locking primitives that always had to be dynamically allocated.\u00a0 Working around this required <a href=\"https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=1087245\">writing statically-allocated mutexes<\/a> and carefully integrating with our file descriptor poisoning that happens during shutdown.<\/li>\n<li>Ehsan Akhgari discovered that the <tt>ReplaceSubstring<\/tt> method of XPCOM&#8217;s strings was O(n^2), which <a href=\"https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=1101337\">caused hangs when using the reftest analyzer<\/a>.\u00a0 And motivated by wanting to have automated testing for this, he also <a href=\"https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=1110956\">ported the string tests to run under the GTest unit test framework<\/a> (along with other tests that have lain dormant for far too long.)<\/li>\n<li>People also continue to make various tweaks to XPCOM data structures: Kyle Huey and Peter Van der Beken <a href=\"https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=982212\">added rvalue reference support to <tt>nsTArray<\/tt><\/a>.\u00a0 Seth Fowler\u00a0<a href=\"https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=1091921\">modified various <tt>Auto<\/tt> helpers so they&#8217;d work properly with <tt>mozilla::Maybe<\/tt><\/a>.\u00a0 Nicholas Nethercote <a href=\"https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=1048044\">fixed nsTArray to use exponential growth<\/a> when appending to an array.<\/li>\n<li>Finally, reviewing wouldn&#8217;t be reviewing if you didn&#8217;t get to review fixes to code that you already reviewed and approved some time ago.\u00a0 Benjamin Smedberg wrote a patch a year ago to <a href=\"https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=938794\">annotate out-of-memory callsites in XPCOM<\/a> with the actual amount of bytes that were being allocated.\u00a0 This worked well enough, but David Major noticed that we sometimes <a href=\"https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=1096155\">passed the sentinel size of -1 as the actual allocation size<\/a>, and <a href=\"https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=1097283\">we didn&#8217;t compute the correct sizes for XPCOM string allocations<\/a>.<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>I was talking to somebody at Mozilla&#8217;s recent all-hands meeting in Portland, and in the course of attempting to provide a reasonable answer for &#8220;What have you been doing lately?&#8221;, I said that I had been doing a lot of reviews, mostly because of my newfound duties as XPCOM module owner. My conversational partner responded [&hellip;]<\/p>\n","protected":false},"author":320,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.mozilla.org\/nfroyd\/wp-json\/wp\/v2\/posts\/378"}],"collection":[{"href":"https:\/\/blog.mozilla.org\/nfroyd\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.mozilla.org\/nfroyd\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.mozilla.org\/nfroyd\/wp-json\/wp\/v2\/users\/320"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.mozilla.org\/nfroyd\/wp-json\/wp\/v2\/comments?post=378"}],"version-history":[{"count":0,"href":"https:\/\/blog.mozilla.org\/nfroyd\/wp-json\/wp\/v2\/posts\/378\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.mozilla.org\/nfroyd\/wp-json\/wp\/v2\/media?parent=378"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.mozilla.org\/nfroyd\/wp-json\/wp\/v2\/categories?post=378"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.mozilla.org\/nfroyd\/wp-json\/wp\/v2\/tags?post=378"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}