Followup fixes to making cycle collector use more efficient hashtables: shrink size of table and fix warnings on 64-bit machines. b=377606 sr=peterv r=graydon

This commit is contained in:
dbaron@dbaron.org 2007-04-23 16:34:33 -07:00
Родитель 2019f586fe
Коммит be3b7ec321
2 изменённых файлов: 14 добавлений и 17 удалений

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

@ -114,8 +114,6 @@ nsXPConnect::nsXPConnect()
typedef nsBaseHashtable<nsVoidPtrHashKey, nsISupports*, nsISupports*> ScopeSet;
#endif
#define OBJ_REFCOUNT_ENTRIES 100000
static const PLDHashTableOps RefCountOps =
{
PL_DHashAllocTable,
@ -158,15 +156,16 @@ struct JSObjectRefcounts
void InitRefCounts()
{
if(!PL_DHashTableInit(&mRefCounts, &RefCountOps, nsnull,
sizeof(ObjRefCount),
PL_DHASH_DEFAULT_CAPACITY(OBJ_REFCOUNT_ENTRIES)))
sizeof(ObjRefCount), 65536))
mRefCounts.ops = nsnull;
}
void Clear()
{
if(!mRefCounts.ops || mRefCounts.entryCount > 0) {
if(mRefCounts.ops)
PL_DHashTableFinish(&mRefCounts);
InitRefCounts();
}
#ifndef XPCONNECT_STANDALONE
mScopes.Clear();
#endif

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

@ -296,13 +296,11 @@ enum NodeColor { black, white, grey };
struct PtrInfo
: public PLDHashEntryStub
{
#define WORD_MINUS_2_BITS ((PR_BYTES_PER_WORD * 8) - 2)
PRUint32 mColor : 2;
PRUint32 mInternalRefs : WORD_MINUS_2_BITS;
PRUint32 mInternalRefs : 30;
// FIXME: mLang expands back to a full word when bug 368774 lands.
PRUint32 mLang : 2;
PRUint32 mRefCount : WORD_MINUS_2_BITS;
#undef WORD_MINUS_2_BITS
PRUint32 mRefCount : 30;
#ifdef DEBUG_CC
size_t mBytes;
@ -326,8 +324,6 @@ InitPtrInfo(PLDHashTable *table, PLDHashEntryHdr *entry, const void *key)
return PR_TRUE;
}
#define GCTABLE_N_ENTRIES 100000
static PLDHashTableOps GCTableOps = {
PL_DHashAllocTable,
PL_DHashFreeTable,
@ -356,15 +352,17 @@ struct GCTable
void Init()
{
if (!PL_DHashTableInit(&mTab, &GCTableOps, nsnull, sizeof(PtrInfo),
PL_DHASH_DEFAULT_CAPACITY(GCTABLE_N_ENTRIES)))
32768))
mTab.ops = nsnull;
}
void Clear()
{
if (!mTab.ops || mTab.entryCount > 0) {
if (mTab.ops)
PL_DHashTableFinish(&mTab);
Init();
}
}
PtrInfo *Lookup(void *key)
{