Bug 296006: correctly handle the re-locking of shallow GCThings. r+a=brendan

This commit is contained in:
shaver%mozilla.org 2005-06-02 12:17:51 +00:00
Родитель 40babb4906
Коммит 3f1770c2b7
1 изменённых файлов: 23 добавлений и 27 удалений

Просмотреть файл

@ -745,40 +745,36 @@ js_LockGCThingRT(JSRuntime *rt, void *thing)
* 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) {
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;
}
} else if (lock == 0) {
#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;
}
if (!lhe->thing) {
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++;
}
JS_ASSERT(lhe->count >= 1);
lhe->count++;
}
}