Fix bungled GC_KEEP_ATOMS logic (51954, r=mccabe, a=jband).

This commit is contained in:
brendan%mozilla.org 2000-09-29 00:18:15 +00:00
Родитель b28c211264
Коммит 9f53fa4c3a
3 изменённых файлов: 14 добавлений и 14 удалений

Просмотреть файл

@ -306,6 +306,7 @@ js_FreeAtomState(JSContext *cx, JSAtomState *state)
}
typedef struct MarkArgs {
uintN gcflags;
JSGCThingMarker mark;
void *data;
} MarkArgs;
@ -314,15 +315,15 @@ JS_STATIC_DLL_CALLBACK(intN)
js_atom_marker(JSHashEntry *he, intN i, void *arg)
{
JSAtom *atom;
jsval key;
MarkArgs *args;
jsval key;
atom = (JSAtom *)he;
if (atom->flags & ATOM_PINNED) {
args = (MarkArgs *) arg;
if ((atom->flags & ATOM_PINNED) || (args->gcflags & GC_KEEP_ATOMS)) {
atom->flags |= ATOM_MARK;
key = ATOM_KEY(atom);
if (JSVAL_IS_GCTHING(key)) {
args = (MarkArgs *) arg;
args->mark(JSVAL_TO_GCTHING(key), args->data);
}
}
@ -330,10 +331,12 @@ js_atom_marker(JSHashEntry *he, intN i, void *arg)
}
void
js_MarkAtomState(JSAtomState *state, JSGCThingMarker mark, void *data)
js_MarkAtomState(JSAtomState *state, uintN gcflags, JSGCThingMarker mark,
void *data)
{
MarkArgs args;
args.gcflags = gcflags;
args.mark = mark;
args.data = data;
JS_HashTableEnumerateEntries(state->table, js_atom_marker, &args);
@ -343,16 +346,12 @@ JS_STATIC_DLL_CALLBACK(intN)
js_atom_sweeper(JSHashEntry *he, intN i, void *arg)
{
JSAtom *atom;
uintN gcflags;
atom = (JSAtom *)he;
if (atom->flags & ATOM_MARK) {
atom->flags &= ~ATOM_MARK;
return HT_ENUMERATE_NEXT;
}
gcflags = (uintN)arg;
if (gcflags & GC_KEEP_ATOMS)
return HT_ENUMERATE_NEXT;
JS_ASSERT((atom->flags & ATOM_PINNED) == 0);
atom->entry.key = NULL;
atom->flags = 0;
@ -360,9 +359,9 @@ js_atom_sweeper(JSHashEntry *he, intN i, void *arg)
}
void
js_SweepAtomState(JSAtomState *state, uintN gcflags)
js_SweepAtomState(JSAtomState *state)
{
JS_HashTableEnumerateEntries(state->table, js_atom_sweeper, (void*)gcflags);
JS_HashTableEnumerateEntries(state->table, js_atom_sweeper, NULL);
}
JS_STATIC_DLL_CALLBACK(intN)

Просмотреть файл

@ -244,10 +244,11 @@ typedef void
(*JSGCThingMarker)(void *thing, void *data);
extern void
js_MarkAtomState(JSAtomState *state, JSGCThingMarker mark, void *data);
js_MarkAtomState(JSAtomState *state, uintN gcflags, JSGCThingMarker mark,
void *data);
extern void
js_SweepAtomState(JSAtomState *state, uintN gcflags);
js_SweepAtomState(JSAtomState *state);
extern void
js_UnpinPinnedAtoms(JSAtomState *state);

Просмотреть файл

@ -1059,7 +1059,7 @@ restart:
JS_HashTableEnumerateEntries(rt->gcRootsHash, gc_root_marker, cx);
if (rt->gcLocksHash)
JS_HashTableEnumerateEntries(rt->gcLocksHash, gc_lock_marker, cx);
js_MarkAtomState(&rt->atomState, gc_mark_atom_key_thing, cx);
js_MarkAtomState(&rt->atomState, gcflags, gc_mark_atom_key_thing, cx);
iter = NULL;
while ((acx = js_ContextIterator(rt, &iter)) != NULL) {
/*
@ -1137,7 +1137,7 @@ restart:
* Sweep phase, with interleaved finalize phase.
*/
finalpos = 0;
js_SweepAtomState(&rt->atomState, gcflags);
js_SweepAtomState(&rt->atomState);
for (a = rt->gcArenaPool.first.next; a; a = a->next) {
flagp = (uint8 *) a->base;
split = (uint8 *) FIRST_THING_PAGE(a);