Back to index

lightning-sunbird  0.9+nobinonly
Classes | Functions
nsXPCToolsProfiler.cpp File Reference
#include "xpctools_private.h"

Go to the source code of this file.

Classes

class  FunctionKey

Functions

 xpctools_ProfilerFunctionDeleter (nsHashKey *aKey, void *aData, void *closure)
 xpctools_ProfilerFileDeleter (nsHashKey *aKey, void *aData, void *closure)
 xpctools_JSNewScriptHook (JSContext *cx, const char *filename, uintN lineno, JSScript *script, JSFunction *fun, void *callerdata)
 xpctools_JSDestroyScriptHook (JSContext *cx, JSScript *script, void *callerdata)
 xpctools_InterpreterHook (JSContext *cx, JSStackFrame *fp, JSBool before, JSBool *ok, void *closure)
 xpctools_FunctionNamePrinter (nsHashKey *aKey, void *aData, void *closure)
 xpctools_FilenamePrinter (nsHashKey *aKey, void *aData, void *closure)

Function Documentation

xpctools_FilenamePrinter ( nsHashKey *  aKey,
void aData,
void closure 
)

Definition at line 362 of file nsXPCToolsProfiler.cpp.

Here is the call graph for this function:

xpctools_FunctionNamePrinter ( nsHashKey *  aKey,
void aData,
void closure 
)

Definition at line 329 of file nsXPCToolsProfiler.cpp.

{
    ProfilerFunction* fun = (ProfilerFunction*) aData;
    FILE* out = (FILE*) closure;
    const char* name = fun->GetName();
    PRUint32 average;
    PRUint32 count;

    count = fun->GetCallCount();
    if (count != 0)
        average = fun->GetSum() / count;
    if(!name)
        name = "<top level>"; 
    fprintf(out,
        "    [%lu,%lu] %s() {%d-%d} %lu ",
        (unsigned long) fun->GetCompileCount(),
        (unsigned long) fun->GetCallCount(),
        name,
        (int) fun->GetBaseLineNumber(),
        (int)(fun->GetBaseLineNumber()+fun->GetLineExtent()-1),
        (unsigned long) fun->GetTotalSize());
    if(count != 0)
        fprintf(out,
            "{min %lu, max %lu avg %lu}\n",
            (unsigned long) fun->GetQuickTime(),
            (unsigned long) fun->GetLongTime(),
            (unsigned long) average);
    else
        fprintf(out, "\n" );
    return PR_TRUE;        
}        

Here is the call graph for this function:

Here is the caller graph for this function:

xpctools_InterpreterHook ( JSContext cx,
JSStackFrame fp,
JSBool  before,
JSBool ok,
void closure 
)

Definition at line 254 of file nsXPCToolsProfiler.cpp.

{
    // ignore returns
    NS_ASSERTION(fp, "bad frame pointer!");

    JSScript* script = fp->script;
    if(script)
    {
        nsXPCToolsProfiler* self = (nsXPCToolsProfiler*) closure;    
        nsAutoLock lock(self->mLock);
        if(self->mScriptTable)
        {
            nsVoidKey scriptkey(script);
            ProfilerFunction* fun = 
                (ProfilerFunction*) self->mScriptTable->Get(&scriptkey);
            if(fun)
            {
                if(before == PR_TRUE)
                {
                    fun->IncrementCallCount();
                    fun->SetStartTime();
                }
                else
                {
                    fun->SetEndTime();
                }
            }
        }
    }   
    return closure;
}

Here is the call graph for this function:

xpctools_JSDestroyScriptHook ( JSContext cx,
JSScript script,
void callerdata 
)

Definition at line 236 of file nsXPCToolsProfiler.cpp.

{
    if(!script)
        return;
    nsXPCToolsProfiler* self = (nsXPCToolsProfiler*) callerdata;    
    nsAutoLock lock(self->mLock);
    if(self->mScriptTable)
    {
        nsVoidKey scriptkey(script);
        self->mScriptTable->Remove(&scriptkey);
    }
}
xpctools_JSNewScriptHook ( JSContext cx,
const char *  filename,
uintN  lineno,
JSScript script,
JSFunction fun,
void callerdata 
)

Definition at line 189 of file nsXPCToolsProfiler.cpp.

{
    if(!script)
        return;
    if(!filename)
        filename = "<<<!!! has no name so may represent many different pages !!!>>>";
    nsXPCToolsProfiler* self = (nsXPCToolsProfiler*) callerdata;    
    nsAutoLock lock(self->mLock);

    if(self->mFileTable)
    {
        nsCStringKey key(filename);
        ProfilerFile* file = (ProfilerFile*) self->mFileTable->Get(&key);
        if(!file)
        {
            file = new ProfilerFile(filename);
            self->mFileTable->Put(&key, file);
        }
        if(file)
        {
            ProfilerFunction* function = 
                file->FindOrAddFunction(fun ? JS_GetFunctionName(fun) : nsnull, 
                                        JS_GetScriptBaseLineNumber(cx, script),
                                        JS_GetScriptLineExtent(cx, script),
                                        fun
                                        ? JS_GetFunctionTotalSize(cx, fun)
                                        : JS_GetScriptTotalSize(cx, script));
            if(function)
            {
                function->IncrementCompileCount();
                if(self->mScriptTable)
                {
                    nsVoidKey scriptkey(script);
                    self->mScriptTable->Put(&scriptkey, function);
                }
            }
        }
    }
}

Here is the call graph for this function:

xpctools_ProfilerFileDeleter ( nsHashKey *  aKey,
void aData,
void closure 
)

Definition at line 159 of file nsXPCToolsProfiler.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

xpctools_ProfilerFunctionDeleter ( nsHashKey *  aKey,
void aData,
void closure 
)

Definition at line 152 of file nsXPCToolsProfiler.cpp.

{
    delete (ProfilerFunction*) aData;
    return PR_TRUE;        
}        

Here is the caller graph for this function: