Index: Source/wtf/Partitions.cpp |
diff --git a/Source/platform/Partitions.cpp b/Source/wtf/Partitions.cpp |
similarity index 77% |
rename from Source/platform/Partitions.cpp |
rename to Source/wtf/Partitions.cpp |
index 33072f0dc9ddd0cb62a222c03ad55d6ce605f91d..8d131d408d1f0a15f5535aeab7273be58f198340 100644 |
--- a/Source/platform/Partitions.cpp |
+++ b/Source/wtf/Partitions.cpp |
@@ -29,26 +29,43 @@ |
*/ |
#include "config.h" |
-#include "platform/Partitions.h" |
+#include "wtf/Partitions.h" |
-namespace blink { |
+#include "wtf/DefaultAllocator.h" |
+#include "wtf/FastMalloc.h" |
+namespace WTF { |
+ |
+bool Partitions::s_initialized; |
+ |
+PartitionAllocatorGeneric Partitions::m_bufferAllocator; |
SizeSpecificPartitionAllocator<3328> Partitions::m_objectModelAllocator; |
SizeSpecificPartitionAllocator<1024> Partitions::m_renderingAllocator; |
-void Partitions::init() |
+void Partitions::initialize() |
{ |
- m_objectModelAllocator.init(); |
- m_renderingAllocator.init(); |
+ static int lock = 0; |
+ // Guard against two threads hitting here in parallel. |
+ spinLockLock(&lock); |
+ if (!s_initialized) { |
+ m_bufferAllocator.init(); |
+ m_objectModelAllocator.init(); |
+ m_renderingAllocator.init(); |
+ s_initialized = true; |
+ } |
+ spinLockUnlock(&lock); |
} |
void Partitions::shutdown() |
{ |
+ fastMallocShutdown(); |
+ |
// We could ASSERT here for a memory leak within the partition, but it leads |
// to very hard to diagnose ASSERTs, so it's best to leave leak checking for |
// the valgrind and heapcheck bots, which run without partitions. |
(void) m_renderingAllocator.shutdown(); |
(void) m_objectModelAllocator.shutdown(); |
+ (void) m_bufferAllocator.shutdown(); |
} |
-} // namespace blink |
+} // namespace WTF |