On Tue, Jan 22, 2013 at 2:15 PM, Boris Zbarsky <bzbar...@mit.edu> wrote: > On 1/20/13 2:37 PM, Gregory Szorc wrote: >> >> * Have all or most of chrome-privileged JS share the same compartment >> (like on B2G). It's my understanding the CPG decision was largely driven >> by content/security requirements and chrome just got caught up in it. > > What's not clear to me is whether this is a proposal to keep separate > globals per JSM but have them all in one compartment
AIUI, the global-to-compartment mapping will always be 1-to-1, and changing this would be monstrously problematic. > or whether this is a > proposal to have a single global for all JSMs, or all JSMs that opt into > having this single global or something. The compartment overhead has three components. (1) Wasted space within GC arenas (because compartments can't share arenas). This is a consistent, moderate-to-large overhead. (2) Space taken up by cross-compartment wrappers (both the objects and the CCW tables). This doesn't seem that much of a problem in practice. (3) Strings get copied between compartments. This is an irregular problem, but it can be terrible when it does occur. There are several possible fixes for this problem. https://bugzilla.mozilla.org/show_bug.cgi?id=759585 proposes introducing "zones". Compartments in the same zone could share arenas, which would fix (1) (for compartments in the same zone). This would also fix (3), because compartments in the same zone would be able to share strings. https://bugzilla.mozilla.org/show_bug.cgi?id=807205 proposes a way to load multiple JS modules into the same compartment. This would also solve both (1) and (3), with the side-effect that separate modules would be sharing a global, which has some risk. https://bugzilla.mozilla.org/show_bug.cgi?id=833585 requests that strings not be copied between compartments, but if either of the previous two proposals were implemented it shouldn't be necessary. The zones approach is my preferred solution. Firefox has hundreds of compartments, and that won't change any time soon, and the separation that compartments provide gives lots of nice security/isolation benefits. Instead of finding ways to work around compartments, because they have memory overhead, it would be better to fix that memory overhead. Nick _______________________________________________ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform