mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-16 14:55:47 +00:00
Bug 737573 - Fix leak in SaveScriptFilename (r=igor)
This commit is contained in:
parent
1c604a679f
commit
b171c214ba
@ -98,6 +98,12 @@ JSCompartment::JSCompartment(JSRuntime *rt)
|
||||
|
||||
JSCompartment::~JSCompartment()
|
||||
{
|
||||
/*
|
||||
* Even though all objects in the compartment are dead, we may have keep
|
||||
* some filenames around because of gcKeepAtoms.
|
||||
*/
|
||||
FreeScriptFilenames(this);
|
||||
|
||||
#ifdef JS_METHODJIT
|
||||
Foreground::delete_(jaegerCompartment_);
|
||||
#endif
|
||||
|
@ -463,7 +463,7 @@ exn_trace(JSTracer *trc, JSObject *obj)
|
||||
if (elem->funName)
|
||||
MarkString(trc, &elem->funName, "stack trace function name");
|
||||
if (IS_GC_MARKING_TRACER(trc) && elem->filename)
|
||||
js_MarkScriptFilename(elem->filename);
|
||||
MarkScriptFilename(elem->filename);
|
||||
vcount += elem->argc;
|
||||
}
|
||||
vp = GetStackTraceValueBuffer(priv);
|
||||
|
@ -3252,7 +3252,7 @@ SweepPhase(JSContext *cx, JSGCInvocationKind gckind)
|
||||
* script's filename. See bug 323267.
|
||||
*/
|
||||
for (GCCompartmentsIter c(rt); !c.done(); c.next())
|
||||
js_SweepScriptFilenames(c);
|
||||
SweepScriptFilenames(c);
|
||||
|
||||
/*
|
||||
* This removes compartments from rt->compartment, so we do it last to make
|
||||
|
@ -886,8 +886,6 @@ SaveScriptFilename(JSContext *cx, const char *filename)
|
||||
return sfe->filename;
|
||||
}
|
||||
|
||||
} /* namespace js */
|
||||
|
||||
/*
|
||||
* Back up from a saved filename by its offset within its hash table entry.
|
||||
*/
|
||||
@ -895,14 +893,14 @@ SaveScriptFilename(JSContext *cx, const char *filename)
|
||||
((ScriptFilenameEntry *) ((fn) - offsetof(ScriptFilenameEntry, filename)))
|
||||
|
||||
void
|
||||
js_MarkScriptFilename(const char *filename)
|
||||
MarkScriptFilename(const char *filename)
|
||||
{
|
||||
ScriptFilenameEntry *sfe = FILENAME_TO_SFE(filename);
|
||||
sfe->marked = true;
|
||||
}
|
||||
|
||||
void
|
||||
js_SweepScriptFilenames(JSCompartment *comp)
|
||||
SweepScriptFilenames(JSCompartment *comp)
|
||||
{
|
||||
ScriptFilenameTable &table = comp->scriptFilenameTable;
|
||||
for (ScriptFilenameTable::Enum e(table); !e.empty(); e.popFront()) {
|
||||
@ -916,6 +914,18 @@ js_SweepScriptFilenames(JSCompartment *comp)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
FreeScriptFilenames(JSCompartment *comp)
|
||||
{
|
||||
ScriptFilenameTable &table = comp->scriptFilenameTable;
|
||||
for (ScriptFilenameTable::Enum e(table); !e.empty(); e.popFront())
|
||||
Foreground::free_(e.front());
|
||||
|
||||
table.clear();
|
||||
}
|
||||
|
||||
} /* namespace js */
|
||||
|
||||
/*
|
||||
* JSScript data structures memory alignment:
|
||||
*
|
||||
@ -1888,7 +1898,7 @@ JSScript::markChildren(JSTracer *trc)
|
||||
MarkObject(trc, &globalObject, "object");
|
||||
|
||||
if (IS_GC_MARKING_TRACER(trc) && filename)
|
||||
js_MarkScriptFilename(filename);
|
||||
MarkScriptFilename(filename);
|
||||
|
||||
bindings.trace(trc);
|
||||
|
||||
|
@ -793,12 +793,6 @@ StackDepth(JSScript *script)
|
||||
return script->nslots - script->nfixed;
|
||||
}
|
||||
|
||||
extern void
|
||||
js_MarkScriptFilename(const char *filename);
|
||||
|
||||
extern void
|
||||
js_SweepScriptFilenames(JSCompartment *comp);
|
||||
|
||||
/*
|
||||
* New-script-hook calling is factored from NewScriptFromEmitter so that it
|
||||
* and callers of XDRScript can share this code. In the case of callers
|
||||
@ -813,6 +807,15 @@ js_CallDestroyScriptHook(JSContext *cx, JSScript *script);
|
||||
|
||||
namespace js {
|
||||
|
||||
extern void
|
||||
MarkScriptFilename(const char *filename);
|
||||
|
||||
extern void
|
||||
SweepScriptFilenames(JSCompartment *comp);
|
||||
|
||||
extern void
|
||||
FreeScriptFilenames(JSCompartment *comp);
|
||||
|
||||
struct ScriptOpcodeCountsPair
|
||||
{
|
||||
JSScript *script;
|
||||
|
Loading…
Reference in New Issue
Block a user