- Back out part of patch from tlundeen@webcrossing.com, my fault for taking it

in part (the entire patch made JSContexts ref-counted, but that is not an API
  compatible change, and it doesn't help clean up at JS_Finish time if the API
  user leaks JSContext refs anyway).  52835, r=jband.
- First part of 64-bit portability fix for 52792, r=jnance.  More work needed.
- Fix bogus assert and minimization in js_AllocStack, too.
This commit is contained in:
brendan%mozilla.org 2000-09-16 22:17:22 +00:00
Родитель 8b640618cc
Коммит 3fae06f653
3 изменённых файлов: 28 добавлений и 10 удалений

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

@ -658,11 +658,23 @@ bad:
JS_PUBLIC_API(void)
JS_DestroyRuntime(JSRuntime *rt)
{
JSContext *cx, *iter;
#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;
uintN cxcount = 0;
while ((cx = js_ContextIterator(rt, &iter)) != NULL)
cxcount++;
fprintf(stderr,
"JS API usage error: %u contexts left in runtime upon JS_DestroyRuntime.\n",
cxcount);
}
#endif
#endif
iter = NULL;
while ((cx = js_ContextIterator(rt, &iter)) != NULL)
js_DestroyContext(cx, JS_NO_GC);
js_FinishGC(rt);
#ifdef JS_THREADSAFE
if (rt->gcLock)

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

@ -80,7 +80,12 @@
#define GC_FLAGS_SIZE (GC_THINGS_SIZE / sizeof(JSGCThing))
#define GC_ARENA_SIZE (GC_THINGS_SIZE + GC_FLAGS_SIZE)
/* The private JSGCThing struct, which describes a gcFreelist element. */
/*
* The private JSGCThing struct, which describes a gcFreelist element. We use
* it also for things to be finalized in rt->gcFinalVec, in which case next is
* not a next-thing link, it points to the thing to be finalized. The flagp
* member points to this thing's flags, for fast recycling and finalization.
*/
struct JSGCThing {
JSGCThing *next;
uint8 *flagp;
@ -156,7 +161,7 @@ struct JSGCThing {
* the card-mark byte on split's low byte.)
*/
#define GC_PAGE_SHIFT 10
#define GC_PAGE_MASK JS_BITMASK(GC_PAGE_SHIFT)
#define GC_PAGE_MASK ((jsuword) JS_BITMASK(GC_PAGE_SHIFT))
#define GC_PAGE_SIZE JS_BIT(GC_PAGE_SHIFT)
typedef struct JSGCPageInfo {
@ -789,6 +794,8 @@ js_MarkGCThing(JSContext *cx, void *thing, void *arg)
break;
}
}
} else {
strcpy(name, "**UNKNOWN OBJECT MAP ENTRY**");
}
#endif
GC_MARK(cx, JSVAL_TO_GCTHING(v), name, arg);
@ -1230,6 +1237,7 @@ out:
JS_NOTIFY_GC_DONE(rt);
JS_UNLOCK_GC(rt);
#endif
if (rt->gcCallback)
if (!(gcflags & GC_LAST_CONTEXT) && rt->gcCallback)
(void) rt->gcCallback(cx, JSGC_END);
}

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

@ -406,11 +406,9 @@ js_AllocStack(JSContext *cx, uintN nslots, void **markp)
#ifdef DEBUG
jsuword depthdiff = fp->script->depth * sizeof(jsval);
JS_ASSERT(JS_UPTRDIFF(fp->sp, fp->spbase) <= depthdiff);
JS_ASSERT(JS_UPTRDIFF(*markp, fp->spbase) <= depthdiff);
JS_ASSERT(JS_UPTRDIFF(*markp, fp->spbase) >= depthdiff);
#endif
end = fp->spbase + fp->script->depth;
if (end > (jsval *) *markp)
end = (jsval *) *markp;
for (vp = fp->sp; vp < end; vp++)
*vp = JSVAL_VOID;
}