Don't try to correlate scripts with functions in JSD interface, bug 707613. r=luke
authorBrian Hackett <bhackett1024@gmail.com>
Wed, 07 Dec 2011 13:41:27 -0800
changeset 83850 331e25310bf790a5b5262c0aa59247c2ad1aa448
parent 83849 e5b56fcb36af789064d478e728df90d46a498dd8
child 83851 d1466b26c89182580134e4aa854bfdbc336e634e
push id519
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 00:38:35 +0000
treeherdermozilla-beta@788ea1ef610b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersluke
bugs707613
milestone11.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Don't try to correlate scripts with functions in JSD interface, bug 707613. r=luke
js/jsd/jsd.h
js/jsd/jsd_scpt.c
js/src/jsdbgapi.cpp
js/src/jsdbgapi.h
--- a/js/jsd/jsd.h
+++ b/js/jsd/jsd.h
@@ -182,17 +182,16 @@ struct JSDContext
 
 };
 
 struct JSDScript
 {
     JSCList     links;      /* we are part of a JSCList */
     JSDContext* jsdc;       /* JSDContext for this jsdscript */
     JSScript*   script;     /* script we are wrapping */
-    JSFunction* function;   /* back pointer to owning function (can be NULL) */
     uintN       lineBase;   /* we cache this */
     uintN       lineExtent; /* we cache this */
     JSCList     hooks;      /* JSCList of JSDExecHooks for this script */
     char*       url;
     uint32      flags;
     void*       data;
 
     JSDProfileData  *profileData;
--- a/js/jsd/jsd_scpt.c
+++ b/js/jsd/jsd_scpt.c
@@ -86,18 +86,17 @@ HasFileExtention(const char* name, const
         return JS_FALSE;
     return JS_TRUE;
 }    
 #endif /* LIVEWIRE */
 
 static JSDScript*
 _newJSDScript(JSDContext*  jsdc,
               JSContext    *cx,
-              JSScript     *script,
-              JSFunction*  function)
+              JSScript     *script)
 {
     JSDScript*  jsdscript;
     uintN     lineno;
     const char* raw_filename;
 
     JS_ASSERT(JSD_SCRIPTS_LOCKED(jsdc));
 
     /* these are inlined javascript: urls and we can't handle them now */
@@ -109,18 +108,17 @@ static JSDScript*
     if( ! jsdscript )
         return NULL;
 
     raw_filename = JS_GetScriptFilename(cx,script);
 
     JS_HashTableAdd(jsdc->scriptsTable, (void *)script, (void *)jsdscript);
     JS_APPEND_LINK(&jsdscript->links, &jsdc->scripts);
     jsdscript->jsdc         = jsdc;
-    jsdscript->script       = script;        
-    jsdscript->function     = function;
+    jsdscript->script       = script;  
     jsdscript->lineBase     = lineno;
     jsdscript->lineExtent   = (uintN)NOT_SET_YET;
     jsdscript->data         = NULL;
 #ifndef LIVEWIRE
     jsdscript->url          = (char*) jsd_BuildNormalizedURL(raw_filename);
 #else
     jsdscript->app = LWDBG_GetCurrentApp();    
     if( jsdscript->app && raw_filename )
@@ -320,17 +318,17 @@ jsd_FindOrCreateJSDScript(JSDContext    
     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));
+        jsdscript = _newJSDScript(jsdc, cx, script);
 
     return jsdscript;
 }
 
 JSDProfileData*
 jsd_GetScriptProfileData(JSDContext* jsdc, JSDScript *script)
 {
     if (!script->profileData)
@@ -437,17 +435,17 @@ JSScript *
 jsd_GetJSScript (JSDContext *jsdc, JSDScript *script)
 {
     return script->script;
 }
 
 JSFunction *
 jsd_GetJSFunction (JSDContext *jsdc, JSDScript *script)
 {
-    return script->function;
+    return JS_GetScriptFunction(jsdc->dumbContext, script->script);
 }
 
 JSDScript*
 jsd_IterateScripts(JSDContext* jsdc, JSDScript **iterp)
 {
     JSDScript *jsdscript = *iterp;
     
     JS_ASSERT(JSD_SCRIPTS_LOCKED(jsdc));
@@ -496,20 +494,21 @@ jsd_GetScriptFilename(JSDContext* jsdc, 
 {
     return jsdscript->url;
 }
 
 JSString*
 jsd_GetScriptFunctionId(JSDContext* jsdc, JSDScript *jsdscript)
 {
     JSString* str;
+    JSFunction *fun = jsd_GetJSFunction(jsdc, jsdscript);
 
-    if( ! jsdscript->function )
+    if( ! fun )
         return NULL;
-    str = JS_GetFunctionId(jsdscript->function);
+    str = JS_GetFunctionId(fun);
 
     /* For compatibility we return "anonymous", not an empty string here. */
     return str ? str : JS_GetAnonymousString(jsdc->jsrt);
 }
 
 uintN
 jsd_GetScriptBaseLineNumber(JSDContext* jsdc, JSDScript *jsdscript)
 {
@@ -675,17 +674,17 @@ jsd_NewScriptHookProc(
     void*                   hookData;
     
     JSD_ASSERT_VALID_CONTEXT(jsdc);
 
     if( JSD_IS_DANGEROUS_THREAD(jsdc) )
         return;
     
     JSD_LOCK_SCRIPTS(jsdc);
-    jsdscript = _newJSDScript(jsdc, cx, script, fun);
+    jsdscript = _newJSDScript(jsdc, cx, script);
     JSD_UNLOCK_SCRIPTS(jsdc);
     if( ! jsdscript )
         return;
 
 #ifdef JSD_DUMP
     JSD_LOCK_SCRIPTS(jsdc);
     _dumpJSDScript(jsdc, jsdscript, "***NEW Script: ");
     _dumpJSDScriptList( jsdc );
--- a/js/src/jsdbgapi.cpp
+++ b/js/src/jsdbgapi.cpp
@@ -627,16 +627,22 @@ JS_GetFrameFunctionObject(JSContext *cx,
     StackFrame *fp = Valueify(fpArg);
     if (!fp->isFunctionFrame())
         return NULL;
 
     JS_ASSERT(fp->callee().isFunction());
     return &fp->callee();
 }
 
+JS_PUBLIC_API(JSFunction *)
+JS_GetScriptFunction(JSContext *cx, JSScript *script)
+{
+    return script->function();
+}
+
 JS_PUBLIC_API(JSObject *)
 JS_GetParentOrScopeChain(JSContext *cx, JSObject *obj)
 {
     return obj->scopeChain();
 }
 
 JS_PUBLIC_API(JSBool)
 JS_IsConstructorFrame(JSContext *cx, JSStackFrame *fp)
--- a/js/src/jsdbgapi.h
+++ b/js/src/jsdbgapi.h
@@ -271,16 +271,19 @@ extern JS_PUBLIC_API(JSBool)
 JS_GetFrameThis(JSContext *cx, JSStackFrame *fp, jsval *thisv);
 
 extern JS_PUBLIC_API(JSFunction *)
 JS_GetFrameFunction(JSContext *cx, JSStackFrame *fp);
 
 extern JS_PUBLIC_API(JSObject *)
 JS_GetFrameFunctionObject(JSContext *cx, JSStackFrame *fp);
 
+JS_PUBLIC_API(JSFunction *)
+JS_GetScriptFunction(JSContext *cx, JSScript *script);
+
 extern JS_PUBLIC_API(JSObject *)
 JS_GetParentOrScopeChain(JSContext *cx, JSObject *obj);
 
 /* XXXrginda Initially published with typo */
 #define JS_IsContructorFrame JS_IsConstructorFrame
 extern JS_PUBLIC_API(JSBool)
 JS_IsConstructorFrame(JSContext *cx, JSStackFrame *fp);