Chromium Code Reviews| 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 55 } | 55 } |
| 56 | 56 |
| 57 ALWAYS_INLINE static PartitionRootGeneric* fastMallocPartition() | 57 ALWAYS_INLINE static PartitionRootGeneric* fastMallocPartition() |
| 58 { | 58 { |
| 59 ASSERT(s_initialized); | 59 ASSERT(s_initialized); |
| 60 return m_fastMallocAllocator.root(); | 60 return m_fastMallocAllocator.root(); |
| 61 } | 61 } |
| 62 | 62 |
| 63 ALWAYS_INLINE static PartitionRoot* nodePartition() | 63 ALWAYS_INLINE static PartitionRoot* nodePartition() |
| 64 { | 64 { |
| 65 #if ENABLE(OILPAN) | |
| 66 ASSERT_NOT_REACHED(); | 65 ASSERT_NOT_REACHED(); |
| 67 return nullptr; | 66 return nullptr; |
| 68 #else | |
| 69 ASSERT(s_initialized); | |
| 70 return m_nodeAllocator.root(); | |
| 71 #endif | |
| 72 } | 67 } |
| 73 ALWAYS_INLINE static PartitionRoot* layoutPartition() | 68 ALWAYS_INLINE static PartitionRoot* layoutPartition() |
| 74 { | 69 { |
| 75 ASSERT(s_initialized); | 70 ASSERT(s_initialized); |
| 76 return m_layoutAllocator.root(); | 71 return m_layoutAllocator.root(); |
| 77 } | 72 } |
| 78 | 73 |
| 79 static size_t currentDOMMemoryUsage() | 74 static size_t currentDOMMemoryUsage() |
| 80 { | 75 { |
| 81 ASSERT(s_initialized); | 76 ASSERT(s_initialized); |
| 82 #if ENABLE(OILPAN) | |
| 83 ASSERT_NOT_REACHED(); | 77 ASSERT_NOT_REACHED(); |
| 84 return 0; | 78 return 0; |
| 85 #else | |
| 86 return m_nodeAllocator.root()->totalSizeOfCommittedPages; | |
| 87 #endif | |
| 88 } | 79 } |
| 89 | 80 |
| 90 static size_t totalSizeOfCommittedPages() | 81 static size_t totalSizeOfCommittedPages() |
| 91 { | 82 { |
| 92 size_t totalSize = 0; | 83 size_t totalSize = 0; |
| 93 totalSize += m_fastMallocAllocator.root()->totalSizeOfCommittedPages; | 84 totalSize += m_fastMallocAllocator.root()->totalSizeOfCommittedPages; |
| 94 totalSize += m_bufferAllocator.root()->totalSizeOfCommittedPages; | 85 totalSize += m_bufferAllocator.root()->totalSizeOfCommittedPages; |
| 95 #if !ENABLE(OILPAN) | |
| 96 totalSize += m_nodeAllocator.root()->totalSizeOfCommittedPages; | |
| 97 #endif | |
| 98 totalSize += m_layoutAllocator.root()->totalSizeOfCommittedPages; | 86 totalSize += m_layoutAllocator.root()->totalSizeOfCommittedPages; |
| 99 return totalSize; | 87 return totalSize; |
| 100 } | 88 } |
| 101 | 89 |
| 102 static void decommitFreeableMemory(); | 90 static void decommitFreeableMemory(); |
| 103 | 91 |
| 104 static void reportMemoryUsageHistogram(); | 92 static void reportMemoryUsageHistogram(); |
| 105 | 93 |
| 106 static void dumpMemoryStats(bool isLightDump, PartitionStatsDumper*); | 94 static void dumpMemoryStats(bool isLightDump, PartitionStatsDumper*); |
| 107 | 95 |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 136 partitionFreeGeneric(Partitions::fastMallocPartition(), p); | 124 partitionFreeGeneric(Partitions::fastMallocPartition(), p); |
| 137 } | 125 } |
| 138 | 126 |
| 139 static void handleOutOfMemory(); | 127 static void handleOutOfMemory(); |
| 140 | 128 |
| 141 private: | 129 private: |
| 142 static SpinLock s_initializationLock; | 130 static SpinLock s_initializationLock; |
| 143 static bool s_initialized; | 131 static bool s_initialized; |
| 144 | 132 |
| 145 // We have the following four partitions. | 133 // We have the following four partitions. |
| 146 // - Node partition: A partition to allocate Nodes. We prepare a | 134 // - Node partition: A partition to allocate Nodes. We prepare a |
|
haraken
2016/04/05 23:32:16
Update this comment & PartitionAlloc.md.
sof
2016/04/06 05:16:27
Thanks, updated - I updated a couple of the remark
| |
| 147 // dedicated partition for Nodes because Nodes are likely to be | 135 // dedicated partition for Nodes because Nodes are likely to be |
| 148 // a source of use-after-frees. Another reason is for performance: | 136 // a source of use-after-frees. Another reason is for performance: |
| 149 // Since Nodes are guaranteed to be used only by the main | 137 // Since Nodes are guaranteed to be used only by the main |
| 150 // thread, we can bypass acquiring a lock. Also we can improve memory | 138 // thread, we can bypass acquiring a lock. Also we can improve memory |
| 151 // locality by putting Nodes together. | 139 // locality by putting Nodes together. |
| 152 // - Layout object partition: A partition to allocate LayoutObjects. | 140 // - Layout object partition: A partition to allocate LayoutObjects. |
| 153 // we prepare a dedicated partition for the same reason as Nodes. | 141 // we prepare a dedicated partition for the same reason as Nodes. |
| 154 // - Buffer partition: A partition to allocate objects that have a strong | 142 // - Buffer partition: A partition to allocate objects that have a strong |
| 155 // risk where the length and/or the contents are exploited from user | 143 // risk where the length and/or the contents are exploited from user |
| 156 // scripts. Vectors, HashTables, ArrayBufferContents and Strings are | 144 // scripts. Vectors, HashTables, ArrayBufferContents and Strings are |
| 157 // allocated in the buffer partition. | 145 // allocated in the buffer partition. |
| 158 // - Fast malloc partition: A partition to allocate all other objects. | 146 // - Fast malloc partition: A partition to allocate all other objects. |
| 159 static PartitionAllocatorGeneric m_fastMallocAllocator; | 147 static PartitionAllocatorGeneric m_fastMallocAllocator; |
| 160 static PartitionAllocatorGeneric m_bufferAllocator; | 148 static PartitionAllocatorGeneric m_bufferAllocator; |
| 161 #if !ENABLE(OILPAN) | |
| 162 static SizeSpecificPartitionAllocator<3328> m_nodeAllocator; | |
| 163 #endif | |
| 164 static SizeSpecificPartitionAllocator<1024> m_layoutAllocator; | 149 static SizeSpecificPartitionAllocator<1024> m_layoutAllocator; |
| 165 static ReportPartitionAllocSizeFunction m_reportSizeFunction; | 150 static ReportPartitionAllocSizeFunction m_reportSizeFunction; |
| 166 }; | 151 }; |
| 167 | 152 |
| 168 } // namespace WTF | 153 } // namespace WTF |
| 169 | 154 |
| 170 #endif // Partitions_h | 155 #endif // Partitions_h |
| OLD | NEW |