From 8f4d8cb810188c1f88c43636e02ebed220d633b7 Mon Sep 17 00:00:00 2001 From: "rginda%netscape.com" Date: Thu, 14 Aug 2003 22:49:09 +0000 Subject: [PATCH] bug 216112, "add ability to disable object tracking in jsd" r=caillon, sr=brendan, a=asa adds the ability to turn off the object tracking without having to disable the debugger. should make a dormant venkman less of a performance impact. --- js/jsd/idl/jsdIDebuggerService.idl | 5 +++++ js/jsd/jsd_obj.c | 7 +++++-- js/jsd/jsd_step.c | 10 ++++++++++ js/jsd/jsd_xpc.cpp | 14 +++++++------- js/jsd/jsdebug.h | 5 +++++ 5 files changed, 32 insertions(+), 9 deletions(-) diff --git a/js/jsd/idl/jsdIDebuggerService.idl b/js/jsd/idl/jsdIDebuggerService.idl index 81c2a78e3d2b..f4d68554ca88 100644 --- a/js/jsd/idl/jsdIDebuggerService.idl +++ b/js/jsd/idl/jsdIDebuggerService.idl @@ -182,6 +182,11 @@ interface jsdIDebuggerService : nsISupports * If HIDE_DISABLED_FRAMES is set, this is effectively set as well. */ const unsigned long MASK_TOP_FRAME_ONLY = 0x20; + /** + * When this flag is set, object creation will not be tracked. This will + * reduce the performance price you pay by enabling the debugger. + */ + const unsigned long DISABLE_OBJECT_TRACE = 0x40; /** * Debugger service flags. diff --git a/js/jsd/jsd_obj.c b/js/jsd/jsd_obj.c index c2c6e1cafeaa..4b7b2f2cc81c 100644 --- a/js/jsd/jsd_obj.c +++ b/js/jsd/jsd_obj.c @@ -122,15 +122,18 @@ _createJSDObject(JSDContext* jsdc, JSContext *cx, JSObject *obj) JS_ASSERT(JSD_OBJECTS_LOCKED(jsdc)); jsdobj = (JSDObject*) calloc(1, sizeof(JSDObject)); - if( jsdobj ) + if (jsdobj) { JS_INIT_CLIST(&jsdobj->links); JS_APPEND_LINK(&jsdobj->links, &jsdc->objectsList); jsdobj->obj = obj; JS_HashTableAdd(jsdc->objectsTable, obj, jsdobj); + if (jsdc->flags & JSD_DISABLE_OBJECT_TRACE) + return jsdobj; + /* walk the stack to find js frame (if any) causing creation */ - while( NULL != (fp = JS_FrameIterator(cx, &iter)) ) + while (NULL != (fp = JS_FrameIterator(cx, &iter))) { if( !JS_IsNativeFrame(cx, fp) ) { diff --git a/js/jsd/jsd_step.c b/js/jsd/jsd_step.c index dd9061de1dbb..74bd1c483c53 100644 --- a/js/jsd/jsd_step.c +++ b/js/jsd/jsd_step.c @@ -118,6 +118,16 @@ _callHook(JSDContext *jsdc, JSContext *cx, JSStackFrame *fp, JSBool before, if (!jsdc || !jsdc->inited) return JS_FALSE; + + if (!hook && !(jsdc->flags & JSD_COLLECT_PROFILE_DATA) && + jsdc->flags & JSD_DISABLE_OBJECT_TRACE) + { + /* no hook to call, no profile data needs to be collected, and + * the client has object tracing disabled, so there is nothing + * to do here. + */ + return hookresult; + } if (before && JS_IsConstructorFrame(cx, fp)) jsd_Constructing(jsdc, cx, JS_GetFrameThis(cx, fp), fp); diff --git a/js/jsd/jsd_xpc.cpp b/js/jsd/jsd_xpc.cpp index 73c23316c17f..af569522f0e4 100644 --- a/js/jsd/jsd_xpc.cpp +++ b/js/jsd/jsd_xpc.cpp @@ -96,7 +96,7 @@ } #define JSDS_MAJOR_VERSION 1 -#define JSDS_MINOR_VERSION 1 +#define JSDS_MINOR_VERSION 2 #define NS_CATMAN_CTRID "@mozilla.org/categorymanager;1" #define NS_JSRT_CTRID "@mozilla.org/js/xpc/RuntimeService;1" @@ -3235,9 +3235,7 @@ class jsdASObserver : public nsIObserver NS_DECL_ISUPPORTS NS_DECL_NSIOBSERVER - jsdASObserver () - { - } + jsdASObserver () {} }; NS_IMPL_THREADSAFE_ISUPPORTS1(jsdASObserver, nsIObserver); @@ -3267,15 +3265,17 @@ jsdASObserver::Observe (nsISupports *aSubject, const char *aTopic, return rv; rv = jsds->OnForRuntime(rt); + if (NS_FAILED(rv)) + return rv; - return rv; + return jsds->SetFlags(JSD_DISABLE_OBJECT_TRACE); } NS_GENERIC_FACTORY_CONSTRUCTOR(jsdASObserver); static const nsModuleComponentInfo components[] = { - {"JSDService", JSDSERVICE_CID, jsdServiceCtrID, jsdServiceConstructor}, - {"JSDASObserver", JSDASO_CID, jsdASObserverCtrID, jsdASObserverConstructor} + {"JSDService", JSDSERVICE_CID, jsdServiceCtrID, jsdServiceConstructor}, + {"JSDASObserver", JSDASO_CID, jsdASObserverCtrID, jsdASObserverConstructor} }; NS_IMPL_NSGETMODULE(JavaScript_Debugger, components); diff --git a/js/jsd/jsdebug.h b/js/jsd/jsdebug.h index bdc5e7000c0e..fd0385091a3e 100644 --- a/js/jsd/jsdebug.h +++ b/js/jsd/jsdebug.h @@ -230,6 +230,11 @@ JSD_ClearAllProfileData(JSDContext* jsdc); * If JSD_HIDE_DISABLED_FRAMES is set, this is effectively set as well. */ #define JSD_MASK_TOP_FRAME_ONLY 0x20 +/* +* When this flag is set, object creation will not be tracked. This will +* reduce the performance price you pay by enabling the debugger. +*/ +#define JSD_DISABLE_OBJECT_TRACE 0x40 extern JSD_PUBLIC_API(void) JSD_SetContextFlags (JSDContext* jsdc, uint32 flags);