зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1304653 - Improve heap checking zeal mode r=sfink
This commit is contained in:
Родитель
ccb9a8b6b9
Коммит
c2222d8e7c
|
@ -128,7 +128,7 @@ struct MOZ_RAII AutoStopVerifyingBarriers
|
|||
|
||||
#ifdef JSGC_HASH_TABLE_CHECKS
|
||||
void CheckHashTablesAfterMovingGC(JSRuntime* rt);
|
||||
void CheckHeapAfterMovingGC(JSRuntime* rt);
|
||||
void CheckHeapAfterGC(JSRuntime* rt);
|
||||
#endif
|
||||
|
||||
struct MovingTracer : JS::CallbackTracer
|
||||
|
|
|
@ -473,6 +473,12 @@ CheckHeapTracer::init()
|
|||
return visited.init();
|
||||
}
|
||||
|
||||
inline static bool
|
||||
IsValidGCThingPointer(Cell* cell)
|
||||
{
|
||||
return (uintptr_t(cell) & CellMask) == 0;
|
||||
}
|
||||
|
||||
void
|
||||
CheckHeapTracer::onChild(const JS::GCCellPtr& thing)
|
||||
{
|
||||
|
@ -485,9 +491,10 @@ CheckHeapTracer::onChild(const JS::GCCellPtr& thing)
|
|||
return;
|
||||
}
|
||||
|
||||
if (!IsGCThingValidAfterMovingGC(cell)) {
|
||||
if (!IsValidGCThingPointer(cell) || !IsGCThingValidAfterMovingGC(cell))
|
||||
{
|
||||
failures++;
|
||||
fprintf(stderr, "Stale pointer %p\n", cell);
|
||||
fprintf(stderr, "Bad pointer %p\n", cell);
|
||||
const char* name = contextName();
|
||||
for (int index = parentIndex; index != -1; index = stack[index].parentIndex) {
|
||||
const WorkItem& parent = stack[index];
|
||||
|
@ -537,7 +544,7 @@ CheckHeapTracer::check(AutoLockForExclusiveAccess& lock)
|
|||
}
|
||||
|
||||
void
|
||||
js::gc::CheckHeapAfterMovingGC(JSRuntime* rt)
|
||||
js::gc::CheckHeapAfterGC(JSRuntime* rt)
|
||||
{
|
||||
AutoTraceSession session(rt, JS::HeapState::Tracing);
|
||||
CheckHeapTracer tracer(rt);
|
||||
|
|
|
@ -908,7 +908,7 @@ const char* gc::ZealModeHelpText =
|
|||
" 12: (ElementsBarrier) Always use the individual element post-write barrier, regardless of elements size\n"
|
||||
" 13: (CheckHashTablesOnMinorGC) Check internal hashtables on minor GC\n"
|
||||
" 14: (Compact) Perform a shrinking collection every N allocations\n"
|
||||
" 15: (CheckHeapOnMovingGC) Walk the heap to check all pointers have been updated\n"
|
||||
" 15: (CheckHeapAfterGC) Walk the heap to check its integrity after every GC\n"
|
||||
" 16: (CheckNursery) Check nursery integrity on minor GC\n";
|
||||
|
||||
void
|
||||
|
@ -6337,9 +6337,9 @@ GCRuntime::collect(bool nonincrementalByAPI, SliceBudget budget, JS::gcreason::R
|
|||
maybeDoCycleCollection();
|
||||
|
||||
#ifdef JS_GC_ZEAL
|
||||
if (shouldCompact() && rt->hasZealMode(ZealMode::CheckHeapOnMovingGC)) {
|
||||
if (rt->hasZealMode(ZealMode::CheckHeapAfterGC)) {
|
||||
gcstats::AutoPhase ap(rt->gc.stats, gcstats::PHASE_TRACE_HEAP);
|
||||
CheckHeapAfterMovingGC(rt);
|
||||
CheckHeapAfterGC(rt);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -6542,8 +6542,8 @@ GCRuntime::minorGC(JS::gcreason::Reason reason, gcstats::Phase phase)
|
|||
blocksToFreeAfterMinorGC.freeAll();
|
||||
|
||||
#ifdef JS_GC_ZEAL
|
||||
if (rt->hasZealMode(ZealMode::CheckHeapOnMovingGC))
|
||||
CheckHeapAfterMovingGC(rt);
|
||||
if (rt->hasZealMode(ZealMode::CheckHeapAfterGC))
|
||||
CheckHeapAfterGC(rt);
|
||||
#endif
|
||||
|
||||
{
|
||||
|
|
|
@ -1222,7 +1222,7 @@ CheckValueAfterMovingGC(const JS::Value& value)
|
|||
D(ElementsBarrier, 12) \
|
||||
D(CheckHashTablesOnMinorGC, 13) \
|
||||
D(Compact, 14) \
|
||||
D(CheckHeapOnMovingGC, 15) \
|
||||
D(CheckHeapAfterGC, 15) \
|
||||
D(CheckNursery, 16)
|
||||
|
||||
enum class ZealMode {
|
||||
|
|
Загрузка…
Ссылка в новой задаче