lhe = (JSGCLockHashEntry *) JS_DHashTableOperate(rt->gcLocksHash, thing, JS_DHASH_LOOKUP); JS_ASSERT(JS_DHASH_ENTRY_IS_BUSY(&lhe->hdr)); if (JS_DHASH_ENTRY_IS_BUSY(&lhe->hdr)) { JS_ASSERT(lhe->count >= 1); lhe->count++; }
JS_ASSERT(lhe->count >= 1); lhe->count++;
js_LockGCThingRT(JSRuntime *rt, void *thing){    JSBool ok, deep;    uint8 *flagp, flags, lock, type;    JSGCLockHashEntry *lhe;    ok = JS_TRUE;    if (!thing)        return ok;    flagp = js_GetGCThingFlags(thing);    JS_LOCK_GC(rt);    flags = *flagp;    lock = (flags & GCF_LOCK);    type = (flags & GCF_TYPEMASK);    deep = GC_THING_IS_DEEP(type, thing);    /*     * Avoid adding a rt->gcLocksHash entry for shallow things until someone     * nests a lock -- then start such an entry with a count of 2, not 1.     */    if (lock || deep) {        if (lock == 0 || !deep) {            if (!rt->gcLocksHash) {                rt->gcLocksHash =                    JS_NewDHashTable(JS_DHashGetStubOps(), NULL,                                     sizeof(JSGCLockHashEntry),                                     GC_ROOTS_SIZE);                if (!rt->gcLocksHash) {                    ok = JS_FALSE;                    goto done;                }            } else {#ifdef DEBUG                JSDHashEntryHdr *hdr =                    JS_DHashTableOperate(rt->gcLocksHash, thing,                                         JS_DHASH_LOOKUP);                JS_ASSERT(JS_DHASH_ENTRY_IS_FREE(hdr));#endif            }            lhe = (JSGCLockHashEntry *)                  JS_DHashTableOperate(rt->gcLocksHash, thing, JS_DHASH_ADD);            if (!lhe) {                ok = JS_FALSE;                goto done;            }            lhe->thing = thing;            lhe->count = deep ? 1 : 2;        } else {            lhe = (JSGCLockHashEntry *)                  JS_DHashTableOperate(rt->gcLocksHash, thing, JS_DHASH_LOOKUP);            JS_ASSERT(JS_DHASH_ENTRY_IS_BUSY(&lhe->hdr));            if (JS_DHASH_ENTRY_IS_BUSY(&lhe->hdr)) {                JS_ASSERT(lhe->count >= 1);                lhe->count++;            }        }    }    *flagp = (uint8)(flags | GCF_LOCK);    METER(rt->gcStats.lock++);    ok = JS_TRUE;done:    JS_UNLOCK_GC(rt);    return ok;}