зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1477626 - Replace some bespoke code with a call to CeilingLog2(). r=Waldo
After all, bug 543034 was fixed 9 years ago. MozReview-Commit-ID: HDPO3gGuQMx --HG-- extra : rebase_source : 6a1410c30e63f2ea5a4f918ba932b814d50c34dd
This commit is contained in:
Родитель
674efd0cee
Коммит
049d8130b0
|
@ -11,6 +11,7 @@
|
||||||
#include "mozilla/Attributes.h"
|
#include "mozilla/Attributes.h"
|
||||||
#include "mozilla/Casting.h"
|
#include "mozilla/Casting.h"
|
||||||
#include "mozilla/HashFunctions.h"
|
#include "mozilla/HashFunctions.h"
|
||||||
|
#include "mozilla/MathAlgorithms.h"
|
||||||
#include "mozilla/MemoryChecking.h"
|
#include "mozilla/MemoryChecking.h"
|
||||||
#include "mozilla/MemoryReporting.h"
|
#include "mozilla/MemoryReporting.h"
|
||||||
#include "mozilla/Move.h"
|
#include "mozilla/Move.h"
|
||||||
|
@ -1253,8 +1254,7 @@ class HashTable : private AllocPolicy
|
||||||
|
|
||||||
// The default initial capacity is 32 (enough to hold 16 elements), but it
|
// The default initial capacity is 32 (enough to hold 16 elements), but it
|
||||||
// can be as low as 4.
|
// can be as low as 4.
|
||||||
static const unsigned sMinCapacityLog2 = 2;
|
static const unsigned sMinCapacity = 4;
|
||||||
static const unsigned sMinCapacity = 1 << sMinCapacityLog2;
|
|
||||||
static const unsigned sMaxInit = JS_BIT(CAP_BITS - 1);
|
static const unsigned sMaxInit = JS_BIT(CAP_BITS - 1);
|
||||||
static const unsigned sMaxCapacity = JS_BIT(CAP_BITS);
|
static const unsigned sMaxCapacity = JS_BIT(CAP_BITS);
|
||||||
static const unsigned sHashBits = mozilla::tl::BitSize<HashNumber>::value;
|
static const unsigned sHashBits = mozilla::tl::BitSize<HashNumber>::value;
|
||||||
|
@ -1361,14 +1361,10 @@ class HashTable : private AllocPolicy
|
||||||
if (newCapacity < sMinCapacity)
|
if (newCapacity < sMinCapacity)
|
||||||
newCapacity = sMinCapacity;
|
newCapacity = sMinCapacity;
|
||||||
|
|
||||||
// FIXME: use JS_CEILING_LOG2 when PGO stops crashing (bug 543034).
|
// Round up capacity to next power-of-two.
|
||||||
uint32_t roundUp = sMinCapacity, roundUpLog2 = sMinCapacityLog2;
|
uint32_t log2 = mozilla::CeilingLog2(newCapacity);
|
||||||
while (roundUp < newCapacity) {
|
newCapacity = 1u << log2;
|
||||||
roundUp <<= 1;
|
|
||||||
++roundUpLog2;
|
|
||||||
}
|
|
||||||
|
|
||||||
newCapacity = roundUp;
|
|
||||||
MOZ_ASSERT(newCapacity >= length);
|
MOZ_ASSERT(newCapacity >= length);
|
||||||
MOZ_ASSERT(newCapacity <= sMaxCapacity);
|
MOZ_ASSERT(newCapacity <= sMaxCapacity);
|
||||||
|
|
||||||
|
@ -1376,7 +1372,7 @@ class HashTable : private AllocPolicy
|
||||||
if (!table)
|
if (!table)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
setTableSizeLog2(roundUpLog2);
|
setTableSizeLog2(log2);
|
||||||
METER(memset(&stats, 0, sizeof(stats)));
|
METER(memset(&stats, 0, sizeof(stats)));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче