As a leftover from the multithreaded runtime era JSPRINCIPALS_(HOLD|DROP) still use atomic operations when updating JSPrincipals::refcount. We should remove that. Also it would be nice to remove the unused JSContext *cx parameter that often requires to pass that cx through many layers of API.
Created attachment 595181 [details] [diff] [review] v1 The patch drops atomic operations around JSPrincipals::refcount and removes the cx parameter from JSPRINCIPALS_(HOLD|DROP). That removal is propagated to the callers when possible.
Is this safe given the comments near the end of bug 143559? nsPrincipal uses atomic increment/decrement on the JSPrincipals, and could race with main-thread code per that bug, right?
(In reply to Boris Zbarsky (:bz) from comment #2) > Is this safe given the comments near the end of bug 143559? nsPrincipal > uses atomic increment/decrement on the JSPrincipals, and could race with > main-thread code per that bug, right? You are absolutely right - the principals must continue to use atomic refcounter mutators. So I mutate the bug to be about eliminating unnecessary cx parameter from principals-related methods. That allows to eliminate few useless compartment enter() calls.
This was addressed in the bug 730221.