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 20 matching lines...) Expand all Loading... | |
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 bool Partitions::s_initialized; |
41 int Partitions::s_lock = 0; | |
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(HistogramEnumerationFunction histogramEnumeration) | 49 void Partitions::initialize() |
49 { | 50 { |
50 static int lock = 0; | |
51 // Guard against two threads hitting here in parallel. | 51 // Guard against two threads hitting here in parallel. |
52 spinLockLock(&lock); | 52 spinLockLock(&s_lock); |
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 spinLockUnlock(&s_lock); |
61 } | |
62 | |
63 void Partitions::setHistogramEnumeration(HistogramEnumerationFunction histogramE numeration) | |
64 { | |
65 spinLockLock(&s_lock); | |
haraken
2015/06/17 05:24:20
I don't think this lock is needed. Partitions::set
bashi
2015/06/17 05:25:27
Hmm, the same can be said for initialize()? Can we
haraken
2015/06/17 05:29:37
I think your understanding is correct. Any Blink t
bashi
2015/06/17 05:49:41
Removed. We can't add ASSERT(isMainThread()) becau
| |
66 ASSERT(!m_histogramEnumeration); | |
67 m_histogramEnumeration = histogramEnumeration; | |
68 spinLockUnlock(&s_lock); | |
62 } | 69 } |
63 | 70 |
64 void Partitions::shutdown() | 71 void Partitions::shutdown() |
65 { | 72 { |
66 // We could ASSERT here for a memory leak within the partition, but it leads | 73 // 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 | 74 // 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. | 75 // the valgrind and heapcheck bots, which run without partitions. |
69 (void) m_layoutAllocator.shutdown(); | 76 (void) m_layoutAllocator.shutdown(); |
70 (void) m_objectModelAllocator.shutdown(); | 77 (void) m_objectModelAllocator.shutdown(); |
71 (void) m_bufferAllocator.shutdown(); | 78 (void) m_bufferAllocator.shutdown(); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
110 // accessed only on the main thread. | 117 // accessed only on the main thread. |
111 ASSERT(isMainThread()); | 118 ASSERT(isMainThread()); |
112 | 119 |
113 partitionDumpStatsGeneric(fastMallocPartition(), "fast_malloc_partition", pa rtitionStatsDumper); | 120 partitionDumpStatsGeneric(fastMallocPartition(), "fast_malloc_partition", pa rtitionStatsDumper); |
114 partitionDumpStatsGeneric(bufferPartition(), "buffer_partition", partitionSt atsDumper); | 121 partitionDumpStatsGeneric(bufferPartition(), "buffer_partition", partitionSt atsDumper); |
115 partitionDumpStats(objectModelPartition(), "object_model_partition", partiti onStatsDumper); | 122 partitionDumpStats(objectModelPartition(), "object_model_partition", partiti onStatsDumper); |
116 partitionDumpStats(layoutPartition(), "layout_partition", partitionStatsDump er); | 123 partitionDumpStats(layoutPartition(), "layout_partition", partitionStatsDump er); |
117 } | 124 } |
118 | 125 |
119 } // namespace WTF | 126 } // namespace WTF |
OLD | NEW |