mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-02 10:00:54 +00:00
Backout 1b55728f51ad (bug 633016) due to leaking jsdScript objects
This commit is contained in:
parent
a2f27a580c
commit
163812a8da
@ -1249,23 +1249,9 @@ EvalKernel(JSContext *cx, uintN argc, Value *vp, EvalType evalType, JSStackFrame
|
||||
|
||||
JSScript *script = NULL;
|
||||
JSScript **bucket = EvalCacheHash(cx, linearStr);
|
||||
if (evalType == DIRECT_EVAL && caller->isFunctionFrame() && !caller->isEvalFrame()) {
|
||||
if (evalType == DIRECT_EVAL && caller->isFunctionFrame() && !caller->isEvalFrame())
|
||||
script = EvalCacheLookup(cx, linearStr, caller, staticLevel, principals, scopeobj, bucket);
|
||||
|
||||
/*
|
||||
* Although the eval cache keeps a script alive from the perspective of
|
||||
* the JS engine, from a jsdbgapi user's perspective each eval()
|
||||
* creates and destroys a script. This hides implementation details and
|
||||
* allows jsdbgapi clients to avoid calling JS_GetScriptObject after a
|
||||
* script has been returned to the eval cache, which is invalid since
|
||||
* script->u.object aliases script->u.nextToGC.
|
||||
*/
|
||||
if (script) {
|
||||
js_CallNewScriptHook(cx, script, NULL);
|
||||
MUST_FLOW_THROUGH("destroy");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* We can't have a callerFrame (down in js::Execute's terms) if we're in
|
||||
* global code (or if we're an indirect eval).
|
||||
@ -1294,9 +1280,6 @@ EvalKernel(JSContext *cx, uintN argc, Value *vp, EvalType evalType, JSStackFrame
|
||||
cx->runtime->atomState.evalAtom) &&
|
||||
Execute(cx, scopeobj, script, callerFrame, JSFRAME_EVAL, vp);
|
||||
|
||||
destroy:
|
||||
js_CallDestroyScriptHook(cx, script);
|
||||
|
||||
script->u.nextToGC = *bucket;
|
||||
*bucket = script;
|
||||
#ifdef CHECK_SCRIPT_OWNER
|
||||
|
@ -1561,7 +1561,7 @@ js_CallNewScriptHook(JSContext *cx, JSScript *script, JSFunction *fun)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
JS_FRIEND_API(void)
|
||||
js_CallDestroyScriptHook(JSContext *cx, JSScript *script)
|
||||
{
|
||||
JSDestroyScriptHook hook;
|
||||
@ -1569,7 +1569,6 @@ js_CallDestroyScriptHook(JSContext *cx, JSScript *script)
|
||||
hook = cx->debugHooks->destroyScriptHook;
|
||||
if (hook)
|
||||
hook(cx, script, cx->debugHooks->destroyScriptHookData);
|
||||
JS_ClearScriptTraps(cx, script);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1582,6 +1581,9 @@ DestroyScript(JSContext *cx, JSScript *script)
|
||||
JS_RUNTIME_UNMETER(cx->runtime, liveScripts);
|
||||
#endif
|
||||
|
||||
js_CallDestroyScriptHook(cx, script);
|
||||
JS_ClearScriptTraps(cx, script);
|
||||
|
||||
if (script->principals)
|
||||
JSPRINCIPALS_DROP(cx, script->principals);
|
||||
|
||||
@ -1644,7 +1646,6 @@ void
|
||||
js_DestroyScript(JSContext *cx, JSScript *script)
|
||||
{
|
||||
JS_ASSERT(!cx->runtime->gcRunning);
|
||||
js_CallDestroyScriptHook(cx, script);
|
||||
DestroyScript(cx, script);
|
||||
}
|
||||
|
||||
|
@ -649,7 +649,7 @@ js_SweepScriptFilenames(JSRuntime *rt);
|
||||
extern JS_FRIEND_API(void)
|
||||
js_CallNewScriptHook(JSContext *cx, JSScript *script, JSFunction *fun);
|
||||
|
||||
extern void
|
||||
extern JS_FRIEND_API(void)
|
||||
js_CallDestroyScriptHook(JSContext *cx, JSScript *script);
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user