Closed Bug 1357862 (same-compartment-realms) Opened 7 years ago Closed 5 years ago

[meta] Support multiple globals per compartment (same-compartment realms)

Categories

(Core :: JavaScript Engine, enhancement, P2)

enhancement

Tracking

()

RESOLVED FIXED
mozilla67
Performance Impact ?
Tracking Status
firefox57 --- wontfix
firefox67 --- fixed
firefox68 --- fixed

People

(Reporter: jorendorff, Assigned: jandem)

References

(Depends on 7 open bugs, Blocks 6 open bugs)

Details

(Keywords: meta)

Currently a compartment contains exactly one realm (standard-ese for a global and all objects and code associated with it). An object in one realm cannot have a direct reference to an object in another realm. References across realm boundaries are represented as cross-compartment wrappers (CCWs).

The cross-compartment wrapper overhead is sometimes bad, so we're planning to merge compartments that are in the same tab group and are same-origin. Objects in a page will tend to be same-compartment with those in child iframes. The new nesting will be runtimes > zone groups > zones > compartments > realms.

In the new order, the main responsibility of compartments will be security. Security wrappers will continue to exist. Since only same-origin compartments are being merged, the only CCWs removed will be the transparent wrappers we currently insert at the boundary between same-origin compartments.

This will mean changing the implementation and some Web-observable behavior of Window and Location objects and (especially) document.domain.

Many things in various specs require there to be a "current global", so we'll continue to have a cx->global() that's non-null whenever JS could run. JSAutoCompartment will be changed to require a global, not just a JSCompartment*.
Depends on: 1363200
Depends on: 1363206
Depends on: 1363208
Depends on: 1363212
Depends on: 1363214
Summary: [meta] Support multiple globals per compartment → [meta] Support multiple globals per compartment (same-compartment realms)
See Also: → 1186409
No longer blocks: TimeToFirstPaint_FB
Blocks: 1338802
Blocks: 1384970
Priority: -- → P1
Priority: P1 → P2
Blocks: 1414387
Whiteboard: [qf:p1}
Whiteboard: [qf:p1} → [qf:p1]
Whiteboard: [qf:p1] → [qf:i60][qf:p1]
Whiteboard: [qf:i60][qf:p1] → [qf:f60][qf:p1]
Blocks: 1434809
No longer depends on: 1434809
Whiteboard: [qf:f60][qf:p1] → [qf:f61][qf:p1]
Whiteboard: [qf:f61][qf:p1] → [qf:f64][qf:p1]
Depends on: 1461938
Depends on: 1463163
Depends on: 1464134
Depends on: 1464374
Depends on: 1464772
Depends on: 1465002
Depends on: 1465037
Assignee: nobody → jdemooij
Status: NEW → ASSIGNED
Alias: same-compartment-realms
Depends on: 1465163
Depends on: 1465472
Depends on: 1465700
Depends on: 1465728
Depends on: 1466083
Depends on: 1466112
Depends on: 1466113
Depends on: 1466118
Depends on: 1466121
Depends on: 1466126
Depends on: 1466128
Depends on: 1466133
Depends on: 1466458
Depends on: 1466501
Depends on: 1466503
Depends on: 1467124
Depends on: 1467142
Whiteboard: [qf:f64][qf:p1] → [qf:meta]
Depends on: 1468536
Depends on: 1469006
Depends on: 1469082
Depends on: 1471495
Depends on: 1471496
Depends on: 1472130
Depends on: 1473255
Depends on: 1473957
Depends on: 1479430
No longer depends on: 1363208
Blocks: 575000
Blocks: 1465980
Depends on: 1512029
Depends on: 1512260
Depends on: 1512410
Depends on: 1513665
Depends on: 1514210
Depends on: 1515582
Depends on: 1516775
Depends on: 1517424
Depends on: 1518077
Depends on: 1518753
Depends on: 1519414
Depends on: 1514050
Depends on: 1523843
Depends on: 1525629
Depends on: 1525673
Depends on: 1526424
Depends on: 1526588
Depends on: 1527332
Depends on: 1528469
Depends on: 1530608
Depends on: 1534214
Blocks: 907369

This has been enabled for chrome code in bug 1512029 and bug 1514210 (Firefox 66) and for more devtools code in bug 1517210 (Firefox 67). We are using this for content since bug 1523843 (Firefox 67). Fingers crossed but so far these changes have stuck.

There has been some follow-up discussion on doing more compartment sharing for content, but that's a much smaller change and shouldn't affect SpiderMonkey (much). In any case, we've disentangled globals and compartments so this bug is FIXED.

Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla67
Blocks: 1545038
Depends on: 1548304
Performance Impact: --- → ?
Whiteboard: [qf:meta]
You need to log in before you can comment on or make changes to this bug.