| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/allocator/partition_allocator/partition_alloc.h" | 5 #include "base/allocator/partition_allocator/partition_alloc.h" |
| 6 | 6 |
| 7 #include <string.h> | 7 #include <string.h> |
| 8 | 8 |
| 9 #include "base/allocator/partition_allocator/oom.h" | 9 #include "base/allocator/partition_allocator/oom.h" |
| 10 #include "base/allocator/partition_allocator/spin_lock.h" | 10 #include "base/allocator/partition_allocator/spin_lock.h" |
| (...skipping 1144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1155 // Rewrite the freelist. | 1155 // Rewrite the freelist. |
| 1156 PartitionFreelistEntry** entry_ptr = &page->freelist_head; | 1156 PartitionFreelistEntry** entry_ptr = &page->freelist_head; |
| 1157 for (size_t slotIndex = 0; slotIndex < num_slots; ++slotIndex) { | 1157 for (size_t slotIndex = 0; slotIndex < num_slots; ++slotIndex) { |
| 1158 if (slot_usage[slotIndex]) | 1158 if (slot_usage[slotIndex]) |
| 1159 continue; | 1159 continue; |
| 1160 PartitionFreelistEntry* entry = reinterpret_cast<PartitionFreelistEntry*>( | 1160 PartitionFreelistEntry* entry = reinterpret_cast<PartitionFreelistEntry*>( |
| 1161 ptr + (slot_size * slotIndex)); | 1161 ptr + (slot_size * slotIndex)); |
| 1162 *entry_ptr = PartitionFreelistMask(entry); | 1162 *entry_ptr = PartitionFreelistMask(entry); |
| 1163 entry_ptr = reinterpret_cast<PartitionFreelistEntry**>(entry); | 1163 entry_ptr = reinterpret_cast<PartitionFreelistEntry**>(entry); |
| 1164 num_new_entries++; | 1164 num_new_entries++; |
| 1165 last_slot = slotIndex; |
| 1165 } | 1166 } |
| 1166 // Terminate the freelist chain. | 1167 // Terminate the freelist chain. |
| 1167 *entry_ptr = nullptr; | 1168 *entry_ptr = nullptr; |
| 1168 // The freelist head is stored unmasked. | 1169 // The freelist head is stored unmasked. |
| 1169 page->freelist_head = PartitionFreelistMask(page->freelist_head); | 1170 page->freelist_head = PartitionFreelistMask(page->freelist_head); |
| 1170 DCHECK(num_new_entries == num_slots - page->num_allocated_slots); | 1171 DCHECK(num_new_entries == num_slots - page->num_allocated_slots); |
| 1171 // Discard the memory. | 1172 // Discard the memory. |
| 1172 DiscardSystemPages(begin_ptr, unprovisioned_bytes); | 1173 DiscardSystemPages(begin_ptr, unprovisioned_bytes); |
| 1173 } | 1174 } |
| 1174 | 1175 |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1437 // can use PartitionAlloc to allocate and this can affect the statistics. | 1438 // can use PartitionAlloc to allocate and this can affect the statistics. |
| 1438 for (size_t i = 0; i < partitionNumBuckets; ++i) { | 1439 for (size_t i = 0; i < partitionNumBuckets; ++i) { |
| 1439 if (memory_stats[i].is_valid) | 1440 if (memory_stats[i].is_valid) |
| 1440 dumper->PartitionsDumpBucketStats(partition_name, &memory_stats[i]); | 1441 dumper->PartitionsDumpBucketStats(partition_name, &memory_stats[i]); |
| 1441 } | 1442 } |
| 1442 } | 1443 } |
| 1443 dumper->PartitionDumpTotals(partition_name, &stats); | 1444 dumper->PartitionDumpTotals(partition_name, &stats); |
| 1444 } | 1445 } |
| 1445 | 1446 |
| 1446 } // namespace base | 1447 } // namespace base |
| OLD | NEW |