mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-27 23:02:20 +00:00
Backed out 2 changesets (bug 1121304) for consistent b2g hangs in webgl-color-test.html?frame=1&__&preserve&premult&_____
Backed out changeset 20651ac19549 (bug 1121304) Backed out changeset 758afec77c95 (bug 1121304)
This commit is contained in:
parent
5d81d66f89
commit
e39f0adeca
@ -208,6 +208,8 @@ NS_GetContentList(nsINode* aRootNode,
|
||||
|
||||
static const PLDHashTableOps hash_table_ops =
|
||||
{
|
||||
PL_DHashAllocTable,
|
||||
PL_DHashFreeTable,
|
||||
ContentListHashtableHashKey,
|
||||
ContentListHashtableMatchEntry,
|
||||
PL_DHashMoveEntryStub,
|
||||
@ -318,6 +320,8 @@ GetFuncStringContentList(nsINode* aRootNode,
|
||||
|
||||
static const PLDHashTableOps hash_table_ops =
|
||||
{
|
||||
PL_DHashAllocTable,
|
||||
PL_DHashFreeTable,
|
||||
FuncStringContentListHashtableHashKey,
|
||||
FuncStringContentListHashtableMatchEntry,
|
||||
PL_DHashMoveEntryStub,
|
||||
|
@ -479,6 +479,8 @@ nsContentUtils::Init()
|
||||
if (!sEventListenerManagersHash.ops) {
|
||||
static const PLDHashTableOps hash_table_ops =
|
||||
{
|
||||
PL_DHashAllocTable,
|
||||
PL_DHashFreeTable,
|
||||
PL_DHashVoidPtrKeyStub,
|
||||
PL_DHashMatchEntryStub,
|
||||
PL_DHashMoveEntryStub,
|
||||
|
@ -3972,6 +3972,8 @@ nsDocument::SetSubDocumentFor(Element* aElement, nsIDocument* aSubDoc)
|
||||
|
||||
static const PLDHashTableOps hash_table_ops =
|
||||
{
|
||||
PL_DHashAllocTable,
|
||||
PL_DHashFreeTable,
|
||||
PL_DHashVoidPtrKeyStub,
|
||||
PL_DHashMatchEntryStub,
|
||||
PL_DHashMoveEntryStub,
|
||||
|
@ -320,6 +320,8 @@ nsScriptNameSpaceManager::Init()
|
||||
{
|
||||
static const PLDHashTableOps hash_table_ops =
|
||||
{
|
||||
PL_DHashAllocTable,
|
||||
PL_DHashFreeTable,
|
||||
GlobalNameHashHashKey,
|
||||
GlobalNameHashMatchEntry,
|
||||
PL_DHashMoveEntryStub,
|
||||
|
@ -760,6 +760,8 @@ XULDocument::AddBroadcastListenerFor(Element& aBroadcaster, Element& aListener,
|
||||
}
|
||||
|
||||
static const PLDHashTableOps gOps = {
|
||||
PL_DHashAllocTable,
|
||||
PL_DHashFreeTable,
|
||||
PL_DHashVoidPtrKeyStub,
|
||||
PL_DHashMatchEntryStub,
|
||||
PL_DHashMoveEntryStub,
|
||||
|
@ -16,6 +16,8 @@ using namespace mozilla;
|
||||
|
||||
const PLDHashTableOps nsCommandParams::sHashOps =
|
||||
{
|
||||
PL_DHashAllocTable,
|
||||
PL_DHashFreeTable,
|
||||
HashKey,
|
||||
HashMatchEntry,
|
||||
HashMoveEntry,
|
||||
|
@ -622,6 +622,8 @@ public:
|
||||
: mWriteNeeded(false)
|
||||
{
|
||||
mOps = (PLDHashTableOps) {
|
||||
PL_DHashAllocTable,
|
||||
PL_DHashFreeTable,
|
||||
StringHash,
|
||||
HashMatchEntry,
|
||||
MoveEntry,
|
||||
|
@ -212,6 +212,8 @@ Native2WrappedNativeMap::SizeOfEntryExcludingThis(PLDHashEntryHdr *hdr,
|
||||
|
||||
const struct PLDHashTableOps IID2WrappedJSClassMap::Entry::sOps =
|
||||
{
|
||||
PL_DHashAllocTable,
|
||||
PL_DHashFreeTable,
|
||||
HashIIDPtrKey,
|
||||
MatchIIDPtrKey,
|
||||
PL_DHashMoveEntryStub,
|
||||
@ -246,6 +248,8 @@ IID2WrappedJSClassMap::~IID2WrappedJSClassMap()
|
||||
|
||||
const struct PLDHashTableOps IID2NativeInterfaceMap::Entry::sOps =
|
||||
{
|
||||
PL_DHashAllocTable,
|
||||
PL_DHashFreeTable,
|
||||
HashIIDPtrKey,
|
||||
MatchIIDPtrKey,
|
||||
PL_DHashMoveEntryStub,
|
||||
@ -448,6 +452,8 @@ NativeSetMap::Entry::Match(PLDHashTable *table,
|
||||
|
||||
const struct PLDHashTableOps NativeSetMap::Entry::sOps =
|
||||
{
|
||||
PL_DHashAllocTable,
|
||||
PL_DHashFreeTable,
|
||||
HashNativeKey,
|
||||
Match,
|
||||
PL_DHashMoveEntryStub,
|
||||
@ -512,6 +518,8 @@ IID2ThisTranslatorMap::Entry::Clear(PLDHashTable *table, PLDHashEntryHdr *entry)
|
||||
|
||||
const struct PLDHashTableOps IID2ThisTranslatorMap::Entry::sOps =
|
||||
{
|
||||
PL_DHashAllocTable,
|
||||
PL_DHashFreeTable,
|
||||
HashIIDPtrKey,
|
||||
Match,
|
||||
PL_DHashMoveEntryStub,
|
||||
@ -588,6 +596,8 @@ XPCNativeScriptableSharedMap::Entry::Match(PLDHashTable *table,
|
||||
|
||||
const struct PLDHashTableOps XPCNativeScriptableSharedMap::Entry::sOps =
|
||||
{
|
||||
PL_DHashAllocTable,
|
||||
PL_DHashFreeTable,
|
||||
Hash,
|
||||
Match,
|
||||
PL_DHashMoveEntryStub,
|
||||
|
@ -69,6 +69,8 @@ PlaceholderMapMatchEntry(PLDHashTable *table, const PLDHashEntryHdr *hdr,
|
||||
}
|
||||
|
||||
static const PLDHashTableOps PlaceholderMapOps = {
|
||||
PL_DHashAllocTable,
|
||||
PL_DHashFreeTable,
|
||||
PL_DHashVoidPtrKeyStub,
|
||||
PlaceholderMapMatchEntry,
|
||||
PL_DHashMoveEntryStub,
|
||||
|
@ -362,6 +362,8 @@ RuleHash_NameSpaceTable_MatchEntry(PLDHashTable *table,
|
||||
}
|
||||
|
||||
static const PLDHashTableOps RuleHash_TagTable_Ops = {
|
||||
PL_DHashAllocTable,
|
||||
PL_DHashFreeTable,
|
||||
PL_DHashVoidPtrKeyStub,
|
||||
RuleHash_TagTable_MatchEntry,
|
||||
RuleHash_TagTable_MoveEntry,
|
||||
@ -372,6 +374,8 @@ static const PLDHashTableOps RuleHash_TagTable_Ops = {
|
||||
// Case-sensitive ops.
|
||||
static const RuleHashTableOps RuleHash_ClassTable_CSOps = {
|
||||
{
|
||||
PL_DHashAllocTable,
|
||||
PL_DHashFreeTable,
|
||||
PL_DHashVoidPtrKeyStub,
|
||||
RuleHash_CSMatchEntry,
|
||||
RuleHash_MoveEntry,
|
||||
@ -384,6 +388,8 @@ static const RuleHashTableOps RuleHash_ClassTable_CSOps = {
|
||||
// Case-insensitive ops.
|
||||
static const RuleHashTableOps RuleHash_ClassTable_CIOps = {
|
||||
{
|
||||
PL_DHashAllocTable,
|
||||
PL_DHashFreeTable,
|
||||
RuleHash_CIHashKey,
|
||||
RuleHash_CIMatchEntry,
|
||||
RuleHash_MoveEntry,
|
||||
@ -396,6 +402,8 @@ static const RuleHashTableOps RuleHash_ClassTable_CIOps = {
|
||||
// Case-sensitive ops.
|
||||
static const RuleHashTableOps RuleHash_IdTable_CSOps = {
|
||||
{
|
||||
PL_DHashAllocTable,
|
||||
PL_DHashFreeTable,
|
||||
PL_DHashVoidPtrKeyStub,
|
||||
RuleHash_CSMatchEntry,
|
||||
RuleHash_MoveEntry,
|
||||
@ -408,6 +416,8 @@ static const RuleHashTableOps RuleHash_IdTable_CSOps = {
|
||||
// Case-insensitive ops.
|
||||
static const RuleHashTableOps RuleHash_IdTable_CIOps = {
|
||||
{
|
||||
PL_DHashAllocTable,
|
||||
PL_DHashFreeTable,
|
||||
RuleHash_CIHashKey,
|
||||
RuleHash_CIMatchEntry,
|
||||
RuleHash_MoveEntry,
|
||||
@ -418,6 +428,8 @@ static const RuleHashTableOps RuleHash_IdTable_CIOps = {
|
||||
};
|
||||
|
||||
static const PLDHashTableOps RuleHash_NameSpaceTable_Ops = {
|
||||
PL_DHashAllocTable,
|
||||
PL_DHashFreeTable,
|
||||
RuleHash_NameSpaceTable_HashKey,
|
||||
RuleHash_NameSpaceTable_MatchEntry,
|
||||
RuleHash_MoveEntry,
|
||||
@ -875,6 +887,8 @@ AtomSelector_GetKey(PLDHashTable *table, const PLDHashEntryHdr *hdr)
|
||||
|
||||
// Case-sensitive ops.
|
||||
static const PLDHashTableOps AtomSelector_CSOps = {
|
||||
PL_DHashAllocTable,
|
||||
PL_DHashFreeTable,
|
||||
PL_DHashVoidPtrKeyStub,
|
||||
PL_DHashMatchEntryStub,
|
||||
AtomSelector_MoveEntry,
|
||||
@ -885,6 +899,8 @@ static const PLDHashTableOps AtomSelector_CSOps = {
|
||||
// Case-insensitive ops.
|
||||
static const RuleHashTableOps AtomSelector_CIOps = {
|
||||
{
|
||||
PL_DHashAllocTable,
|
||||
PL_DHashFreeTable,
|
||||
RuleHash_CIHashKey,
|
||||
RuleHash_CIMatchEntry,
|
||||
AtomSelector_MoveEntry,
|
||||
@ -3321,6 +3337,8 @@ InitWeightEntry(PLDHashTable *table, PLDHashEntryHdr *hdr,
|
||||
}
|
||||
|
||||
static const PLDHashTableOps gRulesByWeightOps = {
|
||||
PL_DHashAllocTable,
|
||||
PL_DHashFreeTable,
|
||||
HashIntKey,
|
||||
MatchWeightEntry,
|
||||
PL_DHashMoveEntryStub,
|
||||
|
@ -169,6 +169,8 @@ MappedAttrTable_MatchEntry(PLDHashTable *table, const PLDHashEntryHdr *hdr,
|
||||
}
|
||||
|
||||
static const PLDHashTableOps MappedAttrTable_Ops = {
|
||||
PL_DHashAllocTable,
|
||||
PL_DHashFreeTable,
|
||||
MappedAttrTable_HashKey,
|
||||
MappedAttrTable_MatchEntry,
|
||||
PL_DHashMoveEntryStub,
|
||||
@ -223,6 +225,8 @@ LangRuleTable_InitEntry(PLDHashTable *table, PLDHashEntryHdr *hdr,
|
||||
}
|
||||
|
||||
static const PLDHashTableOps LangRuleTable_Ops = {
|
||||
PL_DHashAllocTable,
|
||||
PL_DHashFreeTable,
|
||||
LangRuleTable_HashKey,
|
||||
LangRuleTable_MatchEntry,
|
||||
PL_DHashMoveEntryStub,
|
||||
|
@ -114,6 +114,8 @@ nsRuleNode::ChildrenHashOps = {
|
||||
// free rather than the pres shell's arena because the table doesn't
|
||||
// grow very often and the pres shell's arena doesn't recycle very
|
||||
// large size allocations.
|
||||
PL_DHashAllocTable,
|
||||
PL_DHashFreeTable,
|
||||
ChildrenHashHashKey,
|
||||
ChildrenHashMatchEntry,
|
||||
PL_DHashMoveEntryStub,
|
||||
|
@ -33,6 +33,8 @@ SpanningCellSorter::~SpanningCellSorter()
|
||||
|
||||
/* static */ const PLDHashTableOps
|
||||
SpanningCellSorter::HashTableOps = {
|
||||
PL_DHashAllocTable,
|
||||
PL_DHashFreeTable,
|
||||
HashTableHashKey,
|
||||
HashTableMatchEntry,
|
||||
PL_DHashMoveEntryStub,
|
||||
|
@ -77,6 +77,8 @@ static bool gShouldCleanupDeadNodes = false;
|
||||
|
||||
|
||||
static PLDHashTableOps pref_HashTableOps = {
|
||||
PL_DHashAllocTable,
|
||||
PL_DHashFreeTable,
|
||||
PL_DHashStringKey,
|
||||
matchPrefEntry,
|
||||
PL_DHashMoveEntryStub,
|
||||
|
@ -1156,6 +1156,8 @@ nsresult nsLoadGroup::Init()
|
||||
{
|
||||
static const PLDHashTableOps hash_table_ops =
|
||||
{
|
||||
PL_DHashAllocTable,
|
||||
PL_DHashFreeTable,
|
||||
PL_DHashVoidPtrKeyStub,
|
||||
RequestHashMatchEntry,
|
||||
PL_DHashMoveEntryStub,
|
||||
|
2
netwerk/cache/nsCacheEntry.cpp
vendored
2
netwerk/cache/nsCacheEntry.cpp
vendored
@ -377,6 +377,8 @@ nsCacheEntryInfo::IsStreamBased(bool * result)
|
||||
const PLDHashTableOps
|
||||
nsCacheEntryHashTable::ops =
|
||||
{
|
||||
PL_DHashAllocTable,
|
||||
PL_DHashFreeTable,
|
||||
HashKey,
|
||||
MatchEntry,
|
||||
MoveEntry,
|
||||
|
2
netwerk/cache/nsDiskCacheBinding.cpp
vendored
2
netwerk/cache/nsDiskCacheBinding.cpp
vendored
@ -124,6 +124,8 @@ nsDiskCacheBinding::EnsureStreamIO()
|
||||
|
||||
const PLDHashTableOps nsDiskCacheBindery::ops =
|
||||
{
|
||||
PL_DHashAllocTable,
|
||||
PL_DHashFreeTable,
|
||||
HashKey,
|
||||
MatchEntry,
|
||||
MoveEntry,
|
||||
|
@ -463,6 +463,8 @@ HostDB_InitEntry(PLDHashTable *table,
|
||||
|
||||
static const PLDHashTableOps gHostDB_ops =
|
||||
{
|
||||
PL_DHashAllocTable,
|
||||
PL_DHashFreeTable,
|
||||
HostDB_HashKey,
|
||||
HostDB_MatchEntry,
|
||||
HostDB_MoveEntry,
|
||||
|
@ -42,7 +42,7 @@ struct HttpHeapAtom {
|
||||
char value[1];
|
||||
};
|
||||
|
||||
static PLDHashTable sAtomTable;
|
||||
static struct PLDHashTable sAtomTable;
|
||||
static struct HttpHeapAtom *sHeapAtoms = nullptr;
|
||||
static Mutex *sLock = nullptr;
|
||||
|
||||
@ -85,6 +85,8 @@ StringCompare(PLDHashTable *table, const PLDHashEntryHdr *entry,
|
||||
}
|
||||
|
||||
static const PLDHashTableOps ops = {
|
||||
PL_DHashAllocTable,
|
||||
PL_DHashFreeTable,
|
||||
StringHash,
|
||||
StringCompare,
|
||||
PL_DHashMoveEntryStub,
|
||||
|
@ -52,6 +52,8 @@ static PLDHashNumber
|
||||
|
||||
|
||||
static const PLDHashTableOps EntityToUnicodeOps = {
|
||||
PL_DHashAllocTable,
|
||||
PL_DHashFreeTable,
|
||||
PL_DHashStringKey,
|
||||
matchNodeString,
|
||||
PL_DHashMoveEntryStub,
|
||||
@ -60,6 +62,8 @@ static const PLDHashTableOps EntityToUnicodeOps = {
|
||||
};
|
||||
|
||||
static const PLDHashTableOps UnicodeToEntityOps = {
|
||||
PL_DHashAllocTable,
|
||||
PL_DHashFreeTable,
|
||||
hashUnicodeValue,
|
||||
matchNodeUnicode,
|
||||
PL_DHashMoveEntryStub,
|
||||
|
@ -140,6 +140,8 @@ struct ResourceHashEntry : public PLDHashEntryHdr {
|
||||
};
|
||||
|
||||
static const PLDHashTableOps gResourceTableOps = {
|
||||
PL_DHashAllocTable,
|
||||
PL_DHashFreeTable,
|
||||
ResourceHashEntry::HashKey,
|
||||
ResourceHashEntry::MatchEntry,
|
||||
PL_DHashMoveEntryStub,
|
||||
@ -175,6 +177,8 @@ struct LiteralHashEntry : public PLDHashEntryHdr {
|
||||
};
|
||||
|
||||
static const PLDHashTableOps gLiteralTableOps = {
|
||||
PL_DHashAllocTable,
|
||||
PL_DHashFreeTable,
|
||||
LiteralHashEntry::HashKey,
|
||||
LiteralHashEntry::MatchEntry,
|
||||
PL_DHashMoveEntryStub,
|
||||
@ -209,6 +213,8 @@ struct IntHashEntry : public PLDHashEntryHdr {
|
||||
};
|
||||
|
||||
static const PLDHashTableOps gIntTableOps = {
|
||||
PL_DHashAllocTable,
|
||||
PL_DHashFreeTable,
|
||||
IntHashEntry::HashKey,
|
||||
IntHashEntry::MatchEntry,
|
||||
PL_DHashMoveEntryStub,
|
||||
@ -247,6 +253,8 @@ struct DateHashEntry : public PLDHashEntryHdr {
|
||||
};
|
||||
|
||||
static const PLDHashTableOps gDateTableOps = {
|
||||
PL_DHashAllocTable,
|
||||
PL_DHashFreeTable,
|
||||
DateHashEntry::HashKey,
|
||||
DateHashEntry::MatchEntry,
|
||||
PL_DHashMoveEntryStub,
|
||||
@ -364,6 +372,8 @@ struct BlobHashEntry : public PLDHashEntryHdr {
|
||||
};
|
||||
|
||||
static const PLDHashTableOps gBlobTableOps = {
|
||||
PL_DHashAllocTable,
|
||||
PL_DHashFreeTable,
|
||||
BlobHashEntry::HashKey,
|
||||
BlobHashEntry::MatchEntry,
|
||||
PL_DHashMoveEntryStub,
|
||||
|
@ -80,6 +80,8 @@ RequestMapInitEntry(PLDHashTable *table, PLDHashEntryHdr *hdr,
|
||||
}
|
||||
|
||||
static const PLDHashTableOps gMapOps = {
|
||||
PL_DHashAllocTable,
|
||||
PL_DHashFreeTable,
|
||||
PL_DHashVoidPtrKeyStub,
|
||||
RequestMapMatchEntry,
|
||||
PL_DHashMoveEntryStub,
|
||||
|
@ -92,6 +92,8 @@ CompareCacheClearEntry(PLDHashTable *table, PLDHashEntryHdr *hdr)
|
||||
}
|
||||
|
||||
static const PLDHashTableOps gMapOps = {
|
||||
PL_DHashAllocTable,
|
||||
PL_DHashFreeTable,
|
||||
PL_DHashVoidPtrKeyStub,
|
||||
CompareCacheMatchEntry,
|
||||
PL_DHashMoveEntryStub,
|
||||
|
@ -33,6 +33,8 @@ ObjectSetInitEntry(PLDHashTable *table, PLDHashEntryHdr *hdr,
|
||||
}
|
||||
|
||||
static const PLDHashTableOps gSetOps = {
|
||||
PL_DHashAllocTable,
|
||||
PL_DHashFreeTable,
|
||||
PL_DHashVoidPtrKeyStub,
|
||||
ObjectSetMatchEntry,
|
||||
PL_DHashMoveEntryStub,
|
||||
|
@ -114,6 +114,8 @@ nsDocLoader::nsDocLoader()
|
||||
|
||||
static const PLDHashTableOps hash_table_ops =
|
||||
{
|
||||
PL_DHashAllocTable,
|
||||
PL_DHashFreeTable,
|
||||
PL_DHashVoidPtrKeyStub,
|
||||
PL_DHashMatchEntryStub,
|
||||
PL_DHashMoveEntryStub,
|
||||
|
@ -801,6 +801,8 @@ PtrToNodeMatchEntry(PLDHashTable* aTable,
|
||||
}
|
||||
|
||||
static PLDHashTableOps PtrNodeOps = {
|
||||
PL_DHashAllocTable,
|
||||
PL_DHashFreeTable,
|
||||
PL_DHashVoidPtrKeyStub,
|
||||
PtrToNodeMatchEntry,
|
||||
PL_DHashMoveEntryStub,
|
||||
|
@ -288,6 +288,8 @@ AtomTableInitEntry(PLDHashTable* aTable, PLDHashEntryHdr* aEntry,
|
||||
|
||||
|
||||
static const PLDHashTableOps AtomTableOps = {
|
||||
PL_DHashAllocTable,
|
||||
PL_DHashFreeTable,
|
||||
AtomTableGetHash,
|
||||
AtomTableMatchKey,
|
||||
PL_DHashMoveEntryStub,
|
||||
|
@ -50,6 +50,8 @@ ArenaStrdup(const nsAFlatCString& aString, PLArenaPool* aArena)
|
||||
}
|
||||
|
||||
static const struct PLDHashTableOps property_HashTableOps = {
|
||||
PL_DHashAllocTable,
|
||||
PL_DHashFreeTable,
|
||||
PL_DHashStringKey,
|
||||
PL_DHashMatchStringKey,
|
||||
PL_DHashMoveEntryStub,
|
||||
|
@ -33,7 +33,7 @@ protected:
|
||||
nsCOMPtr<nsIUnicharInputStream> mIn;
|
||||
|
||||
nsIPersistentProperties* mSubclass;
|
||||
PLDHashTable mTable;
|
||||
struct PLDHashTable mTable;
|
||||
PLArenaPool mArena;
|
||||
};
|
||||
|
||||
|
@ -94,6 +94,8 @@ caseInsensitiveStringHashKey(PLDHashTable* aTable, const void* aKey)
|
||||
}
|
||||
|
||||
static const struct PLDHashTableOps nametable_CaseInsensitiveHashTableOps = {
|
||||
PL_DHashAllocTable,
|
||||
PL_DHashFreeTable,
|
||||
caseInsensitiveStringHashKey,
|
||||
matchNameKeysCaseInsensitive,
|
||||
PL_DHashMoveEntryStub,
|
||||
|
@ -419,6 +419,8 @@ nsTHashtable<EntryType>::Init(uint32_t aInitLength)
|
||||
{
|
||||
static const PLDHashTableOps sOps =
|
||||
{
|
||||
::PL_DHashAllocTable,
|
||||
::PL_DHashFreeTable,
|
||||
s_HashKey,
|
||||
s_MatchEntry,
|
||||
EntryType::ALLOW_MEMMOVE ? ::PL_DHashMoveEntryStub : s_CopyEntry,
|
||||
|
@ -68,6 +68,18 @@
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
void*
|
||||
PL_DHashAllocTable(PLDHashTable* aTable, uint32_t aNBytes)
|
||||
{
|
||||
return malloc(aNBytes);
|
||||
}
|
||||
|
||||
void
|
||||
PL_DHashFreeTable(PLDHashTable* aTable, void* aPtr)
|
||||
{
|
||||
free(aPtr);
|
||||
}
|
||||
|
||||
PLDHashNumber
|
||||
PL_DHashStringKey(PLDHashTable* aTable, const void* aKey)
|
||||
{
|
||||
@ -146,6 +158,8 @@ PL_DHashFreeStringKey(PLDHashTable* aTable, PLDHashEntryHdr* aEntry)
|
||||
}
|
||||
|
||||
static const PLDHashTableOps stub_ops = {
|
||||
PL_DHashAllocTable,
|
||||
PL_DHashFreeTable,
|
||||
PL_DHashVoidPtrKeyStub,
|
||||
PL_DHashMatchEntryStub,
|
||||
PL_DHashMoveEntryStub,
|
||||
@ -171,13 +185,13 @@ PLDHashTable*
|
||||
PL_NewDHashTable(const PLDHashTableOps* aOps, uint32_t aEntrySize,
|
||||
uint32_t aLength)
|
||||
{
|
||||
PLDHashTable* table = (PLDHashTable*)malloc(sizeof(*table));
|
||||
PLDHashTable* table = (PLDHashTable*)aOps->allocTable(NULL, sizeof(*table));
|
||||
|
||||
if (!table) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!PL_DHashTableInit(table, aOps, aEntrySize, fallible_t(), aLength)) {
|
||||
free(table);
|
||||
aOps->freeTable(NULL, table);
|
||||
return nullptr;
|
||||
}
|
||||
return table;
|
||||
@ -187,7 +201,7 @@ void
|
||||
PL_DHashTableDestroy(PLDHashTable* aTable)
|
||||
{
|
||||
PL_DHashTableFinish(aTable);
|
||||
free(aTable);
|
||||
aTable->ops->freeTable(NULL, aTable);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -249,7 +263,7 @@ PLDHashTable::Init(const PLDHashTableOps* aOps,
|
||||
return false; // overflowed
|
||||
}
|
||||
|
||||
mEntryStore = (char*)malloc(nbytes);
|
||||
mEntryStore = (char*)aOps->allocTable(this, nbytes);
|
||||
if (!mEntryStore) {
|
||||
return false;
|
||||
}
|
||||
@ -338,7 +352,7 @@ PLDHashTable::Finish()
|
||||
MOZ_ASSERT(RECURSION_LEVEL_SAFE_TO_FINISH(this));
|
||||
|
||||
/* Free entry storage last. */
|
||||
free(mEntryStore);
|
||||
ops->freeTable(this, mEntryStore);
|
||||
}
|
||||
|
||||
void
|
||||
@ -481,7 +495,7 @@ PLDHashTable::ChangeTable(int aDeltaLog2)
|
||||
return false; // overflowed
|
||||
}
|
||||
|
||||
char* newEntryStore = (char*)malloc(nbytes);
|
||||
char* newEntryStore = (char*)ops->allocTable(this, nbytes);
|
||||
if (!newEntryStore) {
|
||||
return false;
|
||||
}
|
||||
@ -520,7 +534,7 @@ PLDHashTable::ChangeTable(int aDeltaLog2)
|
||||
oldEntryAddr += mEntrySize;
|
||||
}
|
||||
|
||||
free(oldEntryStore);
|
||||
ops->freeTable(this, oldEntryStore);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -53,10 +53,12 @@
|
||||
#define PL_DHASH_BITS 32
|
||||
#define PL_DHASH_GOLDEN_RATIO 0x9E3779B9U
|
||||
|
||||
typedef uint32_t PLDHashNumber;
|
||||
|
||||
class PLDHashTable;
|
||||
struct PLDHashTableOps;
|
||||
/* Primitive and forward-struct typedefs. */
|
||||
typedef uint32_t PLDHashNumber;
|
||||
typedef struct PLDHashEntryHdr PLDHashEntryHdr;
|
||||
typedef struct PLDHashEntryStub PLDHashEntryStub;
|
||||
typedef struct PLDHashTable PLDHashTable;
|
||||
typedef struct PLDHashTableOps PLDHashTableOps;
|
||||
|
||||
/*
|
||||
* Table entry header structure.
|
||||
@ -174,9 +176,8 @@ typedef size_t (*PLDHashSizeOfEntryExcludingThisFun)(
|
||||
* aTable->mGeneration before adding or removing, and compare the sample after,
|
||||
* dereferencing the entry pointer only if aTable->mGeneration has not changed.
|
||||
*/
|
||||
class PLDHashTable
|
||||
struct PLDHashTable
|
||||
{
|
||||
public:
|
||||
/*
|
||||
* Virtual operations; see below. This field is public because it's commonly
|
||||
* zeroed to indicate that a table is no longer live.
|
||||
@ -299,6 +300,15 @@ private:
|
||||
bool ChangeTable(int aDeltaLog2);
|
||||
};
|
||||
|
||||
/*
|
||||
* Table space at mEntryStore is allocated and freed using these callbacks.
|
||||
* The allocator should return null on error only (not if called with aNBytes
|
||||
* equal to 0; but note that pldhash.c code will never call with 0 aNBytes).
|
||||
*/
|
||||
typedef void* (*PLDHashAllocTable)(PLDHashTable* aTable, uint32_t aNBytes);
|
||||
|
||||
typedef void (*PLDHashFreeTable)(PLDHashTable* aTable, void* aPtr);
|
||||
|
||||
/*
|
||||
* Compute the hash code for a given key to be looked up, added, or removed
|
||||
* from aTable. A hash code may have any PLDHashNumber value.
|
||||
@ -343,11 +353,13 @@ typedef bool (*PLDHashInitEntry)(PLDHashTable* aTable, PLDHashEntryHdr* aEntry,
|
||||
const void* aKey);
|
||||
|
||||
/*
|
||||
* Finally, the "vtable" structure for PLDHashTable. The first four hooks
|
||||
* Finally, the "vtable" structure for PLDHashTable. The first six hooks
|
||||
* must be provided by implementations; they're called unconditionally by the
|
||||
* generic pldhash.c code. Hooks after these may be null.
|
||||
*
|
||||
* Summary of allocation-related hook usage with C++ placement new emphasis:
|
||||
* allocTable Allocate raw bytes with malloc, no ctors run.
|
||||
* freeTable Free raw bytes with free, no dtors run.
|
||||
* initEntry Call placement new using default key-based ctor.
|
||||
* Return true on success, false on error.
|
||||
* moveEntry Call placement new using copy ctor, run dtor on old
|
||||
@ -368,6 +380,8 @@ typedef bool (*PLDHashInitEntry)(PLDHashTable* aTable, PLDHashEntryHdr* aEntry,
|
||||
struct PLDHashTableOps
|
||||
{
|
||||
/* Mandatory hooks. All implementations must provide these. */
|
||||
PLDHashAllocTable allocTable;
|
||||
PLDHashFreeTable freeTable;
|
||||
PLDHashHashKey hashKey;
|
||||
PLDHashMatchEntry matchEntry;
|
||||
PLDHashMoveEntry moveEntry;
|
||||
@ -380,6 +394,9 @@ struct PLDHashTableOps
|
||||
/*
|
||||
* Default implementations for the above ops.
|
||||
*/
|
||||
void* PL_DHashAllocTable(PLDHashTable* aTable, uint32_t aNBytes);
|
||||
|
||||
void PL_DHashFreeTable(PLDHashTable* aTable, void* aPtr);
|
||||
|
||||
PLDHashNumber PL_DHashStringKey(PLDHashTable* aTable, const void* aKey);
|
||||
|
||||
@ -417,8 +434,10 @@ void PL_DHashFreeStringKey(PLDHashTable* aTable, PLDHashEntryHdr* aEntry);
|
||||
const PLDHashTableOps* PL_DHashGetStubOps(void);
|
||||
|
||||
/*
|
||||
* Dynamically allocate a new PLDHashTable, initialize it using
|
||||
* PL_DHashTableInit, and return its address. Return null on allocation failure.
|
||||
* Dynamically allocate a new PLDHashTable using malloc, initialize it using
|
||||
* PL_DHashTableInit, and return its address. Return null on malloc failure.
|
||||
* Note that the entry storage at aTable->mEntryStore will be allocated using
|
||||
* the aOps->allocTable callback.
|
||||
*/
|
||||
PLDHashTable* PL_NewDHashTable(
|
||||
const PLDHashTableOps* aOps, uint32_t aEntrySize,
|
||||
@ -472,9 +491,9 @@ void PL_DHashTableFinish(PLDHashTable* aTable);
|
||||
* entry = PL_DHashTableOperate(table, key, PL_DHASH_ADD);
|
||||
*
|
||||
* If entry is null upon return, then either the table is severely overloaded,
|
||||
* and memory can't be allocated for entry storage. Or if
|
||||
* aTable->ops->initEntry is non-null, the aTable->ops->initEntry op may have
|
||||
* returned false.
|
||||
* and memory can't be allocated for entry storage via aTable->ops->allocTable;
|
||||
* Or if aTable->ops->initEntry is non-null, the aTable->ops->initEntry op may
|
||||
* have returned false.
|
||||
*
|
||||
* Otherwise, aEntry->keyHash has been set so that PL_DHASH_ENTRY_IS_BUSY(entry)
|
||||
* is true, and it is up to the caller to initialize the key and value parts
|
||||
|
@ -80,6 +80,8 @@ hash(PLDHashTable *table, const void *key)
|
||||
static bool test_pldhash_grow_to_max_capacity()
|
||||
{
|
||||
static const PLDHashTableOps ops = {
|
||||
PL_DHashAllocTable,
|
||||
PL_DHashFreeTable,
|
||||
hash,
|
||||
PL_DHashMatchEntryStub,
|
||||
PL_DHashMoveEntryStub,
|
||||
|
Loading…
Reference in New Issue
Block a user