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 27 matching lines...) Expand all Loading... | |
38 namespace WTF { | 38 namespace WTF { |
39 | 39 |
40 bool Partitions::s_initialized; | 40 bool Partitions::s_initialized; |
41 | 41 |
42 PartitionAllocatorGeneric Partitions::m_fastMallocAllocator; | 42 PartitionAllocatorGeneric Partitions::m_fastMallocAllocator; |
43 PartitionAllocatorGeneric Partitions::m_bufferAllocator; | 43 PartitionAllocatorGeneric Partitions::m_bufferAllocator; |
44 SizeSpecificPartitionAllocator<3328> Partitions::m_objectModelAllocator; | 44 SizeSpecificPartitionAllocator<3328> Partitions::m_objectModelAllocator; |
45 SizeSpecificPartitionAllocator<1024> Partitions::m_layoutAllocator; | 45 SizeSpecificPartitionAllocator<1024> Partitions::m_layoutAllocator; |
46 HistogramEnumerationFunction Partitions::m_histogramEnumeration = nullptr; | 46 HistogramEnumerationFunction Partitions::m_histogramEnumeration = nullptr; |
47 | 47 |
48 void Partitions::initialize(HistogramEnumerationFunction histogramEnumeration) | 48 void Partitions::initialize() |
49 { | 49 { |
50 static int lock = 0; | 50 // TODO(bashi): Add ASSERT(isMainThread()). |
51 // Guard against two threads hitting here in parallel. | 51 // This could be called before WTF::initialize() is called so we can't |
52 spinLockLock(&lock); | 52 // rely on isMainThread() at this point. |
haraken
2015/06/17 14:20:33
Sorry, I noticed this file is already including Ma
bashi
2015/06/18 22:53:37
Removed.
| |
53 if (!s_initialized) { | 53 if (!s_initialized) { |
54 m_fastMallocAllocator.init(); | 54 m_fastMallocAllocator.init(); |
55 m_bufferAllocator.init(); | 55 m_bufferAllocator.init(); |
56 m_objectModelAllocator.init(); | 56 m_objectModelAllocator.init(); |
57 m_layoutAllocator.init(); | 57 m_layoutAllocator.init(); |
58 m_histogramEnumeration = histogramEnumeration; | |
59 s_initialized = true; | 58 s_initialized = true; |
60 } | 59 } |
61 spinLockUnlock(&lock); | 60 } |
61 | |
62 void Partitions::setHistogramEnumeration(HistogramEnumerationFunction histogramE numeration) | |
63 { | |
64 ASSERT(!m_histogramEnumeration); | |
65 m_histogramEnumeration = histogramEnumeration; | |
62 } | 66 } |
63 | 67 |
64 void Partitions::shutdown() | 68 void Partitions::shutdown() |
65 { | 69 { |
66 // We could ASSERT here for a memory leak within the partition, but it leads | 70 // We could ASSERT here for a memory leak within the partition, but it leads |
67 // to very hard to diagnose ASSERTs, so it's best to leave leak checking for | 71 // to very hard to diagnose ASSERTs, so it's best to leave leak checking for |
68 // the valgrind and heapcheck bots, which run without partitions. | 72 // the valgrind and heapcheck bots, which run without partitions. |
69 (void) m_layoutAllocator.shutdown(); | 73 (void) m_layoutAllocator.shutdown(); |
70 (void) m_objectModelAllocator.shutdown(); | 74 (void) m_objectModelAllocator.shutdown(); |
71 (void) m_bufferAllocator.shutdown(); | 75 (void) m_bufferAllocator.shutdown(); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
110 // accessed only on the main thread. | 114 // accessed only on the main thread. |
111 ASSERT(isMainThread()); | 115 ASSERT(isMainThread()); |
112 | 116 |
113 partitionDumpStatsGeneric(fastMallocPartition(), "fast_malloc_partition", pa rtitionStatsDumper); | 117 partitionDumpStatsGeneric(fastMallocPartition(), "fast_malloc_partition", pa rtitionStatsDumper); |
114 partitionDumpStatsGeneric(bufferPartition(), "buffer_partition", partitionSt atsDumper); | 118 partitionDumpStatsGeneric(bufferPartition(), "buffer_partition", partitionSt atsDumper); |
115 partitionDumpStats(objectModelPartition(), "object_model_partition", partiti onStatsDumper); | 119 partitionDumpStats(objectModelPartition(), "object_model_partition", partiti onStatsDumper); |
116 partitionDumpStats(layoutPartition(), "layout_partition", partitionStatsDump er); | 120 partitionDumpStats(layoutPartition(), "layout_partition", partitionStatsDump er); |
117 } | 121 } |
118 | 122 |
119 } // namespace WTF | 123 } // namespace WTF |
OLD | NEW |