Back to index

lightning-sunbird  0.9+nobinonly
Defines | Functions | Variables
jsd_scpt.c File Reference
#include "jsd.h"

Go to the source code of this file.

Defines

#define NOT_SET_YET   -1
#define JSD_SCRIPT_HASH_SIZE   1024

Functions

static JSDScript_newJSDScript (JSDContext *jsdc, JSContext *cx, JSScript *script, JSFunction *function)
static void _destroyJSDScript (JSDContext *jsdc, JSDScript *jsdscript)
 jsd_hash_script (const void *key)
 jsd_alloc_script_table (void *priv, size_t size)
 jsd_free_script_table (void *priv, void *item)
 jsd_alloc_script_entry (void *priv, const void *item)
 jsd_free_script_entry (void *priv, JSHashEntry *he, uintN flag)
JSBool jsd_InitScriptManager (JSDContext *jsdc)
void jsd_DestroyScriptManager (JSDContext *jsdc)
JSDScriptjsd_FindJSDScript (JSDContext *jsdc, JSScript *script)
JSDProfileDatajsd_GetScriptProfileData (JSDContext *jsdc, JSDScript *script)
uint32 jsd_GetScriptFlags (JSDContext *jsdc, JSDScript *script)
void jsd_SetScriptFlags (JSDContext *jsdc, JSDScript *script, uint32 flags)
uintN jsd_GetScriptCallCount (JSDContext *jsdc, JSDScript *script)
uintN jsd_GetScriptMaxRecurseDepth (JSDContext *jsdc, JSDScript *script)
jsdouble jsd_GetScriptMinExecutionTime (JSDContext *jsdc, JSDScript *script)
jsdouble jsd_GetScriptMaxExecutionTime (JSDContext *jsdc, JSDScript *script)
jsdouble jsd_GetScriptTotalExecutionTime (JSDContext *jsdc, JSDScript *script)
jsdouble jsd_GetScriptMinOwnExecutionTime (JSDContext *jsdc, JSDScript *script)
jsdouble jsd_GetScriptMaxOwnExecutionTime (JSDContext *jsdc, JSDScript *script)
jsdouble jsd_GetScriptTotalOwnExecutionTime (JSDContext *jsdc, JSDScript *script)
void jsd_ClearScriptProfileData (JSDContext *jsdc, JSDScript *script)
JSScriptjsd_GetJSScript (JSDContext *jsdc, JSDScript *script)
JSFunctionjsd_GetJSFunction (JSDContext *jsdc, JSDScript *script)
JSDScriptjsd_IterateScripts (JSDContext *jsdc, JSDScript **iterp)
voidjsd_SetScriptPrivate (JSDScript *jsdscript, void *data)
voidjsd_GetScriptPrivate (JSDScript *jsdscript)
JSBool jsd_IsActiveScript (JSDContext *jsdc, JSDScript *jsdscript)
const char * jsd_GetScriptFilename (JSDContext *jsdc, JSDScript *jsdscript)
const char * jsd_GetScriptFunctionName (JSDContext *jsdc, JSDScript *jsdscript)
uintN jsd_GetScriptBaseLineNumber (JSDContext *jsdc, JSDScript *jsdscript)
uintN jsd_GetScriptLineExtent (JSDContext *jsdc, JSDScript *jsdscript)
jsuword jsd_GetClosestPC (JSDContext *jsdc, JSDScript *jsdscript, uintN line)
uintN jsd_GetClosestLine (JSDContext *jsdc, JSDScript *jsdscript, jsuword pc)
JSBool jsd_SetScriptHook (JSDContext *jsdc, JSD_ScriptHookProc hook, void *callerdata)
JSBool jsd_GetScriptHook (JSDContext *jsdc, JSD_ScriptHookProc *hook, void **callerdata)
void JS_DLL_CALLBACK jsd_NewScriptHookProc (JSContext *cx, const char *filename, uintN lineno, JSScript *script, JSFunction *fun, void *callerdata)
void JS_DLL_CALLBACK jsd_DestroyScriptHookProc (JSContext *cx, JSScript *script, void *callerdata)
static JSDExecHook_findHook (JSDContext *jsdc, JSDScript *jsdscript, jsuword pc)
static JSBool _isActiveHook (JSDContext *jsdc, JSScript *script, JSDExecHook *jsdhook)
JSTrapStatus JS_DLL_CALLBACK jsd_TrapHandler (JSContext *cx, JSScript *script, jsbytecode *pc, jsval *rval, void *closure)
JSBool jsd_SetExecutionHook (JSDContext *jsdc, JSDScript *jsdscript, jsuword pc, JSD_ExecutionHookProc hook, void *callerdata)
JSBool jsd_ClearExecutionHook (JSDContext *jsdc, JSDScript *jsdscript, jsuword pc)
JSBool jsd_ClearAllExecutionHooksForScript (JSDContext *jsdc, JSDScript *jsdscript)
JSBool jsd_ClearAllExecutionHooks (JSDContext *jsdc)
void jsd_ScriptCreated (JSDContext *jsdc, JSContext *cx, const char *filename, uintN lineno, JSScript *script, JSFunction *fun)
void jsd_ScriptDestroyed (JSDContext *jsdc, JSContext *cx, JSScript *script)

Variables

static JSHashAllocOps script_alloc_ops

Define Documentation

Definition at line 260 of file jsd_scpt.c.

#define NOT_SET_YET   -1

Definition at line 51 of file jsd_scpt.c.


Function Documentation

static void _destroyJSDScript ( JSDContext jsdc,
JSDScript jsdscript 
) [static]

Definition at line 154 of file jsd_scpt.c.

{
    JS_ASSERT(JSD_SCRIPTS_LOCKED(jsdc));

    /* destroy all hooks */
    jsd_ClearAllExecutionHooksForScript(jsdc, jsdscript);

    JS_REMOVE_LINK(&jsdscript->links);
    if(jsdscript->url)
        free(jsdscript->url);

    if (jsdscript->profileData)
        free(jsdscript->profileData);
    
    if(jsdscript)
        free(jsdscript);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static JSDExecHook* _findHook ( JSDContext jsdc,
JSDScript jsdscript,
jsuword  pc 
) [static]

Definition at line 645 of file jsd_scpt.c.

{
    JSDExecHook* jsdhook;
    JSCList* list = &jsdscript->hooks;

    for( jsdhook = (JSDExecHook*)list->next;
         jsdhook != (JSDExecHook*)list;
         jsdhook = (JSDExecHook*)jsdhook->links.next )
    {
        if (jsdhook->pc == pc)
            return jsdhook;
    }
    return NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static JSBool _isActiveHook ( JSDContext jsdc,
JSScript script,
JSDExecHook jsdhook 
) [static]

Definition at line 661 of file jsd_scpt.c.

{
    JSDExecHook* current;
    JSCList* list;
    JSDScript* jsdscript;

    JSD_LOCK_SCRIPTS(jsdc);
    jsdscript = jsd_FindJSDScript(jsdc, script);
    if( ! jsdscript)
    {
        JSD_UNLOCK_SCRIPTS(jsdc);
        return JS_FALSE;
    }

    list = &jsdscript->hooks;

    for( current = (JSDExecHook*)list->next;
         current != (JSDExecHook*)list;
         current = (JSDExecHook*)current->links.next )
    {
        if(current == jsdhook)
        {
            JSD_UNLOCK_SCRIPTS(jsdc);
            return JS_TRUE;
        }
    }
    JSD_UNLOCK_SCRIPTS(jsdc);
    return JS_FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static JSDScript* _newJSDScript ( JSDContext jsdc,
JSContext cx,
JSScript script,
JSFunction function 
) [static]

Definition at line 91 of file jsd_scpt.c.

{
    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 */
    lineno = (uintN) JS_GetScriptBaseLineNumber(cx, script);
    if( lineno == 0 )
        return NULL;

    jsdscript = (JSDScript*) calloc(1, sizeof(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->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 )
    {
        jsdscript->url = jsdlw_BuildAppRelativeFilename(jsdscript->app, raw_filename);
        if( function )
        {
            jsdscript->lwscript = 
                LWDBG_GetScriptOfFunction(jsdscript->app,
                                          JS_GetFunctionName(function));
    
            /* also, make sure this file is added to filelist if is .js file */
            if( HasFileExtention(raw_filename,"js") || 
                HasFileExtention(raw_filename,"sjs") )
            {
                jsdlw_PreLoadSource(jsdc, jsdscript->app, raw_filename, JS_FALSE);
            }
        }
        else
        {
            jsdscript->lwscript = LWDBG_GetCurrentTopLevelScript();
        }
    }
#endif

    JS_INIT_CLIST(&jsdscript->hooks);
    
    return jsdscript;
}           

Here is the call graph for this function:

Here is the caller graph for this function:

jsd_alloc_script_entry ( void priv,
const void item 
)

Definition at line 239 of file jsd_scpt.c.

{
    return (JSHashEntry*) malloc(sizeof(JSHashEntry));
}
jsd_alloc_script_table ( void priv,
size_t  size 
)

Definition at line 227 of file jsd_scpt.c.

{
    return malloc(size);
}

Definition at line 836 of file jsd_scpt.c.

{
    JSDScript* jsdscript;
    JSDScript* iterp = NULL;

    JSD_LOCK();
    while( NULL != (jsdscript = jsd_IterateScripts(jsdc, &iterp)) )
        jsd_ClearAllExecutionHooksForScript(jsdc, jsdscript);
    JSD_UNLOCK();
    return JS_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 816 of file jsd_scpt.c.

{
    JSDExecHook* jsdhook;
    JSCList* list = &jsdscript->hooks;

    JSD_LOCK();

    while( (JSDExecHook*)list != (jsdhook = (JSDExecHook*)list->next) )
    {
        JS_REMOVE_LINK(&jsdhook->links);
        free(jsdhook);
    }

    JS_ClearScriptTraps(jsdc->dumbContext, jsdscript->script);
    JSD_UNLOCK();

    return JS_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

JSBool jsd_ClearExecutionHook ( JSDContext jsdc,
JSDScript jsdscript,
jsuword  pc 
)

Definition at line 789 of file jsd_scpt.c.

{
    JSDExecHook* jsdhook;

    JSD_LOCK();

    jsdhook = _findHook(jsdc, jsdscript, pc);
    if( ! jsdhook )
    {
        JS_ASSERT(0);
        JSD_UNLOCK();
        return JS_FALSE;
    }

    JS_ClearTrap(jsdc->dumbContext, jsdscript->script, 
                 (jsbytecode*)pc, NULL, NULL );

    JS_REMOVE_LINK(&jsdhook->links);
    free(jsdhook);

    JSD_UNLOCK();
    return JS_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 384 of file jsd_scpt.c.

{
    if (script->profileData)
    {
        free(script->profileData);
        script->profileData = NULL;
    }
}    

Here is the caller graph for this function:

void JS_DLL_CALLBACK jsd_DestroyScriptHookProc ( JSContext cx,
JSScript script,
void callerdata 
)

Definition at line 593 of file jsd_scpt.c.

{
    JSDScript* jsdscript = NULL;
    JSDContext* jsdc = (JSDContext*) callerdata;
    JSD_ScriptHookProc      hook;
    void*                   hookData;
    
    JSD_ASSERT_VALID_CONTEXT(jsdc);

    if( JSD_IS_DANGEROUS_THREAD(jsdc) )
        return;
    
    JSD_LOCK_SCRIPTS(jsdc);
    jsdscript = jsd_FindJSDScript(jsdc, script);
    JSD_UNLOCK_SCRIPTS(jsdc);

    if( ! jsdscript )
        return;

#ifdef JSD_DUMP
    JSD_LOCK_SCRIPTS(jsdc);
    _dumpJSDScript(jsdc, jsdscript, "***DESTROY Script: ");
    JSD_UNLOCK_SCRIPTS(jsdc);
#endif /* JSD_DUMP */

    /* local in case hook gets cleared on another thread */
    JSD_LOCK();
    hook = jsdc->scriptHook;
    hookData = jsdc->scriptHookData;
    JSD_UNLOCK();

    if( hook )
        hook(jsdc, jsdscript, JS_FALSE, hookData);

    JSD_LOCK_SCRIPTS(jsdc);
    JS_HashTableRemove(jsdc->scriptsTable, (void *)script);
    JSD_UNLOCK_SCRIPTS(jsdc);

#ifdef JSD_DUMP
    JSD_LOCK_SCRIPTS(jsdc);
    _dumpJSDScriptList(jsdc);
    JSD_UNLOCK_SCRIPTS(jsdc);
#endif /* JSD_DUMP */
}                

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 274 of file jsd_scpt.c.

Here is the call graph for this function:

Here is the caller graph for this function:

JSDScript* jsd_FindJSDScript ( JSDContext jsdc,
JSScript script 
)

Definition at line 283 of file jsd_scpt.c.

{
    JS_ASSERT(JSD_SCRIPTS_LOCKED(jsdc));
    return (JSDScript*) JS_HashTableLookup(jsdc->scriptsTable, (void *)script);
}               

Here is the call graph for this function:

Here is the caller graph for this function:

jsd_free_script_entry ( void priv,
JSHashEntry he,
uintN  flag 
)

Definition at line 245 of file jsd_scpt.c.

Here is the call graph for this function:

jsd_free_script_table ( void priv,
void item 
)

Definition at line 233 of file jsd_scpt.c.

{
    free(item);
}
uintN jsd_GetClosestLine ( JSDContext jsdc,
JSDScript jsdscript,
jsuword  pc 
)

Definition at line 497 of file jsd_scpt.c.

{
    uintN first = jsdscript->lineBase;
    uintN last = first + jsd_GetScriptLineExtent(jsdc, jsdscript) - 1;
    uintN line = JS_PCToLineNumber(jsdc->dumbContext, 
                                     jsdscript->script, (jsbytecode*)pc);

    if( line < first )
        return first;
    if( line > last )
        return last;

#ifdef LIVEWIRE
    if( jsdscript && jsdscript->lwscript )
    {
        uintN newline;
        jsdlw_ProcessedToRawLineNumber(jsdc, jsdscript, line, &newline);
        line = newline;
    }
#endif

    return line;    
}

Here is the call graph for this function:

Here is the caller graph for this function:

jsuword jsd_GetClosestPC ( JSDContext jsdc,
JSDScript jsdscript,
uintN  line 
)

Definition at line 480 of file jsd_scpt.c.

{
#ifdef LIVEWIRE
    if( jsdscript && jsdscript->lwscript )
    {
        uintN newline;
        jsdlw_RawToProcessedLineNumber(jsdc, jsdscript, line, &newline);
        if( line != newline )
            line = newline;
    }
#endif

    return (jsuword) JS_LineNumberToPC(jsdc->dumbContext, 
                                       jsdscript->script, line );
}

Here is the call graph for this function:

Here is the caller graph for this function:

JSFunction* jsd_GetJSFunction ( JSDContext jsdc,
JSDScript script 
)

Definition at line 400 of file jsd_scpt.c.

{
    return script->function;
}

Here is the caller graph for this function:

JSScript* jsd_GetJSScript ( JSDContext jsdc,
JSDScript script 
)

Definition at line 394 of file jsd_scpt.c.

{
    return script->script;
}

Here is the caller graph for this function:

uintN jsd_GetScriptBaseLineNumber ( JSDContext jsdc,
JSDScript jsdscript 
)

Definition at line 466 of file jsd_scpt.c.

{
    return jsdscript->lineBase;
}

Here is the caller graph for this function:

uintN jsd_GetScriptCallCount ( JSDContext jsdc,
JSDScript script 
)

Definition at line 312 of file jsd_scpt.c.

{
    if (script->profileData)
        return script->profileData->callCount;

    return 0;
}

Here is the caller graph for this function:

const char* jsd_GetScriptFilename ( JSDContext jsdc,
JSDScript jsdscript 
)

Definition at line 452 of file jsd_scpt.c.

{
    return jsdscript->url;
}

Here is the caller graph for this function:

uint32 jsd_GetScriptFlags ( JSDContext jsdc,
JSDScript script 
)

Definition at line 300 of file jsd_scpt.c.

{
    return script->flags;
}

Here is the caller graph for this function:

const char* jsd_GetScriptFunctionName ( JSDContext jsdc,
JSDScript jsdscript 
)

Definition at line 458 of file jsd_scpt.c.

{
    if( ! jsdscript->function )
        return NULL;
    return JS_GetFunctionName(jsdscript->function);
}

Here is the call graph for this function:

Here is the caller graph for this function:

JSBool jsd_GetScriptHook ( JSDContext jsdc,
JSD_ScriptHookProc *  hook,
void **  callerdata 
)

Definition at line 532 of file jsd_scpt.c.

{
    JSD_LOCK();
    if( hook )
        *hook = jsdc->scriptHook;
    if( callerdata )
        *callerdata = jsdc->scriptHookData;
    JSD_UNLOCK();
    return JS_TRUE;
}    

Here is the caller graph for this function:

uintN jsd_GetScriptLineExtent ( JSDContext jsdc,
JSDScript jsdscript 
)

Definition at line 472 of file jsd_scpt.c.

{
    if( NOT_SET_YET == (int)jsdscript->lineExtent )
        jsdscript->lineExtent = JS_GetScriptLineExtent(jsdc->dumbContext, jsdscript->script);
    return jsdscript->lineExtent;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 339 of file jsd_scpt.c.

{
    if (script->profileData)
        return script->profileData->maxExecutionTime;

    return 0.0;
}

Here is the caller graph for this function:

Definition at line 366 of file jsd_scpt.c.

{
    if (script->profileData)
        return script->profileData->maxOwnExecutionTime;

    return 0.0;
}

Here is the caller graph for this function:

Definition at line 321 of file jsd_scpt.c.

{
    if (script->profileData)
        return script->profileData->maxRecurseDepth;

    return 0;
}

Here is the caller graph for this function:

Definition at line 330 of file jsd_scpt.c.

{
    if (script->profileData)
        return script->profileData->minExecutionTime;

    return 0.0;
}

Here is the caller graph for this function:

Definition at line 357 of file jsd_scpt.c.

{
    if (script->profileData)
        return script->profileData->minOwnExecutionTime;

    return 0.0;
}

Here is the caller graph for this function:

void* jsd_GetScriptPrivate ( JSDScript jsdscript)

Definition at line 429 of file jsd_scpt.c.

{
    return jsdscript->data;
}

Here is the caller graph for this function:

Definition at line 291 of file jsd_scpt.c.

{
    if (!script->profileData)
        script->profileData = (JSDProfileData*)calloc(1, sizeof(JSDProfileData));

    return script->profileData;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 348 of file jsd_scpt.c.

{
    if (script->profileData)
        return script->profileData->totalExecutionTime;

    return 0.0;
}

Here is the caller graph for this function:

Definition at line 375 of file jsd_scpt.c.

{
    if (script->profileData)
        return script->profileData->totalOwnExecutionTime;

    return 0.0;
}

Here is the caller graph for this function:

Definition at line 221 of file jsd_scpt.c.

{
    return ((JSHashNumber) key) >> 2; /* help lame MSVC1.5 on Win16 */
}

Here is the caller graph for this function:

Definition at line 264 of file jsd_scpt.c.

Here is the call graph for this function:

Here is the caller graph for this function:

JSBool jsd_IsActiveScript ( JSDContext jsdc,
JSDScript jsdscript 
)

Definition at line 435 of file jsd_scpt.c.

{
    JSDScript *current;

    JS_ASSERT(JSD_SCRIPTS_LOCKED(jsdc));

    for( current = (JSDScript *)jsdc->scripts.next;
         current != (JSDScript *)&jsdc->scripts;
         current = (JSDScript *)current->links.next )
    {
        if(jsdscript == current)
            return JS_TRUE;
    }
    return JS_FALSE;
}        

Here is the caller graph for this function:

JSDScript* jsd_IterateScripts ( JSDContext jsdc,
JSDScript **  iterp 
)

Definition at line 406 of file jsd_scpt.c.

{
    JSDScript *jsdscript = *iterp;
    
    JS_ASSERT(JSD_SCRIPTS_LOCKED(jsdc));

    if( !jsdscript )
        jsdscript = (JSDScript *)jsdc->scripts.next;
    if( jsdscript == (JSDScript *)&jsdc->scripts )
        return NULL;
    *iterp = (JSDScript*) jsdscript->links.next;
    return jsdscript;
}

Here is the caller graph for this function:

void JS_DLL_CALLBACK jsd_NewScriptHookProc ( JSContext cx,
const char *  filename,
uintN  lineno,
JSScript script,
JSFunction fun,
void callerdata 
)

Definition at line 546 of file jsd_scpt.c.

{
    JSDScript* jsdscript = NULL;
    JSDContext* jsdc = (JSDContext*) callerdata;
    JSD_ScriptHookProc      hook;
    void*                   hookData;
    
    JSD_ASSERT_VALID_CONTEXT(jsdc);

    if( JSD_IS_DANGEROUS_THREAD(jsdc) )
        return;
    
#ifdef LIVEWIRE
    if( 1 == lineno )
        jsdlw_PreLoadSource(jsdc, LWDBG_GetCurrentApp(), filename, JS_TRUE );
#endif
    
    JSD_LOCK_SCRIPTS(jsdc);
    jsdscript = _newJSDScript(jsdc, cx, script, fun);
    JSD_UNLOCK_SCRIPTS(jsdc);
    if( ! jsdscript )
        return;

#ifdef JSD_DUMP
    JSD_LOCK_SCRIPTS(jsdc);
    _dumpJSDScript(jsdc, jsdscript, "***NEW Script: ");
    _dumpJSDScriptList( jsdc );
    JSD_UNLOCK_SCRIPTS(jsdc);
#endif /* JSD_DUMP */

    /* local in case jsdc->scriptHook gets cleared on another thread */
    JSD_LOCK();
    hook = jsdc->scriptHook;
    hookData = jsdc->scriptHookData;
    JSD_UNLOCK();

    if( hook )
        hook(jsdc, jsdscript, JS_TRUE, hookData);
}                

Here is the call graph for this function:

Here is the caller graph for this function:

void jsd_ScriptCreated ( JSDContext jsdc,
JSContext cx,
const char *  filename,
uintN  lineno,
JSScript script,
JSFunction fun 
)

Definition at line 849 of file jsd_scpt.c.

{
    jsd_NewScriptHookProc(cx, filename, lineno, script, fun, jsdc);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void jsd_ScriptDestroyed ( JSDContext jsdc,
JSContext cx,
JSScript script 
)

Definition at line 860 of file jsd_scpt.c.

{
    jsd_DestroyScriptHookProc(cx, script, jsdc);
}

Here is the call graph for this function:

Here is the caller graph for this function:

JSBool jsd_SetExecutionHook ( JSDContext jsdc,
JSDScript jsdscript,
jsuword  pc,
JSD_ExecutionHookProc  hook,
void callerdata 
)

Definition at line 741 of file jsd_scpt.c.

{
    JSDExecHook* jsdhook;

    JSD_LOCK();
    if( ! hook )
    {
        jsd_ClearExecutionHook(jsdc, jsdscript, pc);
        JSD_UNLOCK();
        return JS_TRUE;
    }

    jsdhook = _findHook(jsdc, jsdscript, pc);
    if( jsdhook )
    {
        jsdhook->hook       = hook;
        jsdhook->callerdata = callerdata;
        return JS_TRUE;
    }
    /* else... */

    jsdhook = (JSDExecHook*)calloc(1, sizeof(JSDExecHook));
    if( ! jsdhook )
        return JS_FALSE;
    jsdhook->jsdscript  = jsdscript;
    jsdhook->pc         = pc;
    jsdhook->hook       = hook;
    jsdhook->callerdata = callerdata;

    if( ! JS_SetTrap(jsdc->dumbContext, jsdscript->script, 
                     (jsbytecode*)pc, jsd_TrapHandler, 
                     (void*) PRIVATE_TO_JSVAL(jsdhook)) )
    {
        free(jsdhook);
        return JS_FALSE;
    }

    JS_APPEND_LINK(&jsdhook->links, &jsdscript->hooks);
    JSD_UNLOCK();

    return JS_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void jsd_SetScriptFlags ( JSDContext jsdc,
JSDScript script,
uint32  flags 
)

Definition at line 306 of file jsd_scpt.c.

{
    script->flags = flags;
}

Here is the caller graph for this function:

JSBool jsd_SetScriptHook ( JSDContext jsdc,
JSD_ScriptHookProc  hook,
void callerdata 
)

Definition at line 522 of file jsd_scpt.c.

{
    JSD_LOCK();
    jsdc->scriptHook = hook;
    jsdc->scriptHookData = callerdata;
    JSD_UNLOCK();
    return JS_TRUE;
}

Here is the caller graph for this function:

void* jsd_SetScriptPrivate ( JSDScript jsdscript,
void data 
)

Definition at line 421 of file jsd_scpt.c.

{
    void *rval = jsdscript->data;
    jsdscript->data = data;
    return rval;
}

Here is the caller graph for this function:

JSTrapStatus JS_DLL_CALLBACK jsd_TrapHandler ( JSContext cx,
JSScript script,
jsbytecode pc,
jsval rval,
void closure 
)

Definition at line 693 of file jsd_scpt.c.

{
    JSDExecHook* jsdhook = (JSDExecHook*) JSVAL_TO_PRIVATE(((jsval)closure));
    JSD_ExecutionHookProc hook;
    void* hookData;
    JSDContext*  jsdc;
    JSDScript* jsdscript;

    JSD_LOCK();

    if( NULL == (jsdc = jsd_JSDContextForJSContext(cx)) ||
        ! _isActiveHook(jsdc, script, jsdhook) )
    {
        JSD_UNLOCK();
        return JSTRAP_CONTINUE;
    }

    JSD_ASSERT_VALID_EXEC_HOOK(jsdhook);
    JS_ASSERT(jsdhook->pc == (jsuword)pc);
    JS_ASSERT(jsdhook->jsdscript->script == script);
    JS_ASSERT(jsdhook->jsdscript->jsdc == jsdc);

    hook = jsdhook->hook;
    hookData = jsdhook->callerdata;
    jsdscript = jsdhook->jsdscript;

    /* do not use jsdhook-> after this point */
    JSD_UNLOCK();

    if( ! jsdc || ! jsdc->inited )
        return JSTRAP_CONTINUE;

    if( JSD_IS_DANGEROUS_THREAD(jsdc) )
        return JSTRAP_CONTINUE;

#ifdef LIVEWIRE
    if( ! jsdlw_UserCodeAtPC(jsdc, jsdscript, (jsuword)pc) )
        return JSTRAP_CONTINUE;
#endif

    return jsd_CallExecutionHook(jsdc, cx, JSD_HOOK_BREAKPOINT,
                                 hook, hookData, rval);
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation