The JS engine now supports allocating multiple global objects (also known as "realms") in a single compartment [0]. We are working on using this mechanism for our chrome code (one compartment for most of our system-principal sandboxes [1] and windows [2]). I'm hoping that part will land relatively soon. After that we want to enable this for same-origin content globals (like iframes) as well. This is the main goal of this work, but it depends on some architectural changes that are still in flight.
We are doing this to reduce cross-compartment wrapper overhead: globals within a compartment can access each other directly, without any wrapper overhead, and they can share wrappers into other compartments. Initial results are promising; we are seeing performance improvements on various talos tests and some memory usage improvements as well. What this means is that globals are no longer guaranteed to have their own compartment. Instead of entering a compartment (JSAutoCompartment), code should now enter a global/realm (JSAutoRealm). Note that JSAutoRealm cannot be used with cross-compartment wrappers (there's a diagnostic assert for this, because cross-compartment wrappers are now shared by all realms in the compartment, so entering a wrapper's realm is kind of meaningless). Please keep this in mind when writing (test) code. Let me know if there are any questions or concerns. Thanks, Jan [0] https://bugzilla.mozilla.org/show_bug.cgi?id=1357862 [1] https://bugzilla.mozilla.org/show_bug.cgi?id=1512029 [2] https://bugzilla.mozilla.org/show_bug.cgi?id=1514210 _______________________________________________ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform