Bug 1074961 - Part 1: use more generic names for the members of ChunkPool; r=sfink

--HG--
extra : rebase_source : c44d91125cf48e7f34fb92cd04670bac9247b0c2
This commit is contained in:
Terrence Cole 2014-10-01 12:17:41 -07:00
parent 21d908c3c9
commit 237f6f59f5
2 changed files with 21 additions and 26 deletions

View File

@ -36,18 +36,13 @@ class AutoTraceSession;
class ChunkPool
{
Chunk *emptyChunkListHead;
size_t emptyCount;
Chunk *head_;
size_t count_;
public:
ChunkPool()
: emptyChunkListHead(nullptr),
emptyCount(0)
{}
ChunkPool() : head_(nullptr), count_(0) {}
size_t getEmptyCount() const {
return emptyCount;
}
size_t count() const { return count_; }
/* Must be called with the GC lock taken. */
inline Chunk *get(JSRuntime *rt);
@ -57,7 +52,7 @@ class ChunkPool
class Enum {
public:
explicit Enum(ChunkPool &pool) : pool(pool), chunkp(&pool.emptyChunkListHead) {}
explicit Enum(ChunkPool &pool) : pool(pool), chunkp(&pool.head_) {}
bool empty() { return !*chunkp; }
Chunk *front();
inline void popFront();

View File

@ -663,15 +663,15 @@ FreeChunk(JSRuntime *rt, Chunk *p)
inline Chunk *
ChunkPool::get(JSRuntime *rt)
{
Chunk *chunk = emptyChunkListHead;
Chunk *chunk = head_;
if (!chunk) {
MOZ_ASSERT(!emptyCount);
MOZ_ASSERT(!count_);
return nullptr;
}
MOZ_ASSERT(emptyCount);
emptyChunkListHead = chunk->info.next;
--emptyCount;
MOZ_ASSERT(count_);
head_ = chunk->info.next;
--count_;
return chunk;
}
@ -680,16 +680,16 @@ inline void
ChunkPool::put(Chunk *chunk)
{
chunk->info.age = 0;
chunk->info.next = emptyChunkListHead;
emptyChunkListHead = chunk;
emptyCount++;
chunk->info.next = head_;
head_ = chunk;
count_++;
}
inline Chunk *
ChunkPool::Enum::front()
{
Chunk *chunk = *chunkp;
MOZ_ASSERT_IF(chunk, pool.getEmptyCount() != 0);
MOZ_ASSERT_IF(chunk, pool.count() != 0);
return chunk;
}
@ -705,7 +705,7 @@ ChunkPool::Enum::removeAndPopFront()
{
MOZ_ASSERT(!empty());
*chunkp = front()->info.next;
--pool.emptyCount;
--pool.count_;
}
/* Must be called either during the GC or with the GC lock taken. */
@ -739,9 +739,9 @@ GCRuntime::expireChunkPool(bool shrinkBuffers, bool releaseAll)
e.popFront();
}
}
MOZ_ASSERT(chunkPool.getEmptyCount() <= tunables.maxEmptyChunkCount());
MOZ_ASSERT_IF(shrinkBuffers, chunkPool.getEmptyCount() <= tunables.minEmptyChunkCount());
MOZ_ASSERT_IF(releaseAll, chunkPool.getEmptyCount() == 0);
MOZ_ASSERT(chunkPool.count() <= tunables.maxEmptyChunkCount());
MOZ_ASSERT_IF(shrinkBuffers, chunkPool.count() <= tunables.minEmptyChunkCount());
MOZ_ASSERT_IF(releaseAll, chunkPool.count() == 0);
return freeList;
}
@ -1049,7 +1049,7 @@ GCRuntime::wantBackgroundAllocation() const
* of them.
*/
return helperState.canBackgroundAllocate() &&
chunkPool.getEmptyCount() < tunables.minEmptyChunkCount() &&
chunkPool.count() < tunables.minEmptyChunkCount() &&
chunkSet.count() >= 4;
}
@ -1512,9 +1512,9 @@ GCRuntime::getParameter(JSGCParamKey key)
case JSGC_MODE:
return uint32_t(mode);
case JSGC_UNUSED_CHUNKS:
return uint32_t(chunkPool.getEmptyCount());
return uint32_t(chunkPool.count());
case JSGC_TOTAL_CHUNKS:
return uint32_t(chunkSet.count() + chunkPool.getEmptyCount());
return uint32_t(chunkSet.count() + chunkPool.count());
case JSGC_SLICE_TIME_BUDGET:
return uint32_t(sliceBudget > 0 ? sliceBudget / PRMJ_USEC_PER_MSEC : 0);
case JSGC_MARK_STACK_LIMIT: