Bug 964214 - Don't recompact store buffer if there are no new entries r=terrence

This commit is contained in:
Jon Coppeard 2014-01-28 10:37:14 +00:00
parent 85d06f4fde
commit c9edbd1aee
2 changed files with 18 additions and 5 deletions

View File

@ -110,10 +110,18 @@ template <typename T>
void
StoreBuffer::MonoTypeBuffer<T>::compact(StoreBuffer *owner)
{
if (!storage_)
return;
JS_ASSERT(storage_);
compactRemoveDuplicates(owner);
usedAtLastCompact_ = storage_->used();
}
template <typename T>
void
StoreBuffer::MonoTypeBuffer<T>::maybeCompact(StoreBuffer *owner)
{
JS_ASSERT(storage_);
if (storage_->used() != usedAtLastCompact_)
compact(owner);
}
template <typename T>
@ -125,7 +133,7 @@ StoreBuffer::MonoTypeBuffer<T>::mark(StoreBuffer *owner, JSTracer *trc)
if (!storage_)
return;
compact(owner);
maybeCompact(owner);
for (LifoAlloc::Enum e(*storage_); !e.empty(); e.popFront<T>()) {
T *edge = e.get<T>();
if (edge->isNullEdge())

View File

@ -91,8 +91,9 @@ class StoreBuffer
struct MonoTypeBuffer
{
LifoAlloc *storage_;
size_t usedAtLastCompact_;
explicit MonoTypeBuffer() : storage_(nullptr) {}
explicit MonoTypeBuffer() : storage_(nullptr), usedAtLastCompact_(0) {}
~MonoTypeBuffer() { js_delete(storage_); }
bool init() {
@ -107,6 +108,7 @@ class StoreBuffer
return;
storage_->used() ? storage_->releaseAll() : storage_->freeAll();
usedAtLastCompact_ = 0;
}
bool isAboutToOverflow() const {
@ -122,6 +124,9 @@ class StoreBuffer
*/
virtual void compact(StoreBuffer *owner);
/* Compacts if any entries have been added since the last compaction. */
void maybeCompact(StoreBuffer *owner);
/* Add one item to the buffer. */
void put(StoreBuffer *owner, const T &t) {
JS_ASSERT(storage_);