Bug 1527905. Switch from zone-per-tab to zone-per-toplevel-load. r=mccr8

The main reason for this change is that we don't really want to share
compartments across same-origin navigations in the same tab (because that will
tend to keep the oldest global involved alive, due to CCWs and
XPCWrappedNatives allocated in that global).  We could somehow flag
compartments as not sharable when we navigate, but it's simpler to just switch
zones, since we restrict our search of shareable compartments to a single zone.

A side benefit is that this way the lifetime of objects in a single zone is
more likely to be similar.

Differential Revision: https://phabricator.services.mozilla.com/D19797

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Boris Zbarsky 2019-02-14 22:43:19 +00:00
parent 271bc01510
commit 8a0e2dabbe

View File

@ -1796,6 +1796,12 @@ static JS::RealmCreationOptions& SelectZone(
if (aNewInner->GetOuterWindow()) {
nsGlobalWindowOuter* top = aNewInner->GetTopInternal();
if (top == aNewInner->GetOuterWindow()) {
// We're a toplevel load. Use a new zone. This way, when we do
// zone-based compartment sharing we won't share compartments
// across navigations.
return aOptions.setNewCompartmentAndZone();
}
// If we have a top-level window, use its zone.
if (top && top->GetGlobalJSObject()) {