Back to index

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

Go to the source code of this file.

Defines

#define TRACEOBJ(jsdc, jsdobj, which)   ((void)0)

Functions

static void _destroyJSDObject (JSDContext *jsdc, JSDObject *jsdobj)
static JSDObject_createJSDObject (JSDContext *jsdc, JSContext *cx, JSObject *obj)
void JS_DLL_CALLBACK jsd_ObjectHook (JSContext *cx, JSObject *obj, JSBool isNew, void *closure)
void jsd_Constructing (JSDContext *jsdc, JSContext *cx, JSObject *obj, JSStackFrame *fp)
 _hash_root (const void *key)
JSBool jsd_InitObjectManager (JSDContext *jsdc)
void jsd_DestroyObjectManager (JSDContext *jsdc)
JSDObjectjsd_IterateObjects (JSDContext *jsdc, JSDObject **iterp)
JSObjectjsd_GetWrappedObject (JSDContext *jsdc, JSDObject *jsdobj)
const char * jsd_GetObjectNewURL (JSDContext *jsdc, JSDObject *jsdobj)
uintN jsd_GetObjectNewLineNumber (JSDContext *jsdc, JSDObject *jsdobj)
const char * jsd_GetObjectConstructorURL (JSDContext *jsdc, JSDObject *jsdobj)
uintN jsd_GetObjectConstructorLineNumber (JSDContext *jsdc, JSDObject *jsdobj)
const char * jsd_GetObjectConstructorName (JSDContext *jsdc, JSDObject *jsdobj)
JSDObjectjsd_GetJSDObjectForJSObject (JSDContext *jsdc, JSObject *jsobj)
JSDObjectjsd_GetObjectForValue (JSDContext *jsdc, JSDValue *jsdval)
JSDValuejsd_GetValueForObject (JSDContext *jsdc, JSDObject *jsdobj)

Define Documentation

#define TRACEOBJ (   jsdc,
  jsdobj,
  which 
)    ((void)0)

Definition at line 83 of file jsd_obj.c.


Function Documentation

static JSDObject* _createJSDObject ( JSDContext jsdc,
JSContext cx,
JSObject obj 
) [static]

Definition at line 114 of file jsd_obj.c.

{
    JSDObject* jsdobj;
    JSStackFrame* fp;
    JSStackFrame* iter = NULL;
    const char* newURL;
    jsbytecode* pc;

    JS_ASSERT(JSD_OBJECTS_LOCKED(jsdc));

    jsdobj = (JSDObject*) calloc(1, sizeof(JSDObject));
    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)))
        {
            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;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void _destroyJSDObject ( JSDContext jsdc,
JSDObject jsdobj 
) [static]

Definition at line 97 of file jsd_obj.c.

{
    JS_ASSERT(JSD_OBJECTS_LOCKED(jsdc));

    JS_REMOVE_LINK(&jsdobj->links);
    JS_HashTableRemove(jsdc->objectsTable, jsdobj->obj);

    if(jsdobj->newURL)
        jsd_DropAtom(jsdc, jsdobj->newURL);
    if(jsdobj->ctorURL)
        jsd_DropAtom(jsdc, jsdobj->ctorURL);
    if(jsdobj->ctorName)
        jsd_DropAtom(jsdc, jsdobj->ctorName);
    free(jsdobj);
}

Here is the call graph for this function:

Here is the caller graph for this function:

_hash_root ( const void key)

Definition at line 224 of file jsd_obj.c.

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

Here is the caller graph for this function:

void jsd_Constructing ( JSDContext jsdc,
JSContext cx,
JSObject obj,
JSStackFrame fp 
)

Definition at line 187 of file jsd_obj.c.

{
    JSDObject* jsdobj;
    JSScript* script;
    JSDScript* jsdscript;
    const char* ctorURL;
    const char* ctorName;

    JSD_LOCK_OBJECTS(jsdc);
    jsdobj = jsd_GetJSDObjectForJSObject(jsdc, obj);
    if( jsdobj && !jsdobj->ctorURL && !JS_IsNativeFrame(cx, fp) )
    {
        script = JS_GetFrameScript(cx, fp);
        if( script )
        {
            ctorURL = JS_GetScriptFilename(cx, script);
            if( ctorURL )
                jsdobj->ctorURL = jsd_AddAtom(jsdc, ctorURL);

            JSD_LOCK_SCRIPTS(jsdc);
            jsdscript = jsd_FindJSDScript(jsdc, script);
            JSD_UNLOCK_SCRIPTS(jsdc);
            if( jsdscript )
            {
                ctorName = jsd_GetScriptFunctionName(jsdc, jsdscript);
                if( ctorName )
                    jsdobj->ctorName = jsd_AddAtom(jsdc, ctorName);
            }
            jsdobj->ctorLineno = JS_GetScriptBaseLineNumber(cx, script);
        }
    }
    TRACEOBJ(jsdc, jsdobj, 3);
    JSD_UNLOCK_OBJECTS(jsdc);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 240 of file jsd_obj.c.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 307 of file jsd_obj.c.

{
    JSDObject* jsdobj;

    JSD_LOCK_OBJECTS(jsdc);
    jsdobj = (JSDObject*) JS_HashTableLookup(jsdc->objectsTable, jsobj);
    JSD_UNLOCK_OBJECTS(jsdc);
    return jsdobj;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 293 of file jsd_obj.c.

{
    return jsdobj->ctorLineno;
}

Here is the caller graph for this function:

const char* jsd_GetObjectConstructorName ( JSDContext jsdc,
JSDObject jsdobj 
)

Definition at line 299 of file jsd_obj.c.

{
    if( jsdobj->ctorName )
        return JSD_ATOM_TO_STRING(jsdobj->ctorName);
    return NULL;
}

Here is the caller graph for this function:

const char* jsd_GetObjectConstructorURL ( JSDContext jsdc,
JSDObject jsdobj 
)

Definition at line 285 of file jsd_obj.c.

{
    if( jsdobj->ctorURL )
        return JSD_ATOM_TO_STRING(jsdobj->ctorURL);
    return NULL;
}

Here is the caller graph for this function:

JSDObject* jsd_GetObjectForValue ( JSDContext jsdc,
JSDValue jsdval 
)

Definition at line 318 of file jsd_obj.c.

{
    return jsd_GetJSDObjectForJSObject(jsdc, JSVAL_TO_OBJECT(jsdval->val));
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 279 of file jsd_obj.c.

{
    return jsdobj->newLineno;
}

Here is the caller graph for this function:

const char* jsd_GetObjectNewURL ( JSDContext jsdc,
JSDObject jsdobj 
)

Definition at line 271 of file jsd_obj.c.

{
    if( jsdobj->newURL )
        return JSD_ATOM_TO_STRING(jsdobj->newURL);
    return NULL;
}

Here is the caller graph for this function:

JSDValue* jsd_GetValueForObject ( JSDContext jsdc,
JSDObject jsdobj 
)

Definition at line 324 of file jsd_obj.c.

{
    return jsd_NewValue(jsdc, OBJECT_TO_JSVAL(jsdobj->obj));
}

Here is the call graph for this function:

Here is the caller graph for this function:

JSObject* jsd_GetWrappedObject ( JSDContext jsdc,
JSDObject jsdobj 
)

Definition at line 265 of file jsd_obj.c.

{
    return jsdobj->obj;
}

Here is the caller graph for this function:

Definition at line 230 of file jsd_obj.c.

Here is the call graph for this function:

Here is the caller graph for this function:

JSDObject* jsd_IterateObjects ( JSDContext jsdc,
JSDObject **  iterp 
)

Definition at line 250 of file jsd_obj.c.

{
    JSDObject *jsdobj = *iterp;

    JS_ASSERT(JSD_OBJECTS_LOCKED(jsdc));

    if( !jsdobj )
        jsdobj = (JSDObject *)jsdc->objectsList.next;
    if( jsdobj == (JSDObject *)&jsdc->objectsList )
        return NULL;
    *iterp = (JSDObject*) jsdobj->links.next;
    return jsdobj;
}

Here is the caller graph for this function:

void JS_DLL_CALLBACK jsd_ObjectHook ( JSContext cx,
JSObject obj,
JSBool  isNew,
void closure 
)

Definition at line 160 of file jsd_obj.c.

{
    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);
}

Here is the call graph for this function:

Here is the caller graph for this function: