Bug 1248726 - Simplify PCLocationMap even further; r=fitzgen

This commit is contained in:
Terrence Cole 2016-02-17 09:49:42 -08:00
parent 97fa807eb0
commit 403ceb2af6
2 changed files with 16 additions and 12 deletions

View File

@ -999,10 +999,8 @@ SavedFrame::toStringMethod(JSContext* cx, unsigned argc, Value* vp)
bool bool
SavedStacks::init() SavedStacks::init()
{ {
if (!pcLocationMap.init()) return frames.init() &&
return false; pcLocationMap.init();
return frames.init();
} }
bool bool
@ -1049,13 +1047,7 @@ SavedStacks::sweep()
void void
SavedStacks::trace(JSTracer* trc) SavedStacks::trace(JSTracer* trc)
{ {
if (pcLocationMap.initialized()) { pcLocationMap.trace(trc);
// Mark each of the source strings in our pc to location cache.
for (PCLocationMap::Enum e(pcLocationMap); !e.empty(); e.popFront()) {
LocationValue& loc = e.front().value();
TraceEdge(trc, &loc.source, "SavedStacks::PCLocationMap's memoized script source name");
}
}
} }
uint32_t uint32_t

View File

@ -223,6 +223,7 @@ class SavedStacks {
RelocatablePtrScript script; RelocatablePtrScript script;
jsbytecode* pc; jsbytecode* pc;
void trace(JSTracer* trc) { /* PCKey is weak. */ }
bool needsSweep() { return IsAboutToBeFinalized(&script); } bool needsSweep() { return IsAboutToBeFinalized(&script); }
}; };
@ -239,8 +240,12 @@ class SavedStacks {
} }
bool needsSweep() { bool needsSweep() {
// LocationValue is always held strongly, but in a weak map.
// Assert that it has been marked already, but allow it to be
// ejected from the map when the key dies.
MOZ_ASSERT(source); MOZ_ASSERT(source);
return IsAboutToBeFinalized(&source); MOZ_ASSERT(!IsAboutToBeFinalized(&source));
return true;
} }
RelocatablePtrAtom source; RelocatablePtrAtom source;
@ -282,6 +287,13 @@ class SavedStacks {
} }
}; };
// We eagerly Atomize the script source stored in LocationValue because
// asm.js does not always have a JSScript and the source might not be
// available when we need it later. However, since the JSScript does not
// actually hold this atom, we have to trace it strongly to keep it alive.
// Thus, it takes two GC passes to fully clean up this table: the first GC
// removes the dead script; the second will clear out the source atom since
// it is no longer held by the table.
using PCLocationMap = GCHashMap<PCKey, LocationValue, PCLocationHasher, SystemAllocPolicy>; using PCLocationMap = GCHashMap<PCKey, LocationValue, PCLocationHasher, SystemAllocPolicy>;
PCLocationMap pcLocationMap; PCLocationMap pcLocationMap;