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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 static void FastFree(void* p) { | 123 static void FastFree(void* p) { |
124 PartitionFreeGeneric(Partitions::FastMallocPartition(), p); | 124 PartitionFreeGeneric(Partitions::FastMallocPartition(), p); |
125 } | 125 } |
126 | 126 |
127 static void HandleOutOfMemory(); | 127 static void HandleOutOfMemory(); |
128 | 128 |
129 private: | 129 private: |
130 static base::subtle::SpinLock initialization_lock_; | 130 static base::subtle::SpinLock initialization_lock_; |
131 static bool initialized_; | 131 static bool initialized_; |
132 | 132 |
133 // We have the following four partitions. | 133 // See Allocator.md for a description of these partitions. |
134 // - LayoutObject partition: A partition to allocate LayoutObjects. | |
135 // We prepare a dedicated partition for LayoutObjects because they | |
136 // are likely to be a source of use-after-frees. Another reason | |
137 // is for performance: As LayoutObjects are guaranteed to only be used | |
138 // by the main thread, we can bypass acquiring a lock. Also we can | |
139 // improve memory locality by putting LayoutObjects together. | |
140 // - ArrayBuffer partition: A partition to allocate array buffers. | |
141 // - Buffer partition: A partition to allocate other buffers that have | |
142 // a strong risk where the length and/or the contents are exploited from | |
143 // user scripts. Vectors, HashTables and Strings are allocated in the | |
144 // buffer partition. | |
145 // - Fast malloc partition: A partition to allocate all other objects. | |
146 static base::PartitionAllocatorGeneric fast_malloc_allocator_; | 134 static base::PartitionAllocatorGeneric fast_malloc_allocator_; |
147 static base::PartitionAllocatorGeneric array_buffer_allocator_; | 135 static base::PartitionAllocatorGeneric array_buffer_allocator_; |
148 static base::PartitionAllocatorGeneric buffer_allocator_; | 136 static base::PartitionAllocatorGeneric buffer_allocator_; |
149 static base::SizeSpecificPartitionAllocator<1024> layout_allocator_; | 137 static base::SizeSpecificPartitionAllocator<1024> layout_allocator_; |
150 static ReportPartitionAllocSizeFunction report_size_function_; | 138 static ReportPartitionAllocSizeFunction report_size_function_; |
151 }; | 139 }; |
152 | 140 |
153 using base::kGenericMaxDirectMapped; | 141 using base::kGenericMaxDirectMapped; |
154 using base::kPageAllocationGranularity; | 142 using base::kPageAllocationGranularity; |
155 using base::kPageAllocationGranularityBaseMask; | 143 using base::kPageAllocationGranularityBaseMask; |
(...skipping 15 matching lines...) Expand all Loading... |
171 using base::PageAccessible; | 159 using base::PageAccessible; |
172 using base::PageInaccessible; | 160 using base::PageInaccessible; |
173 using base::PartitionStatsDumper; | 161 using base::PartitionStatsDumper; |
174 using base::PartitionMemoryStats; | 162 using base::PartitionMemoryStats; |
175 using base::PartitionBucketMemoryStats; | 163 using base::PartitionBucketMemoryStats; |
176 using base::PartitionAllocHooks; | 164 using base::PartitionAllocHooks; |
177 | 165 |
178 } // namespace WTF | 166 } // namespace WTF |
179 | 167 |
180 #endif // Partitions_h | 168 #endif // Partitions_h |
OLD | NEW |