Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(693)

Unified Diff: Source/wtf/Partitions.cpp

Issue 1041103002: PartitionAlloc: Centralize Partition allocators into one place (Part 1) (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/wtf/Partitions.h ('k') | Source/wtf/Vector.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « Source/wtf/Partitions.h ('k') | Source/wtf/Vector.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698