mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 899367 - Only use JSOPTION_UNROOTED_GLOBAL for DOM JSContexts. r=mccr8
We don't cycle collect any other kind, so there's no difference between marking them gray and letting the JS engine mark them black. This also gets rid of that nasty code which reset the flag, which billm theorizes has to do with faulty logic in ContextHolder when creating ephemeral sandbox cxes. The assertion in this patch should catch us if anything goes wrong.
This commit is contained in:
parent
2903ab3e4d
commit
59b924c116
@ -851,7 +851,8 @@ nsJSContext::nsJSContext(bool aGCOnDestruction,
|
||||
|
||||
++sContextCount;
|
||||
|
||||
mDefaultJSOptions = JSOPTION_PRIVATE_IS_NSISUPPORTS;
|
||||
mDefaultJSOptions = JSOPTION_PRIVATE_IS_NSISUPPORTS |
|
||||
JSOPTION_UNROOTED_GLOBAL;
|
||||
|
||||
mContext = ::JS_NewContext(sRuntime, gStackSize);
|
||||
if (mContext) {
|
||||
|
@ -831,8 +831,7 @@ public:
|
||||
// call to JS_SetGCParameter inside CreateJSContextForWorker.
|
||||
WorkerJSRuntime(WorkerPrivate* aWorkerPrivate)
|
||||
: CycleCollectedJSRuntime(WORKER_DEFAULT_RUNTIME_HEAPSIZE,
|
||||
JS_NO_HELPER_THREADS,
|
||||
false),
|
||||
JS_NO_HELPER_THREADS),
|
||||
mWorkerPrivate(aWorkerPrivate)
|
||||
{
|
||||
// We need to ensure that a JSContext outlives the cycle collector, and
|
||||
|
@ -2874,7 +2874,7 @@ SourceHook(JSContext *cx, JS::Handle<JSScript*> script, jschar **src,
|
||||
}
|
||||
|
||||
XPCJSRuntime::XPCJSRuntime(nsXPConnect* aXPConnect)
|
||||
: CycleCollectedJSRuntime(32L * 1024L * 1024L, JS_USE_HELPER_THREADS, true),
|
||||
: CycleCollectedJSRuntime(32L * 1024L * 1024L, JS_USE_HELPER_THREADS),
|
||||
mJSContextStack(new XPCJSContextStack()),
|
||||
mCallContext(nullptr),
|
||||
mAutoRoots(nullptr),
|
||||
|
@ -475,12 +475,10 @@ NoteJSChildGrayWrapperShim(void* aData, void* aThing)
|
||||
static const JSZoneParticipant sJSZoneCycleCollectorGlobal;
|
||||
|
||||
CycleCollectedJSRuntime::CycleCollectedJSRuntime(uint32_t aMaxbytes,
|
||||
JSUseHelperThreads aUseHelperThreads,
|
||||
bool aExpectUnrootedGlobals)
|
||||
JSUseHelperThreads aUseHelperThreads)
|
||||
: mGCThingCycleCollectorGlobal(sGCThingCycleCollectorGlobal),
|
||||
mJSZoneCycleCollectorGlobal(sJSZoneCycleCollectorGlobal),
|
||||
mJSRuntime(nullptr),
|
||||
mExpectUnrootedGlobals(aExpectUnrootedGlobals)
|
||||
mJSRuntime(nullptr)
|
||||
#ifdef DEBUG
|
||||
, mObjectToUnlink(nullptr)
|
||||
#endif
|
||||
@ -545,7 +543,10 @@ CycleCollectedJSRuntime::MaybeTraceGlobals(JSTracer* aTracer) const
|
||||
{
|
||||
JSContext* iter = nullptr;
|
||||
while (JSContext* acx = JS_ContextIterator(Runtime(), &iter)) {
|
||||
MOZ_ASSERT(js::HasUnrootedGlobal(acx) == mExpectUnrootedGlobals);
|
||||
// DOM JSContexts are the only JSContexts that cycle-collect their default
|
||||
// compartment object, so they're the only ones that we need to do the
|
||||
// JSOPTION_UNROOTED_GLOBAL dance for. The other ones are just marked black.
|
||||
MOZ_ASSERT(js::HasUnrootedGlobal(acx) == !!GetScriptContextFromJSContext(acx));
|
||||
if (!js::HasUnrootedGlobal(acx)) {
|
||||
continue;
|
||||
}
|
||||
@ -1187,21 +1188,7 @@ CycleCollectedJSRuntime::OnGC(JSGCStatus aStatus)
|
||||
{
|
||||
switch (aStatus) {
|
||||
case JSGC_BEGIN:
|
||||
{
|
||||
// XXXkhuey do we still need this?
|
||||
// We seem to sometime lose the unrooted global flag. Restore it
|
||||
// here. FIXME: bug 584495.
|
||||
if (mExpectUnrootedGlobals){
|
||||
JSContext* iter = nullptr;
|
||||
while (JSContext* acx = JS_ContextIterator(Runtime(), &iter)) {
|
||||
if (!js::HasUnrootedGlobal(acx)) {
|
||||
JS_ToggleOptions(acx, JSOPTION_UNROOTED_GLOBAL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case JSGC_END:
|
||||
{
|
||||
/*
|
||||
@ -1230,11 +1217,5 @@ CycleCollectedJSRuntime::OnGC(JSGCStatus aStatus)
|
||||
bool
|
||||
CycleCollectedJSRuntime::OnContext(JSContext* aCx, unsigned aOperation)
|
||||
{
|
||||
if (mExpectUnrootedGlobals && aOperation == JSCONTEXT_NEW) {
|
||||
// XXXkhuey bholley is going to make this go away, but for now XPConnect
|
||||
// needs it.
|
||||
JS_ToggleOptions(aCx, JSOPTION_UNROOTED_GLOBAL);
|
||||
}
|
||||
|
||||
return CustomContextCallback(aCx, aOperation);
|
||||
}
|
||||
|
@ -83,8 +83,7 @@ class CycleCollectedJSRuntime
|
||||
friend class IncrementalFinalizeRunnable;
|
||||
protected:
|
||||
CycleCollectedJSRuntime(uint32_t aMaxbytes,
|
||||
JSUseHelperThreads aUseHelperThreads,
|
||||
bool aExpectUnrootedGlobals);
|
||||
JSUseHelperThreads aUseHelperThreads);
|
||||
virtual ~CycleCollectedJSRuntime();
|
||||
|
||||
size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
|
||||
@ -223,8 +222,6 @@ private:
|
||||
|
||||
nsRefPtr<IncrementalFinalizeRunnable> mFinalizeRunnable;
|
||||
|
||||
bool mExpectUnrootedGlobals;
|
||||
|
||||
#ifdef DEBUG
|
||||
void* mObjectToUnlink;
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user