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

Side by Side Diff: base/trace_event/memory_profiler_allocation_register.cc

Issue 1371053002: [Tracing] Add allocation register for heap profiling (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@backtrace
Patch Set: Created 5 years, 2 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
(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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698