| 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 23 matching lines...) Expand all Loading... |
| 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(HistogramEnumerationFunction = nullptr); |
| 43 static void shutdown(); | 43 static void shutdown(); |
| 44 ALWAYS_INLINE static PartitionRootGeneric* getBufferPartition() | 44 ALWAYS_INLINE static PartitionRootGeneric* bufferPartition() |
| 45 { | 45 { |
| 46 // TODO(haraken): This check is needed because some call sites allocate | 46 // TODO(haraken): This check is needed because some call sites allocate |
| 47 // Blink things before WTF::initialize(). We should fix those call sites | 47 // Blink things before WTF::initialize(). We should fix those call sites |
| 48 // and remove the check. | 48 // and remove the check. |
| 49 if (UNLIKELY(!s_initialized)) | 49 if (UNLIKELY(!s_initialized)) |
| 50 initialize(); | 50 initialize(); |
| 51 return m_bufferAllocator.root(); | 51 return m_bufferAllocator.root(); |
| 52 } | 52 } |
| 53 | 53 |
| 54 ALWAYS_INLINE static PartitionRootGeneric* getFastMallocPartition() | 54 ALWAYS_INLINE static PartitionRootGeneric* fastMallocPartition() |
| 55 { | 55 { |
| 56 // TODO(haraken): This check is needed because some call sites allocate | 56 // TODO(haraken): This check is needed because some call sites allocate |
| 57 // Blink things before WTF::initialize(). We should fix those call sites | 57 // Blink things before WTF::initialize(). We should fix those call sites |
| 58 // and remove the check. | 58 // and remove the check. |
| 59 if (UNLIKELY(!s_initialized)) | 59 if (UNLIKELY(!s_initialized)) |
| 60 initialize(); | 60 initialize(); |
| 61 return m_fastMallocAllocator.root(); | 61 return m_fastMallocAllocator.root(); |
| 62 } | 62 } |
| 63 | 63 |
| 64 ALWAYS_INLINE static PartitionRoot* getObjectModelPartition() | 64 ALWAYS_INLINE static PartitionRoot* objectModelPartition() |
| 65 { | 65 { |
| 66 ASSERT(s_initialized); | 66 ASSERT(s_initialized); |
| 67 return m_objectModelAllocator.root(); | 67 return m_objectModelAllocator.root(); |
| 68 } | 68 } |
| 69 ALWAYS_INLINE static PartitionRoot* getRenderingPartition() | 69 ALWAYS_INLINE static PartitionRoot* layoutPartition() |
| 70 { | 70 { |
| 71 ASSERT(s_initialized); | 71 ASSERT(s_initialized); |
| 72 return m_renderingAllocator.root(); | 72 return m_layoutAllocator.root(); |
| 73 } | 73 } |
| 74 | 74 |
| 75 static size_t currentDOMMemoryUsage() | 75 static size_t currentDOMMemoryUsage() |
| 76 { | 76 { |
| 77 ASSERT(s_initialized); | 77 ASSERT(s_initialized); |
| 78 return m_objectModelAllocator.root()->totalSizeOfCommittedPages; | 78 return m_objectModelAllocator.root()->totalSizeOfCommittedPages; |
| 79 } | 79 } |
| 80 | 80 |
| 81 static size_t totalSizeOfCommittedPages() | 81 static size_t totalSizeOfCommittedPages() |
| 82 { | 82 { |
| 83 size_t totalSize = 0; | 83 size_t totalSize = 0; |
| 84 totalSize += m_fastMallocAllocator.root()->totalSizeOfCommittedPages; | 84 totalSize += m_fastMallocAllocator.root()->totalSizeOfCommittedPages; |
| 85 totalSize += m_bufferAllocator.root()->totalSizeOfCommittedPages; | 85 totalSize += m_bufferAllocator.root()->totalSizeOfCommittedPages; |
| 86 totalSize += m_objectModelAllocator.root()->totalSizeOfCommittedPages; | 86 totalSize += m_objectModelAllocator.root()->totalSizeOfCommittedPages; |
| 87 totalSize += m_renderingAllocator.root()->totalSizeOfCommittedPages; | 87 totalSize += m_layoutAllocator.root()->totalSizeOfCommittedPages; |
| 88 return totalSize; | 88 return totalSize; |
| 89 } | 89 } |
| 90 | 90 |
| 91 static void decommitFreeableMemory(); | 91 static void decommitFreeableMemory(); |
| 92 | 92 |
| 93 static void reportMemoryUsageHistogram(); | 93 static void reportMemoryUsageHistogram(); |
| 94 | 94 |
| 95 static void dumpMemoryStats(PartitionStatsDumper*); | 95 static void dumpMemoryStats(PartitionStatsDumper*); |
| 96 | 96 |
| 97 private: | 97 private: |
| 98 static bool s_initialized; | 98 static bool s_initialized; |
| 99 static PartitionAllocatorGeneric m_fastMallocAllocator; | 99 static PartitionAllocatorGeneric m_fastMallocAllocator; |
| 100 static PartitionAllocatorGeneric m_bufferAllocator; | 100 static PartitionAllocatorGeneric m_bufferAllocator; |
| 101 static SizeSpecificPartitionAllocator<3328> m_objectModelAllocator; | 101 static SizeSpecificPartitionAllocator<3328> m_objectModelAllocator; |
| 102 static SizeSpecificPartitionAllocator<1024> m_renderingAllocator; | 102 static SizeSpecificPartitionAllocator<1024> m_layoutAllocator; |
| 103 static HistogramEnumerationFunction m_histogramEnumeration; | 103 static HistogramEnumerationFunction m_histogramEnumeration; |
| 104 }; | 104 }; |
| 105 | 105 |
| 106 } // namespace WTF | 106 } // namespace WTF |
| 107 | 107 |
| 108 #endif // Partitions_h | 108 #endif // Partitions_h |
| OLD | NEW |