Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(272)

Side by Side Diff: third_party/WebKit/Source/wtf/Partitions.h

Issue 1863753002: Remove ENABLE(OILPAN) uses in wtf/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More comment syncing Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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 // - LayoutObject partition: A partition to allocate LayoutObjects.
147 // dedicated partition for Nodes because Nodes are likely to be 135 // We prepare a dedicated partition for LayoutObjects because they
148 // a source of use-after-frees. Another reason is for performance: 136 // are likely to be a source of use-after-frees. Another reason
149 // Since Nodes are guaranteed to be used only by the main 137 // is for performance: As LayoutObjects are guaranteed to only be used
150 // thread, we can bypass acquiring a lock. Also we can improve memory 138 // by the main thread, we can bypass acquiring a lock. Also we can
151 // locality by putting Nodes together. 139 // improve memory locality by putting LayoutObjects together.
152 // - Layout object partition: A partition to allocate LayoutObjects.
153 // we prepare a dedicated partition for the same reason as Nodes.
154 // - Buffer partition: A partition to allocate objects that have a strong 140 // - Buffer partition: A partition to allocate objects that have a strong
155 // risk where the length and/or the contents are exploited from user 141 // risk where the length and/or the contents are exploited from user
156 // scripts. Vectors, HashTables, ArrayBufferContents and Strings are 142 // scripts. Vectors, HashTables, ArrayBufferContents and Strings are
157 // allocated in the buffer partition. 143 // allocated in the buffer partition.
158 // - Fast malloc partition: A partition to allocate all other objects. 144 // - Fast malloc partition: A partition to allocate all other objects.
159 static PartitionAllocatorGeneric m_fastMallocAllocator; 145 static PartitionAllocatorGeneric m_fastMallocAllocator;
160 static PartitionAllocatorGeneric m_bufferAllocator; 146 static PartitionAllocatorGeneric m_bufferAllocator;
161 #if !ENABLE(OILPAN)
162 static SizeSpecificPartitionAllocator<3328> m_nodeAllocator;
163 #endif
164 static SizeSpecificPartitionAllocator<1024> m_layoutAllocator; 147 static SizeSpecificPartitionAllocator<1024> m_layoutAllocator;
165 static ReportPartitionAllocSizeFunction m_reportSizeFunction; 148 static ReportPartitionAllocSizeFunction m_reportSizeFunction;
166 }; 149 };
167 150
168 } // namespace WTF 151 } // namespace WTF
169 152
170 #endif // Partitions_h 153 #endif // Partitions_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/wtf/PartitionAlloc.md ('k') | third_party/WebKit/Source/wtf/Partitions.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698