зеркало из https://github.com/mozilla/pjs.git
Merge tm to mozilla-central. a=blockers
This commit is contained in:
Коммит
f589e76ca6
|
@ -991,7 +991,7 @@ xpc_CreateGlobalObject(JSContext *cx, JSClass *clasp,
|
|||
xpc::PtrAndPrincipalHashKey *priv_key =
|
||||
new xpc::PtrAndPrincipalHashKey(ptr, uri);
|
||||
xpc::CompartmentPrivate *priv =
|
||||
new xpc::CompartmentPrivate(priv_key, wantXrays);
|
||||
new xpc::CompartmentPrivate(priv_key, wantXrays, NS_IsMainThread());
|
||||
if(!CreateNewCompartment(cx, clasp, principal, priv,
|
||||
global, compartment))
|
||||
{
|
||||
|
@ -1028,7 +1028,7 @@ xpc_CreateMTGlobalObject(JSContext *cx, JSClass *clasp,
|
|||
// threadsafety assumptions.
|
||||
nsCOMPtr<nsIPrincipal> principal(do_QueryInterface(ptr));
|
||||
xpc::CompartmentPrivate *priv =
|
||||
new xpc::CompartmentPrivate(ptr, false);
|
||||
new xpc::CompartmentPrivate(ptr, false, NS_IsMainThread());
|
||||
if(!CreateNewCompartment(cx, clasp, principal, priv, global,
|
||||
compartment))
|
||||
{
|
||||
|
|
|
@ -408,22 +408,66 @@ void XPCJSRuntime::TraceXPConnectRoots(JSTracer *trc)
|
|||
JS_DHashTableEnumerate(&mJSHolders, TraceJSHolder, trc);
|
||||
}
|
||||
|
||||
struct Closure
|
||||
{
|
||||
JSContext *cx;
|
||||
bool cycleCollectionEnabled;
|
||||
nsCycleCollectionTraversalCallback *cb;
|
||||
#ifdef DEBUG
|
||||
JSCompartment *compartment;
|
||||
#endif
|
||||
};
|
||||
|
||||
static void
|
||||
CheckParticipatesInCycleCollection(PRUint32 aLangID, void *aThing, void *aClosure)
|
||||
{
|
||||
Closure *closure = static_cast<Closure*>(aClosure);
|
||||
|
||||
#ifdef DEBUG
|
||||
if(aLangID == nsIProgrammingLanguage::JAVASCRIPT &&
|
||||
js_GetGCThingTraceKind(aThing) == JSTRACE_OBJECT)
|
||||
{
|
||||
JSCompartment *c = static_cast<JSObject*>(aThing)->compartment();
|
||||
JS_ASSERT(!closure->compartment || closure->compartment == c);
|
||||
closure->compartment = c;
|
||||
}
|
||||
#endif
|
||||
|
||||
if(!closure->cycleCollectionEnabled &&
|
||||
aLangID == nsIProgrammingLanguage::JAVASCRIPT &&
|
||||
js_GetGCThingTraceKind(aThing) == JSTRACE_OBJECT)
|
||||
{
|
||||
closure->cycleCollectionEnabled =
|
||||
xpc::ParticipatesInCycleCollection(closure->cx,
|
||||
static_cast<JSObject*>(aThing));
|
||||
}
|
||||
}
|
||||
|
||||
static JSDHashOperator
|
||||
NoteJSHolder(JSDHashTable *table, JSDHashEntryHdr *hdr, uint32 number,
|
||||
void *arg)
|
||||
{
|
||||
ObjectHolder* entry = reinterpret_cast<ObjectHolder*>(hdr);
|
||||
Closure *closure = static_cast<Closure*>(arg);
|
||||
|
||||
nsCycleCollectionTraversalCallback* cb =
|
||||
static_cast<nsCycleCollectionTraversalCallback*>(arg);
|
||||
cb->NoteRoot(nsIProgrammingLanguage::CPLUSPLUS, entry->holder,
|
||||
closure->cycleCollectionEnabled = PR_FALSE;
|
||||
#ifdef DEBUG
|
||||
closure->compartment = nsnull;
|
||||
#endif
|
||||
entry->tracer->Trace(entry->holder, CheckParticipatesInCycleCollection,
|
||||
closure);
|
||||
if(!closure->cycleCollectionEnabled)
|
||||
return JS_DHASH_NEXT;
|
||||
|
||||
closure->cb->NoteRoot(nsIProgrammingLanguage::CPLUSPLUS, entry->holder,
|
||||
entry->tracer);
|
||||
|
||||
return JS_DHASH_NEXT;
|
||||
}
|
||||
|
||||
|
||||
void XPCJSRuntime::AddXPConnectRoots(JSContext* cx,
|
||||
void
|
||||
XPCJSRuntime::AddXPConnectRoots(JSContext* cx,
|
||||
nsCycleCollectionTraversalCallback &cb)
|
||||
{
|
||||
// For all JS objects that are held by native objects but aren't held
|
||||
|
@ -447,6 +491,8 @@ void XPCJSRuntime::AddXPConnectRoots(JSContext* cx,
|
|||
nsXPConnect::JSContextParticipant());
|
||||
}
|
||||
|
||||
XPCAutoLock lock(mMapLock);
|
||||
|
||||
XPCWrappedNativeScope::SuspectAllWrappers(this, cx, cb);
|
||||
|
||||
for(XPCRootSetElem *e = mVariantRoots; e ; e = e->GetNextRoot())
|
||||
|
@ -454,12 +500,26 @@ void XPCJSRuntime::AddXPConnectRoots(JSContext* cx,
|
|||
|
||||
for(XPCRootSetElem *e = mWrappedJSRoots; e ; e = e->GetNextRoot())
|
||||
{
|
||||
nsIXPConnectWrappedJS *wrappedJS = static_cast<nsXPCWrappedJS*>(e);
|
||||
cb.NoteXPCOMRoot(wrappedJS);
|
||||
nsXPCWrappedJS *wrappedJS = static_cast<nsXPCWrappedJS*>(e);
|
||||
JSObject *obj = wrappedJS->GetJSObject();
|
||||
|
||||
// Only suspect wrappedJSObjects that are in a compartment that
|
||||
// participates in cycle collection.
|
||||
if(!xpc::ParticipatesInCycleCollection(cx, obj))
|
||||
continue;
|
||||
|
||||
cb.NoteXPCOMRoot(static_cast<nsIXPConnectWrappedJS *>(wrappedJS));
|
||||
}
|
||||
|
||||
if(mJSHolders.ops)
|
||||
JS_DHashTableEnumerate(&mJSHolders, NoteJSHolder, &cb);
|
||||
{
|
||||
Closure closure = { cx, PR_TRUE, &cb
|
||||
#if DEBUG
|
||||
, nsnull
|
||||
#endif
|
||||
};
|
||||
JS_DHashTableEnumerate(&mJSHolders, NoteJSHolder, &closure);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -4512,16 +4512,18 @@ namespace xpc {
|
|||
|
||||
struct CompartmentPrivate
|
||||
{
|
||||
CompartmentPrivate(PtrAndPrincipalHashKey *key, bool wantXrays)
|
||||
CompartmentPrivate(PtrAndPrincipalHashKey *key, bool wantXrays, bool cycleCollectionEnabled)
|
||||
: key(key),
|
||||
ptr(nsnull),
|
||||
wantXrays(wantXrays)
|
||||
wantXrays(wantXrays),
|
||||
cycleCollectionEnabled(cycleCollectionEnabled)
|
||||
{
|
||||
}
|
||||
CompartmentPrivate(nsISupports *ptr, bool wantXrays)
|
||||
CompartmentPrivate(nsISupports *ptr, bool wantXrays, bool cycleCollectionEnabled)
|
||||
: key(nsnull),
|
||||
ptr(ptr),
|
||||
wantXrays(wantXrays)
|
||||
wantXrays(wantXrays),
|
||||
cycleCollectionEnabled(cycleCollectionEnabled)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -4529,8 +4531,25 @@ struct CompartmentPrivate
|
|||
nsAutoPtr<PtrAndPrincipalHashKey> key;
|
||||
nsCOMPtr<nsISupports> ptr;
|
||||
bool wantXrays;
|
||||
bool cycleCollectionEnabled;
|
||||
};
|
||||
|
||||
inline bool
|
||||
CompartmentParticipatesInCycleCollection(JSContext *cx, JSCompartment *compartment)
|
||||
{
|
||||
CompartmentPrivate *priv =
|
||||
static_cast<CompartmentPrivate *>(JS_GetCompartmentPrivate(cx, compartment));
|
||||
NS_ASSERTION(priv, "This should never be null!");
|
||||
|
||||
return priv->cycleCollectionEnabled;
|
||||
}
|
||||
|
||||
inline bool
|
||||
ParticipatesInCycleCollection(JSContext *cx, js::gc::Cell *cell)
|
||||
{
|
||||
return CompartmentParticipatesInCycleCollection(cx, cell->compartment());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#ifdef XPC_IDISPATCH_SUPPORT
|
||||
|
|
|
@ -415,17 +415,22 @@ WrappedNativeSuspecter(JSDHashTable *table, JSDHashEntryHdr *hdr,
|
|||
{
|
||||
NS_ASSERTION(NS_IsMainThread(),
|
||||
"Suspecting wrapped natives from non-main thread");
|
||||
NS_ASSERTION(!JS_IsAboutToBeFinalized(closure->cx, wrapper->GetFlatJSObject()),
|
||||
|
||||
// Only suspect wrappedJSObjects that are in a compartment that
|
||||
// participates in cycle collection.
|
||||
JSObject* obj = wrapper->GetFlatJSObject();
|
||||
if(!xpc::ParticipatesInCycleCollection(closure->cx, obj))
|
||||
return JS_DHASH_NEXT;
|
||||
|
||||
NS_ASSERTION(!JS_IsAboutToBeFinalized(closure->cx, obj),
|
||||
"WrappedNativeSuspecter attempting to touch dead object");
|
||||
|
||||
// Only record objects that might be part of a cycle as roots, unless
|
||||
// the callback wants all traces (a debug feature).
|
||||
if(!(closure->cb.WantAllTraces()) &&
|
||||
!nsXPConnect::IsGray(wrapper->GetFlatJSObject()))
|
||||
if(!(closure->cb.WantAllTraces()) && !nsXPConnect::IsGray(obj))
|
||||
return JS_DHASH_NEXT;
|
||||
|
||||
closure->cb.NoteRoot(nsIProgrammingLanguage::JAVASCRIPT,
|
||||
wrapper->GetFlatJSObject(),
|
||||
closure->cb.NoteRoot(nsIProgrammingLanguage::JAVASCRIPT, obj,
|
||||
nsXPConnect::GetXPConnect());
|
||||
}
|
||||
|
||||
|
|
|
@ -956,8 +956,11 @@ nsCookieService::TryInitDB(PRBool aDeleteExistingDB)
|
|||
// make operations on the table asynchronous, for performance
|
||||
mDBState->dbConn->ExecuteSimpleSQL(NS_LITERAL_CSTRING("PRAGMA synchronous = OFF"));
|
||||
|
||||
// Use write-ahead-logging for performance.
|
||||
// Use write-ahead-logging for performance. We cap the autocheckpoint limit at
|
||||
// 16 pages (around 500KB).
|
||||
mDBState->dbConn->ExecuteSimpleSQL(NS_LITERAL_CSTRING("PRAGMA journal_mode = WAL"));
|
||||
mDBState->dbConn->ExecuteSimpleSQL(NS_LITERAL_CSTRING(
|
||||
"PRAGMA wal_autocheckpoint = 16"));
|
||||
|
||||
// cache frequently used statements (for insertion, deletion, and updating)
|
||||
rv = mDBState->dbConn->CreateStatement(NS_LITERAL_CSTRING(
|
||||
|
|
Загрузка…
Ссылка в новой задаче