зеркало из https://github.com/mozilla/pjs.git
Don't assert about leaked atoms, do DEBUG fprints instead (68765, r=timeless, sr=jband).
This commit is contained in:
Родитель
c7ccbde27d
Коммит
21fa7a7181
|
@ -675,9 +675,6 @@ JS_PUBLIC_API(void)
|
|||
JS_DestroyRuntime(JSRuntime *rt)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
#ifndef MOZILLA_CLIENT
|
||||
JS_ASSERT(rt->contextList.next == &rt->contextList);
|
||||
#else
|
||||
/* Don't hurt everyone in leaky ol' Mozilla with a fatal JS_ASSERT! */
|
||||
if (rt->contextList.next != &rt->contextList) {
|
||||
JSContext *cx, *iter = NULL;
|
||||
|
@ -688,7 +685,6 @@ JS_DestroyRuntime(JSRuntime *rt)
|
|||
"JS API usage error: %u contexts left in runtime upon JS_DestroyRuntime.\n",
|
||||
cxcount);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
js_FinishAtomState(&rt->atomState);
|
||||
|
|
|
@ -308,25 +308,45 @@ js_FreeAtomState(JSContext *cx, JSAtomState *state)
|
|||
#endif
|
||||
}
|
||||
|
||||
typedef struct UninternArgs {
|
||||
JSRuntime *rt;
|
||||
jsatomid leaks;
|
||||
} UninternArgs;
|
||||
|
||||
JS_STATIC_DLL_CALLBACK(intN)
|
||||
js_atom_uninterner(JSHashEntry *he, intN i, void *arg)
|
||||
{
|
||||
JSAtom *atom;
|
||||
UninternArgs *args;
|
||||
|
||||
atom = (JSAtom *)he;
|
||||
JS_ASSERT(atom->flags & ATOM_INTERNED);
|
||||
JS_ASSERT(ATOM_IS_STRING(atom));
|
||||
js_FinalizeStringRT(arg, ATOM_TO_STRING(atom));
|
||||
args = (UninternArgs *)arg;
|
||||
if (!(atom->flags & ATOM_INTERNED) || !ATOM_IS_STRING(atom))
|
||||
args->leaks++;
|
||||
if (ATOM_IS_STRING(atom))
|
||||
js_FinalizeStringRT(args->rt, ATOM_TO_STRING(atom));
|
||||
return HT_ENUMERATE_NEXT;
|
||||
}
|
||||
|
||||
void
|
||||
js_FinishAtomState(JSAtomState *state)
|
||||
{
|
||||
UninternArgs args;
|
||||
|
||||
if (state->interns == 0)
|
||||
return;
|
||||
JS_HashTableEnumerateEntries(state->table, js_atom_uninterner,
|
||||
state->runtime);
|
||||
args.rt = state->runtime;
|
||||
args.leaks = 0;
|
||||
JS_HashTableEnumerateEntries(state->table, js_atom_uninterner, &args);
|
||||
#ifdef DEBUG
|
||||
if (args.leaks != 0) {
|
||||
fprintf(stderr,
|
||||
"JS engine warning: %lu atoms remain after destroying the JSRuntime.\n"
|
||||
" These atoms may point to freed memory. Things reachable\n"
|
||||
" through them have not been finalized.\n",
|
||||
(unsigned long) args.leaks);
|
||||
}
|
||||
#endif
|
||||
state->interns = 0;
|
||||
js_FreeAtomState(NULL, state);
|
||||
}
|
||||
|
@ -345,7 +365,7 @@ js_atom_marker(JSHashEntry *he, intN i, void *arg)
|
|||
jsval key;
|
||||
|
||||
atom = (JSAtom *)he;
|
||||
args = (MarkArgs *) arg;
|
||||
args = (MarkArgs *)arg;
|
||||
if ((atom->flags & (ATOM_PINNED | ATOM_INTERNED)) ||
|
||||
(args->gcflags & GC_KEEP_ATOMS)) {
|
||||
atom->flags |= ATOM_MARK;
|
||||
|
|
Загрузка…
Ссылка в новой задаче