+2014-09-11 Geoffrey Garen <ggaren@apple.com>
+
+ bmalloc: eager scavenge leaves behind a bogus allocator
+ https://bugs.webkit.org/show_bug.cgi?id=136743
+
+ Reviewed by Sam Weinig.
+
+ Be sure to clear the allocator after logging it in the eager scavenge
+ case, so that we don't later try to allocate out of the lines that we
+ have thrown away.
+
+ We didn't need to do this previously because scavenge would only happen
+ at thread exit time, after which no further allocation from the per-thread
+ cache would take place.
+
+ * bmalloc/Allocator.cpp:
+ (bmalloc::Allocator::scavenge):
+ * bmalloc/MediumAllocator.h:
+ (bmalloc::MediumAllocator::clear):
+ * bmalloc/SmallAllocator.h:
+ (bmalloc::SmallAllocator::clear):
+
2014-09-05 Geoffrey Garen <ggaren@apple.com>
bmalloc should honor the FastMalloc statistics API
void Allocator::scavenge()
{
- for (auto& allocator : m_smallAllocators)
+ for (auto& allocator : m_smallAllocators) {
log(allocator);
+ allocator.clear();
+ }
processSmallAllocatorLog();
log(m_mediumAllocator);
+ m_mediumAllocator.clear();
processMediumAllocatorLog();
}
bool allocate(size_t, void*&);
unsigned char derefCount();
+
void refill(MediumLine*);
+ void clear();
private:
char* m_end;
m_objectCount = 0;
}
+inline void MediumAllocator::clear()
+{
+ m_end = nullptr;
+ m_remaining = 0;
+ m_objectCount = 0;
+}
+
} // namespace bmalloc
#endif // MediumAllocator_h
unsigned short objectCount();
unsigned char derefCount();
+
void refill(SmallLine*);
+ void clear();
private:
char* m_ptr;
m_remaining = m_maxObjectCount;
}
+inline void SmallAllocator::clear()
+{
+ m_ptr = nullptr;
+ m_remaining = 0;
+}
+
} // namespace bmalloc
#endif // SmallAllocator_h