Closed Bug 981218 Opened 11 years ago Closed 10 years ago

Remove default compartment objects

Categories

(Core :: JavaScript Engine, defect)

x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla34

People

(Reporter: bholley, Assigned: bholley)

References

Details

Attachments

(6 files)

Now that bug 979481 is landed, we have a null default compartment object for both DOMWindow JSContexts and the SafeJSContext. At that point, we really don't have a use for default compartment objects. Their primary purpose was to specify the compartment that the JSContext should be restored to after JS_SaveFrameChain (which happens during pushing). But I think we can get to a point where we only ever push DOMWindowJSContexts and the SafeJSContext. I think we can probably do the following: (1) Remove the special JSContexts we have for the component loader, sandboxes, etc, and replace them with the SafeJSContext. (2) Fix up any jsapi-tests and whatnot that are sloppy about entering a compartment. (3) Remove default compartment objects, and their associated goop.
\o/
Depends on: 989069
Depends on: 1042996
No longer depends on: 989069
By this point, AutoJSAPI takes care of entering the correct compartment, so this no longer serves a purpose.
Attachment #8476240 - Flags: review?(bobowencode)
Attachment #8476243 - Flags: review?(luke) → review+
Comment on attachment 8476245 [details] [diff] [review] Part 6 - Remove default compartment objects. v1 \o/ \o/ \o/
Attachment #8476245 - Flags: review?(luke) → review+
ISTR some sort of cruft (my memory is not more specific than that) we had to add to deal with the case where you start in compartment A, auto-enter compartment B, auto-leave compartment B, but since then the default-compartment-object has been changed to C. ExclusiveContext::leaveCompartment seems pretty reasonable nowadays, so maybe it's all gone.
Depends on: 1056418
Comment on attachment 8476240 [details] [diff] [review] Part 1 - Remove the JSAutoCompartment from cx pushing. v1 Review of attachment 8476240 [details] [diff] [review]: ----------------------------------------------------------------- Right, we only construct the AutoCxPusher in AutoJSAPI::InitInternal and we always enter a compartment directly afterwards, making this redundant.
Attachment #8476240 - Flags: review?(bobowencode) → review+
Comment on attachment 8476241 [details] [diff] [review] Part 2 - Stop using default compartment objects in nsJSUtils.cpp. v1 Review of attachment 8476241 [details] [diff] [review]: ----------------------------------------------------------------- I've convinced myself that all the callers of nsJSUtils::ReportPendingException will either pass a JSContext that has a script context or pass the SafeJSContext. Again, GetDefaultScopeFromJSContext is only called during an actual push as part of AutoJSAPI::InitInternal, so the JSContext must have a script context or be the SafeJSContext. So in both cases either we would never call js::DefaultObjectForContextOrNull or it would return null anyway.
Attachment #8476241 - Flags: review?(bobowencode) → review+
Comment on attachment 8476242 [details] [diff] [review] Part 3 - Stop using default compartment objects in workers. v1 Review of attachment 8476242 [details] [diff] [review]: ----------------------------------------------------------------- GlobalScope gets set just after the global is created in WorkerPrivate::CreateGlobalScope and (currently until part 6) set as the default compartment object for the context.
Attachment #8476242 - Flags: review?(bobowencode) → review+
Comment on attachment 8476244 [details] [diff] [review] Part 5 - Stop using a default compartment object in the IndexedDB and ProxyAutoConfig JSRuntimes. v1 Review of attachment 8476244 [details] [diff] [review]: ----------------------------------------------------------------- OK, after part 4 it looks like the only place still using DefaultObjectForContextOrNull is JSRuntime::initSelfHosting. This is only called as part of JS_NewContext, which is clearly before we're setting it here.
Attachment #8476244 - Flags: review?(bobowencode) → review+
(In reply to Bob Owen (:bobowen) from comment #13) > I've convinced myself that all the callers of > nsJSUtils::ReportPendingException will either pass a JSContext that has a > script context or pass the SafeJSContext. Yep! Those are now the only 2 contexts left on the main thread. :-)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: