Typed Arrays Supported in XPConnect

December 13, 2011

tl;dr – You can now pass typed arrays to XPCOM methods that expect XPIDL arrays.

These days I work mostly on XPConnect, which serves as the bridge between Spidermonkey and the rest of Gecko. For those not steeped in Mozilla lore, XPConnect has a reputation for being one of the nastiest and most incomprehensible parts of the platform. Unfortunately, it’s also a central bottleneck through which most important things must pass.

lord of the rings

Fig 1: Technical diagram of a method call on an XPCWrappedNative.

So while many people desperately need features and bug fixes for XPConnect, very few people have the knowledge and fortitude to hack on the code. Those who do, folks like Blake Kaplan, Boris Zbarsky, and Peter Van Der Beken, tend to be very busy people.

I started working on XPConnect in large part to alleviate this problem. Unfortunately, when word got out that there was a fresh face in the cartel, I too quickly became a very busy person. Thus, when a bug was filed to implement support for passing typed arrays to XPCOM methods, I expressed skepticism that I’d have the bandwidth for it any time in the near future.

So imagine my surprise and joy when one of the requesters (Antti Haapala, ztane on IRC) expressed interest in taking a crack at it. And imagine my utter disbelief when a working patch, with tests, appeared a day later:

screenshot from bugzilla

A few review iterations later, the patch landed on mozilla-central.

The force is strong in this one – let’s hope he sticks around.


10 Responses to “Typed Arrays Supported in XPConnect”

  1. Tim said

    Fig 1 is awesome!!

  2. Justin Dolske said

    Awesome, but I don’t understand why Crockford is in the diagram.

    (HT/be… http://www.flickr.com/photos/equanimity/4054400577/)

  3. tom jones said

    lol at technical diagram.. 😉

  4. Mook said

    Yay! Hopefully things should be slightly faster.

    Is there equivalent support for js-ctypes? Given that people have been pushed in that direction instead of binary XPCOM components…

  5. Kiro said


  6. Splendid diagram and awesome work. Antii is obviously a force to be reckoned with.

    I think Crockford suits the dress.

  7. It would be more impressive if it didn’t allocate a temporary copy of the array…

Comments are closed.

%d bloggers like this: