| 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 21 matching lines...) Expand all Loading... |
| 32 #define Partitions_h | 32 #define Partitions_h |
| 33 | 33 |
| 34 #include "wtf/PartitionAlloc.h" | 34 #include "wtf/PartitionAlloc.h" |
| 35 #include "wtf/WTF.h" | 35 #include "wtf/WTF.h" |
| 36 #include "wtf/WTFExport.h" | 36 #include "wtf/WTFExport.h" |
| 37 | 37 |
| 38 namespace WTF { | 38 namespace WTF { |
| 39 | 39 |
| 40 class WTF_EXPORT Partitions { | 40 class WTF_EXPORT Partitions { |
| 41 public: | 41 public: |
| 42 static void initialize(HistogramEnumerationFunction = nullptr); | 42 static void initialize(); |
| 43 // TODO(bashi): Remove this function and make initialize() take |
| 44 // HistogramEnumerationFunction when we can make sure that WTF::initialize() |
| 45 // is called before using this class. |
| 46 static void setHistogramEnumeration(HistogramEnumerationFunction); |
| 43 static void shutdown(); | 47 static void shutdown(); |
| 44 ALWAYS_INLINE static PartitionRootGeneric* bufferPartition() | 48 ALWAYS_INLINE static PartitionRootGeneric* bufferPartition() |
| 45 { | 49 { |
| 46 // TODO(haraken): This check is needed because some call sites allocate | 50 // TODO(haraken): This check is needed because some call sites allocate |
| 47 // Blink things before WTF::initialize(). We should fix those call sites | 51 // Blink things before WTF::initialize(). We should fix those call sites |
| 48 // and remove the check. | 52 // and remove the check. |
| 49 if (UNLIKELY(!s_initialized)) | 53 if (UNLIKELY(!s_initialized)) |
| 50 initialize(); | 54 initialize(); |
| 51 return m_bufferAllocator.root(); | 55 return m_bufferAllocator.root(); |
| 52 } | 56 } |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 } | 93 } |
| 90 | 94 |
| 91 static void decommitFreeableMemory(); | 95 static void decommitFreeableMemory(); |
| 92 | 96 |
| 93 static void reportMemoryUsageHistogram(); | 97 static void reportMemoryUsageHistogram(); |
| 94 | 98 |
| 95 static void dumpMemoryStats(PartitionStatsDumper*); | 99 static void dumpMemoryStats(PartitionStatsDumper*); |
| 96 | 100 |
| 97 private: | 101 private: |
| 98 static bool s_initialized; | 102 static bool s_initialized; |
| 103 static int s_lock; // Used for spin lock. |
| 99 static PartitionAllocatorGeneric m_fastMallocAllocator; | 104 static PartitionAllocatorGeneric m_fastMallocAllocator; |
| 100 static PartitionAllocatorGeneric m_bufferAllocator; | 105 static PartitionAllocatorGeneric m_bufferAllocator; |
| 101 static SizeSpecificPartitionAllocator<3328> m_objectModelAllocator; | 106 static SizeSpecificPartitionAllocator<3328> m_objectModelAllocator; |
| 102 static SizeSpecificPartitionAllocator<1024> m_layoutAllocator; | 107 static SizeSpecificPartitionAllocator<1024> m_layoutAllocator; |
| 103 static HistogramEnumerationFunction m_histogramEnumeration; | 108 static HistogramEnumerationFunction m_histogramEnumeration; |
| 104 }; | 109 }; |
| 105 | 110 |
| 106 } // namespace WTF | 111 } // namespace WTF |
| 107 | 112 |
| 108 #endif // Partitions_h | 113 #endif // Partitions_h |
| OLD | NEW |