Backout 1b55728f51ad (bug 633016) due to leaking jsdScript objects

This commit is contained in:
Steve Fink 2011-02-10 14:33:10 -08:00
parent a2f27a580c
commit 163812a8da
3 changed files with 6 additions and 22 deletions

View File

@ -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

View File

@ -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);
}

View File

@ -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);
/*