| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 | 30 |
| 31 #include "config.h" | 31 #include "config.h" |
| 32 #include "wtf/Partitions.h" | 32 #include "wtf/Partitions.h" |
| 33 | 33 |
| 34 #include "wtf/DefaultAllocator.h" | 34 #include "wtf/DefaultAllocator.h" |
| 35 #include "wtf/FastMalloc.h" | 35 #include "wtf/FastMalloc.h" |
| 36 #include "wtf/MainThread.h" | 36 #include "wtf/MainThread.h" |
| 37 | 37 |
| 38 namespace WTF { | 38 namespace WTF { |
| 39 | 39 |
| 40 bool Partitions::s_initialized; | 40 int Partitions::s_initializationLock = 0; |
| 41 bool Partitions::s_initialized = false; |
| 41 | 42 |
| 42 PartitionAllocatorGeneric Partitions::m_fastMallocAllocator; | 43 PartitionAllocatorGeneric Partitions::m_fastMallocAllocator; |
| 43 PartitionAllocatorGeneric Partitions::m_bufferAllocator; | 44 PartitionAllocatorGeneric Partitions::m_bufferAllocator; |
| 44 SizeSpecificPartitionAllocator<3328> Partitions::m_objectModelAllocator; | 45 SizeSpecificPartitionAllocator<3328> Partitions::m_objectModelAllocator; |
| 45 SizeSpecificPartitionAllocator<1024> Partitions::m_layoutAllocator; | 46 SizeSpecificPartitionAllocator<1024> Partitions::m_layoutAllocator; |
| 46 HistogramEnumerationFunction Partitions::m_histogramEnumeration = nullptr; | 47 HistogramEnumerationFunction Partitions::m_histogramEnumeration = nullptr; |
| 47 | 48 |
| 48 void Partitions::initialize() | 49 void Partitions::initialize() |
| 49 { | 50 { |
| 51 spinLockLock(&s_initializationLock); |
| 52 |
| 50 if (!s_initialized) { | 53 if (!s_initialized) { |
| 51 m_fastMallocAllocator.init(); | 54 m_fastMallocAllocator.init(); |
| 52 m_bufferAllocator.init(); | 55 m_bufferAllocator.init(); |
| 53 m_objectModelAllocator.init(); | 56 m_objectModelAllocator.init(); |
| 54 m_layoutAllocator.init(); | 57 m_layoutAllocator.init(); |
| 55 s_initialized = true; | 58 s_initialized = true; |
| 56 } | 59 } |
| 60 |
| 61 spinLockUnlock(&s_initializationLock); |
| 57 } | 62 } |
| 58 | 63 |
| 59 void Partitions::setHistogramEnumeration(HistogramEnumerationFunction histogramE
numeration) | 64 void Partitions::setHistogramEnumeration(HistogramEnumerationFunction histogramE
numeration) |
| 60 { | 65 { |
| 61 ASSERT(!m_histogramEnumeration); | 66 ASSERT(!m_histogramEnumeration); |
| 62 m_histogramEnumeration = histogramEnumeration; | 67 m_histogramEnumeration = histogramEnumeration; |
| 63 } | 68 } |
| 64 | 69 |
| 65 void Partitions::shutdown() | 70 void Partitions::shutdown() |
| 66 { | 71 { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 // accessed only on the main thread. | 116 // accessed only on the main thread. |
| 112 ASSERT(isMainThread()); | 117 ASSERT(isMainThread()); |
| 113 | 118 |
| 114 partitionDumpStatsGeneric(fastMallocPartition(), "fast_malloc_partition", pa
rtitionStatsDumper); | 119 partitionDumpStatsGeneric(fastMallocPartition(), "fast_malloc_partition", pa
rtitionStatsDumper); |
| 115 partitionDumpStatsGeneric(bufferPartition(), "buffer_partition", partitionSt
atsDumper); | 120 partitionDumpStatsGeneric(bufferPartition(), "buffer_partition", partitionSt
atsDumper); |
| 116 partitionDumpStats(objectModelPartition(), "object_model_partition", partiti
onStatsDumper); | 121 partitionDumpStats(objectModelPartition(), "object_model_partition", partiti
onStatsDumper); |
| 117 partitionDumpStats(layoutPartition(), "layout_partition", partitionStatsDump
er); | 122 partitionDumpStats(layoutPartition(), "layout_partition", partitionStatsDump
er); |
| 118 } | 123 } |
| 119 | 124 |
| 120 } // namespace WTF | 125 } // namespace WTF |
| OLD | NEW |