This is showing up in profiles in bug 696761. We should only look for expando objects if we know we ever had one for the XPCWrappedNative that we're traversing. Patch coming up.
So without this patch we do O(number of live compartments) work for every XPCWrappedNative that we traverse? That could certainly explain the profiles I'm seeing, if I have lots of compartments and lots of XPCWrappedNatives around....
Is this something we could safely backport?
For what it's worth, I just checked and I seem to have 425 compartments in the compartment map over here... Is there any way we could just avoid the linear scan?