diff --git a/js/jsd/jsd.h b/js/jsd/jsd.h index 28101976bb9d..e98279ea908f 100644 --- a/js/jsd/jsd.h +++ b/js/jsd/jsd.h @@ -389,6 +389,12 @@ extern JSDScript* jsd_FindJSDScript(JSDContext* jsdc, JSScript *script); +extern JSDScript* +jsd_FindOrCreateJSDScript(JSDContext *jsdc, + JSContext *cx, + JSScript *script, + JSStackFrame *fp); + extern JSDProfileData* jsd_GetScriptProfileData(JSDContext* jsdc, JSDScript *script); diff --git a/js/jsd/jsd_hook.c b/js/jsd/jsd_hook.c index 5ee6c9d56066..45c6be8e5979 100644 --- a/js/jsd/jsd_hook.c +++ b/js/jsd/jsd_hook.c @@ -66,7 +66,7 @@ jsd_InterruptHandler(JSContext *cx, JSScript *script, jsbytecode *pc, jsval *rva return JSTRAP_CONTINUE; JSD_LOCK_SCRIPTS(jsdc); - jsdscript = jsd_FindJSDScript(jsdc, script); + jsdscript = jsd_FindOrCreateJSDScript(jsdc, cx, script, NULL); JSD_UNLOCK_SCRIPTS(jsdc); if( ! jsdscript ) return JSTRAP_CONTINUE; @@ -104,7 +104,7 @@ jsd_DebuggerHandler(JSContext *cx, JSScript *script, jsbytecode *pc, return JSTRAP_CONTINUE; JSD_LOCK_SCRIPTS(jsdc); - jsdscript = jsd_FindJSDScript(jsdc, script); + jsdscript = jsd_FindOrCreateJSDScript(jsdc, cx, script, NULL); JSD_UNLOCK_SCRIPTS(jsdc); if( ! jsdscript ) return JSTRAP_CONTINUE; @@ -138,7 +138,7 @@ jsd_ThrowHandler(JSContext *cx, JSScript *script, jsbytecode *pc, return JSD_HOOK_RETURN_CONTINUE_THROW; JSD_LOCK_SCRIPTS(jsdc); - jsdscript = jsd_FindJSDScript(jsdc, script); + jsdscript = jsd_FindOrCreateJSDScript(jsdc, cx, script, NULL); JSD_UNLOCK_SCRIPTS(jsdc); if( ! jsdscript ) return JSD_HOOK_RETURN_CONTINUE_THROW; diff --git a/js/jsd/jsd_obj.c b/js/jsd/jsd_obj.c index 89283c7468f1..c5eee186703a 100644 --- a/js/jsd/jsd_obj.c +++ b/js/jsd/jsd_obj.c @@ -205,7 +205,7 @@ jsd_Constructing(JSDContext* jsdc, JSContext *cx, JSObject *obj, jsdobj->ctorURL = jsd_AddAtom(jsdc, ctorURL); JSD_LOCK_SCRIPTS(jsdc); - jsdscript = jsd_FindJSDScript(jsdc, script); + jsdscript = jsd_FindOrCreateJSDScript(jsdc, cx, script, fp); JSD_UNLOCK_SCRIPTS(jsdc); if( jsdscript ) { diff --git a/js/jsd/jsd_scpt.c b/js/jsd/jsd_scpt.c index 1baf98dbaf09..581c0efdcce2 100644 --- a/js/jsd/jsd_scpt.c +++ b/js/jsd/jsd_scpt.c @@ -284,7 +284,29 @@ jsd_FindJSDScript( JSDContext* jsdc, { JS_ASSERT(JSD_SCRIPTS_LOCKED(jsdc)); return (JSDScript*) JS_HashTableLookup(jsdc->scriptsTable, (void *)script); -} +} + +JSDScript * +jsd_FindOrCreateJSDScript(JSDContext *jsdc, + JSContext *cx, + JSScript *script, + JSStackFrame *fp) +{ + JSDScript *jsdscript; + JS_ASSERT(JSD_SCRIPTS_LOCKED(jsdc)); + + jsdscript = jsd_FindJSDScript(jsdc, script); + if (jsdscript) + return jsdscript; + + // Fallback for unknown scripts: create a new script + if (!fp) + JS_FrameIterator(cx, &fp); + if (fp) + jsdscript = _newJSDScript(jsdc, cx, script, JS_GetFrameFunction(cx, fp)); + + return jsdscript; +} JSDProfileData* jsd_GetScriptProfileData(JSDContext* jsdc, JSDScript *script) diff --git a/js/jsd/jsd_step.c b/js/jsd/jsd_step.c index 2904ffbb01bc..88a1bce3942c 100644 --- a/js/jsd/jsd_step.c +++ b/js/jsd/jsd_step.c @@ -76,7 +76,7 @@ _interpreterTrace(JSDContext* jsdc, JSContext *cx, JSStackFrame *fp, if(script) { JSD_LOCK_SCRIPTS(jsdc); - jsdscript = jsd_FindJSDScript(jsdc, script); + jsdscript = jsd_FindOrCreateJSDScript(jsdc, cx, script, fp); JSD_UNLOCK_SCRIPTS(jsdc); if(jsdscript) funName = JSD_GetScriptFunctionName(jsdc, jsdscript); @@ -136,7 +136,7 @@ _callHook(JSDContext *jsdc, JSContext *cx, JSStackFrame *fp, JSBool before, if (jsscript) { JSD_LOCK_SCRIPTS(jsdc); - jsdscript = jsd_FindJSDScript(jsdc, jsscript); + jsdscript = jsd_FindOrCreateJSDScript(jsdc, cx, jsscript, fp); JSD_UNLOCK_SCRIPTS(jsdc); if (jsdscript)