Closed Bug 742497 Opened 8 years ago Closed 4 years ago
Only have one context per runtime
Various places in gecko store JSContext pointers on the heap, and with bug 718121 these contexts end up trying to be used from multiple threads at different times, which is broken because contexts can't migrate arbitrarily between different threads. The patches in bug 718121 hack around this, but those hacks need to get removed and the way to do that is store JSRuntime pointers on the heap instead along with metadata that was previously stored on the context implicitly (global object, version, outer window?). With a single threaded runtime only a single context is needed, which gecko can fetch from the runtime as needed. The runtime and context should still be separated, because bug 718121 allows multi threaded runtimes and will have one context per thread (which can be readily fetched from the runtime).
We're certainly moving towards a world where having a context per window like we do now won't be important. Once we have compartment per global, I think all the security checking pieces that we currently still rely on will be removable, and after that there wouldn't be any value left in having a context per window.
Luke surely remembers more details, but our long-term plan has been to shrink context and eventually have it mostly hidden from the user. 'context' would just be the execution state ('regs' maybe + pending exception) and everything else would be wiped out or go to the runtime. Single context per runtime seems like a good step in that direction.
Indeed, I think this bug will leave us in a really good position.
This is done now, see bug 1278223. JSContext refactoring is going on in bug 650361 and deps.
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.