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.
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:
A few review iterations later, the patch landed on mozilla-central.
The force is strong in this one – let’s hope he sticks around.


Fig 1 is awesome!!
Love it!
Awesome, but I don’t understand why Crockford is in the diagram.
(HT/be… http://www.flickr.com/photos/equanimity/4054400577/)
lol at technical diagram..
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…
Filed: https://bugzilla.mozilla.org/show_bug.cgi?id=710830
YOUUUU..SHALL NOT…PASS!
Splendid diagram and awesome work. Antii is obviously a force to be reckoned with.
I think Crockford suits the dress.
It would be more impressive if it didn’t allocate a temporary copy of the array…
As noted on bugzilla, this would be nice, but requires some careful architectural work to make it safe. Antti reported a massive speedup with the copy patch, so I thought we might as well go with it.
There’s a bug for enabling buffer sharing: https://bugzilla.mozilla.org/show_bug.cgi?id=710806