Bug 702915 - Fix write barrier verification during array slowification (r=bhackett)

This commit is contained in:
Bill McCloskey 2011-11-18 14:59:04 -08:00
parent 97d1a6ff51
commit d8c19dcf89
2 changed files with 24 additions and 11 deletions

View File

@ -1451,15 +1451,7 @@ class AutoGCRooter {
/* Implemented in jsgc.cpp. */
inline void trace(JSTracer *trc);
#ifdef __GNUC__
# pragma GCC visibility push(default)
#endif
friend JS_FRIEND_API(void) MarkContext(JSTracer *trc, JSContext *acx);
friend void MarkRuntime(JSTracer *trc);
#ifdef __GNUC__
# pragma GCC visibility pop
#endif
void traceAll(JSTracer *trc);
protected:
AutoGCRooter * const down;

View File

@ -2005,6 +2005,13 @@ AutoGCRooter::trace(JSTracer *trc)
"js::AutoArrayRooter.array");
}
void
AutoGCRooter::traceAll(JSTracer *trc)
{
for (js::AutoGCRooter *gcr = this; gcr; gcr = gcr->down)
gcr->trace(trc);
}
namespace js {
JS_FRIEND_API(void)
@ -2018,8 +2025,8 @@ MarkContext(JSTracer *trc, JSContext *acx)
if (acx->isExceptionPending())
MarkRoot(trc, acx->getPendingException(), "exception");
for (js::AutoGCRooter *gcr = acx->autoGCRooters; gcr; gcr = gcr->down)
gcr->trace(trc);
if (acx->autoGCRooters)
acx->autoGCRooters->traceAll(trc);
if (acx->sharpObjectMap.depth > 0)
js_TraceSharpMap(trc, &acx->sharpObjectMap);
@ -3480,6 +3487,12 @@ oom:
js_free(trc);
}
static void
CheckAutorooter(JSTracer *jstrc, void *thing, JSGCTraceKind kind)
{
static_cast<Cell *>(thing)->markIfUnmarked();
}
/*
* This function is called by EndVerifyBarriers for every heap edge. If the edge
* already existed in the original snapshot, we "cancel it out" by overwriting
@ -3537,6 +3550,14 @@ EndVerifyBarriers(JSContext *cx)
(*c)->needsBarrier_ = false;
}
JS_TRACER_INIT(trc, cx, CheckAutorooter);
JSContext *iter = NULL;
while (JSContext *acx = js_ContextIterator(rt, JS_TRUE, &iter)) {
if (acx->autoGCRooters)
acx->autoGCRooters->traceAll(trc);
}
JS_TRACER_INIT(trc, cx, CheckEdge);
/* Start after the roots. */