зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1136046 - Increase maximum capacity of js::HashMap and HashSet r=luke
This commit is contained in:
Родитель
4cee6e7d5f
Коммит
8db99543e5
|
@ -1013,14 +1013,14 @@ class HashTable : private AllocPolicy
|
||||||
void operator=(const HashTable &) = delete;
|
void operator=(const HashTable &) = delete;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const size_t CAP_BITS = 24;
|
static const size_t CAP_BITS = 30;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Entry *table; // entry storage
|
Entry *table; // entry storage
|
||||||
uint32_t gen; // entry storage generation number
|
uint32_t gen:24; // entry storage generation number
|
||||||
uint32_t entryCount; // number of entries in table
|
|
||||||
uint32_t removedCount:CAP_BITS; // removed entry sentinels in table
|
|
||||||
uint32_t hashShift:8; // multiplicative hash shift
|
uint32_t hashShift:8; // multiplicative hash shift
|
||||||
|
uint32_t entryCount; // number of entries in table
|
||||||
|
uint32_t removedCount; // removed entry sentinels in table
|
||||||
|
|
||||||
#ifdef JS_DEBUG
|
#ifdef JS_DEBUG
|
||||||
uint64_t mutationCount;
|
uint64_t mutationCount;
|
||||||
|
@ -1088,8 +1088,6 @@ class HashTable : private AllocPolicy
|
||||||
{
|
{
|
||||||
static_assert(sFreeKey == 0,
|
static_assert(sFreeKey == 0,
|
||||||
"newly-calloc'd tables have to be considered empty");
|
"newly-calloc'd tables have to be considered empty");
|
||||||
static_assert(sMaxCapacity <= SIZE_MAX / sizeof(Entry),
|
|
||||||
"would overflow allocating max number of entries");
|
|
||||||
return alloc.template pod_calloc<Entry>(capacity);
|
return alloc.template pod_calloc<Entry>(capacity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1105,9 +1103,9 @@ class HashTable : private AllocPolicy
|
||||||
: AllocPolicy(ap)
|
: AllocPolicy(ap)
|
||||||
, table(nullptr)
|
, table(nullptr)
|
||||||
, gen(0)
|
, gen(0)
|
||||||
|
, hashShift(sHashBits)
|
||||||
, entryCount(0)
|
, entryCount(0)
|
||||||
, removedCount(0)
|
, removedCount(0)
|
||||||
, hashShift(sHashBits)
|
|
||||||
#ifdef JS_DEBUG
|
#ifdef JS_DEBUG
|
||||||
, mutationCount(0)
|
, mutationCount(0)
|
||||||
, mEntered(false)
|
, mEntered(false)
|
||||||
|
|
|
@ -45,7 +45,6 @@ UNIFIED_SOURCES += [
|
||||||
'testGCStoreBufferRemoval.cpp',
|
'testGCStoreBufferRemoval.cpp',
|
||||||
'testGetPropertyDescriptor.cpp',
|
'testGetPropertyDescriptor.cpp',
|
||||||
'testHashTable.cpp',
|
'testHashTable.cpp',
|
||||||
'testHashTableInit.cpp',
|
|
||||||
'testIndexToString.cpp',
|
'testIndexToString.cpp',
|
||||||
'testIntern.cpp',
|
'testIntern.cpp',
|
||||||
'testIntString.cpp',
|
'testIntString.cpp',
|
||||||
|
|
|
@ -1,26 +0,0 @@
|
||||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
||||||
|
|
||||||
#include "js/HashTable.h"
|
|
||||||
#include "jsapi-tests/tests.h"
|
|
||||||
|
|
||||||
typedef js::HashSet<uint32_t, js::DefaultHasher<uint32_t>, js::SystemAllocPolicy> IntSet;
|
|
||||||
|
|
||||||
static const uint32_t MaxAllowedHashInit = 1 << 23;
|
|
||||||
|
|
||||||
BEGIN_TEST(testHashInitAlmostTooHuge)
|
|
||||||
{
|
|
||||||
IntSet smallEnough;
|
|
||||||
CHECK(smallEnough.init(MaxAllowedHashInit));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
END_TEST(testHashInitAlmostTooHuge)
|
|
||||||
|
|
||||||
BEGIN_TEST(testHashInitTooHuge)
|
|
||||||
{
|
|
||||||
IntSet tooBig;
|
|
||||||
CHECK(!tooBig.init(MaxAllowedHashInit + 1));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
END_TEST(testHashInitTooHuge)
|
|
Загрузка…
Ссылка в новой задаче