зеркало из https://github.com/mozilla/gecko-dev.git
Bug 578159: remove object allocation debug hook. (r=gal, sr=brendan)
This commit is contained in:
Родитель
0d6cf59819
Коммит
b5a53dd7fa
|
@ -186,11 +186,11 @@ interface jsdIDebuggerService : nsISupports
|
|||
*/
|
||||
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.
|
||||
* This flag has been retired, do not re-use. It previously provided a hook
|
||||
* for object allocation.
|
||||
*/
|
||||
const unsigned long DISABLE_OBJECT_TRACE = 0x40;
|
||||
|
||||
const unsigned long DISABLE_OBJECT_TRACE_RETIRED = 0x40;
|
||||
|
||||
/**
|
||||
* Debugger service flags.
|
||||
*/
|
||||
|
|
|
@ -1044,9 +1044,6 @@ jsd_DestroyObjectManager(JSDContext* jsdc);
|
|||
extern void
|
||||
jsd_DestroyObjects(JSDContext* jsdc);
|
||||
|
||||
extern void
|
||||
jsd_ObjectHook(JSContext *cx, JSObject *obj, JSBool isNew, void *closure);
|
||||
|
||||
extern void
|
||||
jsd_Constructing(JSDContext* jsdc, JSContext *cx, JSObject *obj,
|
||||
JSStackFrame *fp);
|
||||
|
|
|
@ -213,9 +213,6 @@ jsd_DebuggerOnForUser(JSRuntime* jsrt,
|
|||
JS_SetNewScriptHookProc(jsdc->jsrt, jsd_NewScriptHookProc, jsdc);
|
||||
JS_SetDestroyScriptHookProc(jsdc->jsrt, jsd_DestroyScriptHookProc, jsdc);
|
||||
jsd_DebuggerUnpause(jsdc);
|
||||
if (!(jsdc->flags & JSD_DISABLE_OBJECT_TRACE)) {
|
||||
JS_SetObjectHook(jsdc->jsrt, jsd_ObjectHook, jsdc);
|
||||
}
|
||||
#ifdef LIVEWIRE
|
||||
LWDBG_SetNewScriptHookProc(jsd_NewScriptHookProc, jsdc);
|
||||
#endif
|
||||
|
@ -239,9 +236,6 @@ jsd_DebuggerOff(JSDContext* jsdc)
|
|||
/* clear hooks here */
|
||||
JS_SetNewScriptHookProc(jsdc->jsrt, NULL, NULL);
|
||||
JS_SetDestroyScriptHookProc(jsdc->jsrt, NULL, NULL);
|
||||
/* Have to unset these too, since jsd_DebuggerPause only unsets
|
||||
them conditionally */
|
||||
JS_SetObjectHook(jsdc->jsrt, NULL, NULL);
|
||||
#ifdef LIVEWIRE
|
||||
LWDBG_SetNewScriptHookProc(NULL,NULL);
|
||||
#endif
|
||||
|
@ -262,9 +256,7 @@ void
|
|||
jsd_DebuggerPause(JSDContext* jsdc, JSBool forceAllHooksOff)
|
||||
{
|
||||
JS_SetDebuggerHandler(jsdc->jsrt, NULL, NULL);
|
||||
if (forceAllHooksOff ||
|
||||
(!(jsdc->flags & JSD_COLLECT_PROFILE_DATA) &&
|
||||
(jsdc->flags & JSD_DISABLE_OBJECT_TRACE))) {
|
||||
if (forceAllHooksOff || !(jsdc->flags & JSD_COLLECT_PROFILE_DATA)) {
|
||||
JS_SetExecuteHook(jsdc->jsrt, NULL, NULL);
|
||||
JS_SetCallHook(jsdc->jsrt, NULL, NULL);
|
||||
}
|
||||
|
|
|
@ -128,61 +128,10 @@ _createJSDObject(JSDContext* jsdc, JSContext *cx, JSObject *obj)
|
|||
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)))
|
||||
{
|
||||
if( !JS_IsNativeFrame(cx, fp) )
|
||||
{
|
||||
JSScript* script = JS_GetFrameScript(cx, fp);
|
||||
if( !script )
|
||||
continue;
|
||||
|
||||
newURL = JS_GetScriptFilename(cx, script);
|
||||
if( newURL )
|
||||
jsdobj->newURL = jsd_AddAtom(jsdc, newURL);
|
||||
|
||||
pc = JS_GetFramePC(cx, fp);
|
||||
if( pc )
|
||||
jsdobj->newLineno = JS_PCToLineNumber(cx, script, pc);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return jsdobj;
|
||||
}
|
||||
|
||||
void
|
||||
jsd_ObjectHook(JSContext *cx, JSObject *obj, JSBool isNew, void *closure)
|
||||
{
|
||||
JSDObject* jsdobj;
|
||||
JSDContext* jsdc = (JSDContext*) closure;
|
||||
|
||||
if( ! jsdc || ! jsdc->inited )
|
||||
return;
|
||||
|
||||
JSD_LOCK_OBJECTS(jsdc);
|
||||
if(isNew)
|
||||
{
|
||||
jsdobj = _createJSDObject(jsdc, cx, obj);
|
||||
TRACEOBJ(jsdc, jsdobj, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
jsdobj = jsd_GetJSDObjectForJSObject(jsdc, obj);
|
||||
if( jsdobj )
|
||||
{
|
||||
TRACEOBJ(jsdc, jsdobj, 1);
|
||||
_destroyJSDObject(jsdc, jsdobj);
|
||||
}
|
||||
}
|
||||
JSD_UNLOCK_OBJECTS(jsdc);
|
||||
}
|
||||
|
||||
void
|
||||
jsd_Constructing(JSDContext* jsdc, JSContext *cx, JSObject *obj,
|
||||
JSStackFrame *fp)
|
||||
|
|
|
@ -119,12 +119,10 @@ _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)
|
||||
if (!hook && !(jsdc->flags & JSD_COLLECT_PROFILE_DATA))
|
||||
{
|
||||
/* 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.
|
||||
/* no hook to call, no profile data needs to be collected,
|
||||
* so there is nothing to do here.
|
||||
*/
|
||||
return hookresult;
|
||||
}
|
||||
|
|
|
@ -3280,7 +3280,7 @@ jsdASObserver::Observe (nsISupports *aSubject, const char *aTopic,
|
|||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
return jsds->SetFlags(JSD_DISABLE_OBJECT_TRACE);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(jsdASObserver)
|
||||
|
|
|
@ -138,22 +138,11 @@ JSD_SetContextFlags(JSDContext *jsdc, uint32 flags)
|
|||
uint32 oldFlags = jsdc->flags;
|
||||
JSD_ASSERT_VALID_CONTEXT(jsdc);
|
||||
jsdc->flags = flags;
|
||||
if ((flags & JSD_COLLECT_PROFILE_DATA) ||
|
||||
!(flags & JSD_DISABLE_OBJECT_TRACE)) {
|
||||
if (flags & JSD_COLLECT_PROFILE_DATA) {
|
||||
/* Need to reenable our call hooks now */
|
||||
JS_SetExecuteHook(jsdc->jsrt, jsd_TopLevelCallHook, jsdc);
|
||||
JS_SetCallHook(jsdc->jsrt, jsd_FunctionCallHook, jsdc);
|
||||
}
|
||||
if ((oldFlags ^ flags) & JSD_DISABLE_OBJECT_TRACE) {
|
||||
/* Changing our JSD_DISABLE_OBJECT_TRACE flag */
|
||||
if (!(flags & JSD_DISABLE_OBJECT_TRACE)) {
|
||||
/* Need to reenable our object hooks now */
|
||||
JS_SetObjectHook(jsdc->jsrt, jsd_ObjectHook, jsdc);
|
||||
} else {
|
||||
jsd_DestroyObjects(jsdc);
|
||||
JS_SetObjectHook(jsdc->jsrt, NULL, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
JSD_PUBLIC_API(uint32)
|
||||
|
|
|
@ -240,11 +240,12 @@ 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.
|
||||
* 0x40 was formerly used to hook into object creation.
|
||||
*/
|
||||
#define JSD_DISABLE_OBJECT_TRACE 0x40
|
||||
#define JSD_DISABLE_OBJECT_TRACE_RETIRED 0x40
|
||||
|
||||
|
||||
extern JSD_PUBLIC_API(void)
|
||||
JSD_SetContextFlags (JSDContext* jsdc, uint32 flags);
|
||||
|
|
|
@ -1331,8 +1331,7 @@ struct JSRuntime {
|
|||
/* True if any debug hooks not supported by the JIT are enabled. */
|
||||
bool debuggerInhibitsJIT() const {
|
||||
return (globalDebugHooks.interruptHook ||
|
||||
globalDebugHooks.callHook ||
|
||||
globalDebugHooks.objectHook);
|
||||
globalDebugHooks.callHook);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1692,25 +1692,6 @@ JS_SetCallHook(JSRuntime *rt, JSInterpreterHook hook, void *closure)
|
|||
return JS_TRUE;
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(JSBool)
|
||||
JS_SetObjectHook(JSRuntime *rt, JSObjectHook hook, void *closure)
|
||||
{
|
||||
#ifdef JS_TRACER
|
||||
{
|
||||
AutoLockGC lock(rt);
|
||||
bool wasInhibited = rt->debuggerInhibitsJIT();
|
||||
#endif
|
||||
rt->globalDebugHooks.objectHook = hook;
|
||||
rt->globalDebugHooks.objectHookData = closure;
|
||||
#ifdef JS_TRACER
|
||||
JITInhibitingHookChange(rt, wasInhibited);
|
||||
}
|
||||
if (hook)
|
||||
LeaveTraceRT(rt);
|
||||
#endif
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(JSBool)
|
||||
JS_SetThrowHook(JSRuntime *rt, JSThrowHook hook, void *closure)
|
||||
{
|
||||
|
|
|
@ -390,9 +390,6 @@ JS_SetExecuteHook(JSRuntime *rt, JSInterpreterHook hook, void *closure);
|
|||
extern JS_PUBLIC_API(JSBool)
|
||||
JS_SetCallHook(JSRuntime *rt, JSInterpreterHook hook, void *closure);
|
||||
|
||||
extern JS_PUBLIC_API(JSBool)
|
||||
JS_SetObjectHook(JSRuntime *rt, JSObjectHook hook, void *closure);
|
||||
|
||||
extern JS_PUBLIC_API(JSBool)
|
||||
JS_SetThrowHook(JSRuntime *rt, JSThrowHook hook, void *closure);
|
||||
|
||||
|
|
|
@ -2514,25 +2514,6 @@ FinalizeFunction(JSContext *cx, JSFunction *fun, unsigned thingKind)
|
|||
FinalizeObject(cx, FUN_OBJECT(fun), thingKind);
|
||||
}
|
||||
|
||||
inline void
|
||||
FinalizeHookedObject(JSContext *cx, JSObject *obj, unsigned thingKind)
|
||||
{
|
||||
if (!obj->map)
|
||||
return;
|
||||
|
||||
if (cx->debugHooks->objectHook) {
|
||||
cx->debugHooks->objectHook(cx, obj, JS_FALSE,
|
||||
cx->debugHooks->objectHookData);
|
||||
}
|
||||
FinalizeObject(cx, obj, thingKind);
|
||||
}
|
||||
|
||||
inline void
|
||||
FinalizeHookedFunction(JSContext *cx, JSFunction *fun, unsigned thingKind)
|
||||
{
|
||||
FinalizeHookedObject(cx, FUN_OBJECT(fun), thingKind);
|
||||
}
|
||||
|
||||
#if JS_HAS_XML_SUPPORT
|
||||
inline void
|
||||
FinalizeXML(JSContext *cx, JSXML *xml, unsigned thingKind)
|
||||
|
@ -3031,19 +3012,10 @@ GC(JSContext *cx GCTIMER_PARAM)
|
|||
* state. We finalize objects before string, double and other GC things
|
||||
* things to ensure that object's finalizer can access them even if they
|
||||
* will be freed.
|
||||
*
|
||||
* To minimize the number of checks per each to be freed object and
|
||||
* function we use separated list finalizers when a debug hook is
|
||||
* installed.
|
||||
*/
|
||||
JS_ASSERT(!rt->gcEmptyArenaList);
|
||||
if (!cx->debugHooks->objectHook) {
|
||||
FinalizeArenaList<JSObject, FinalizeObject>(cx, FINALIZE_OBJECT);
|
||||
FinalizeArenaList<JSFunction, FinalizeFunction>(cx, FINALIZE_FUNCTION);
|
||||
} else {
|
||||
FinalizeArenaList<JSObject, FinalizeHookedObject>(cx, FINALIZE_OBJECT);
|
||||
FinalizeArenaList<JSFunction, FinalizeHookedFunction>(cx, FINALIZE_FUNCTION);
|
||||
}
|
||||
FinalizeArenaList<JSObject, FinalizeObject>(cx, FINALIZE_OBJECT);
|
||||
FinalizeArenaList<JSFunction, FinalizeFunction>(cx, FINALIZE_FUNCTION);
|
||||
#if JS_HAS_XML_SUPPORT
|
||||
FinalizeArenaList<JSXML, FinalizeXML>(cx, FINALIZE_XML);
|
||||
#endif
|
||||
|
|
|
@ -559,18 +559,6 @@ NewNativeClassInstance(JSContext *cx, Class *clasp, JSObject *proto, JSObject *p
|
|||
obj = NULL;
|
||||
} else {
|
||||
obj->map = scope;
|
||||
|
||||
/*
|
||||
* Do not call debug hooks on trace, because we might be in a non-_FAIL
|
||||
* builtin. See bug 481444.
|
||||
*/
|
||||
if (cx->debugHooks->objectHook && !JS_ON_TRACE(cx)) {
|
||||
AutoObjectRooter tvr(cx, obj);
|
||||
AutoKeepAtoms keep(cx->runtime);
|
||||
cx->debugHooks->objectHook(cx, obj, JS_TRUE,
|
||||
cx->debugHooks->objectHookData);
|
||||
cx->weakRoots.finalizableNewborns[FINALIZE_OBJECT] = obj;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -675,18 +663,6 @@ NewObjectWithGivenProto(JSContext *cx, Class *clasp, JSObject *proto, JSObject *
|
|||
obj->map = const_cast<JSObjectMap *>(ops->objectMap);
|
||||
}
|
||||
|
||||
/*
|
||||
* Do not call debug hooks on trace, because we might be in a non-_FAIL
|
||||
* builtin. See bug 481444.
|
||||
*/
|
||||
if (cx->debugHooks->objectHook && !JS_ON_TRACE(cx)) {
|
||||
AutoObjectRooter tvr(cx, obj);
|
||||
AutoKeepAtoms keep(cx->runtime);
|
||||
cx->debugHooks->objectHook(cx, obj, JS_TRUE,
|
||||
cx->debugHooks->objectHookData);
|
||||
cx->weakRoots.finalizableNewborns[FINALIZE_OBJECT] = obj;
|
||||
}
|
||||
|
||||
out:
|
||||
objectCreationScope.handleCreation(obj);
|
||||
return obj;
|
||||
|
|
|
@ -263,9 +263,6 @@ typedef void *
|
|||
(* JSInterpreterHook)(JSContext *cx, JSStackFrame *fp, JSBool before,
|
||||
JSBool *ok, void *closure);
|
||||
|
||||
typedef void
|
||||
(* JSObjectHook)(JSContext *cx, JSObject *obj, JSBool isNew, void *closure);
|
||||
|
||||
typedef JSBool
|
||||
(* JSDebugErrorHook)(JSContext *cx, const char *message, JSErrorReport *report,
|
||||
void *closure);
|
||||
|
@ -285,8 +282,6 @@ typedef struct JSDebugHooks {
|
|||
void *executeHookData;
|
||||
JSInterpreterHook callHook;
|
||||
void *callHookData;
|
||||
JSObjectHook objectHook;
|
||||
void *objectHookData;
|
||||
JSThrowHook throwHook;
|
||||
void *throwHookData;
|
||||
JSDebugErrorHook debugErrorHook;
|
||||
|
|
Загрузка…
Ссылка в новой задаче