Bug 951722 - Add asserts that hash table postbarriers are working for debug scopes r=terrence

This commit is contained in:
Jon Coppeard 2013-12-19 10:46:41 +00:00
Родитель a207ce2120
Коммит 59d8377c49
3 изменённых файлов: 38 добавлений и 0 удалений

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

@ -290,6 +290,13 @@ StoreBuffer::mark(JSTracer *trc)
bufferRelocVal.mark(this, trc);
bufferRelocCell.mark(this, trc);
bufferGeneric.mark(this, trc);
#if defined(DEBUG)
for (CompartmentsIter c(runtime_, SkipAtoms); !c.done(); c.next()) {
if (c->debugScopes)
c->debugScopes->checkHashTablesAfterMovingGC(runtime_);
}
#endif
}
void

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

@ -1693,6 +1693,33 @@ DebugScopes::sweep(JSRuntime *rt)
}
}
#if defined(DEBUG) && defined(JSGC_GENERATIONAL)
void
DebugScopes::checkHashTablesAfterMovingGC(JSRuntime *runtime)
{
/*
* This is called at the end of StoreBuffer::mark() to check that our
* postbarriers have worked and that no hashtable keys (or values) are left
* pointing into the nursery.
*/
JS::shadow::Runtime *rt = JS::shadow::Runtime::asShadowRuntime(runtime);
for (ObjectWeakMap::Range r = proxiedScopes.all(); !r.empty(); r.popFront()) {
JS_ASSERT(!IsInsideNursery(rt, r.front().key().get()));
JS_ASSERT(!IsInsideNursery(rt, r.front().value().get()));
}
for (MissingScopeMap::Range r = missingScopes.all(); !r.empty(); r.popFront()) {
JS_ASSERT(!IsInsideNursery(rt, r.front().key().cur()));
JS_ASSERT(!IsInsideNursery(rt, r.front().key().block()));
JS_ASSERT(!IsInsideNursery(rt, r.front().value().get()));
}
for (LiveScopeMap::Range r = liveScopes.all(); !r.empty(); r.popFront()) {
JS_ASSERT(!IsInsideNursery(rt, r.front().key()));
JS_ASSERT(!IsInsideNursery(rt, r.front().value().cur_.get()));
JS_ASSERT(!IsInsideNursery(rt, r.front().value().block_.get()));
}
}
#endif
/*
* Unfortunately, GetDebugScopeForFrame needs to work even outside debug mode
* (in particular, JS_GetFrameScopeChain does not require debug mode). Since

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

@ -618,6 +618,7 @@ class ScopeIterKey
class ScopeIterVal
{
friend class ScopeIter;
friend class DebugScopes;
AbstractFramePtr frame_;
RelocatablePtr<JSObject> cur_;
@ -746,6 +747,9 @@ class DebugScopes
public:
void mark(JSTracer *trc);
void sweep(JSRuntime *rt);
#if defined(DEBUG) && defined(JSGC_GENERATIONAL)
void checkHashTablesAfterMovingGC(JSRuntime *rt);
#endif
static DebugScopeObject *hasDebugScope(JSContext *cx, ScopeObject &scope);
static bool addDebugScope(JSContext *cx, ScopeObject &scope, DebugScopeObject &debugScope);