OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "base/trace_event/memory_profiler_allocation_register.h" |
| 6 |
| 7 namespace base { |
| 8 namespace trace_event { |
| 9 |
| 10 size_t RoundUpToPageSize(size_t size) { |
| 11 size_t page_size = GetSystemPageSize(); |
| 12 return ((size + page_size - 1) / page_size) * page_size; |
| 13 } |
| 14 |
| 15 AllocationRegister::AllocationRegister() {} |
| 16 AllocationRegister::~AllocationRegister() {} |
| 17 |
| 18 void AllocationRegister::Insert(void* address, |
| 19 size_t size, |
| 20 AllocationContext context) { |
| 21 Allocation* alloc = allocations_.Insert(reinterpret_cast<uintptr_t>(address)); |
| 22 alloc->size = size; |
| 23 alloc->context = context; |
| 24 } |
| 25 |
| 26 void AllocationRegister::Remove(void* address) { |
| 27 allocations_.Remove(reinterpret_cast<uintptr_t>(address)); |
| 28 } |
| 29 |
| 30 AllocationRegister::AllocationRef AllocationRegister::ConstIterator::operator*() |
| 31 const { |
| 32 AllocationRef alloc_ref; |
| 33 alloc_ref.address = reinterpret_cast<void*>((*iterator_).first); |
| 34 alloc_ref.size = (*iterator_).second->size; |
| 35 alloc_ref.context = &(*iterator_).second->context; |
| 36 return alloc_ref; |
| 37 } |
| 38 |
| 39 } // namespace trace_event |
| 40 } // namespace base |
OLD | NEW |