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

Unified 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, 3 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 side-by-side diff with in-line comments
Download patch
Index: base/trace_event/memory_profiler_allocation_register.cc
diff --git a/base/trace_event/memory_profiler_allocation_register.cc b/base/trace_event/memory_profiler_allocation_register.cc
new file mode 100644
index 0000000000000000000000000000000000000000..8d5fa7c8b957781c31244bde9a8dc5f839d5476d
--- /dev/null
+++ b/base/trace_event/memory_profiler_allocation_register.cc
@@ -0,0 +1,40 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/trace_event/memory_profiler_allocation_register.h"
+
+namespace base {
+namespace trace_event {
+
+size_t RoundUpToPageSize(size_t size) {
+ size_t page_size = GetSystemPageSize();
+ return ((size + page_size - 1) / page_size) * page_size;
+}
+
+AllocationRegister::AllocationRegister() {}
+AllocationRegister::~AllocationRegister() {}
+
+void AllocationRegister::Insert(void* address,
+ size_t size,
+ AllocationContext context) {
+ Allocation* alloc = allocations_.Insert(reinterpret_cast<uintptr_t>(address));
+ alloc->size = size;
+ alloc->context = context;
+}
+
+void AllocationRegister::Remove(void* address) {
+ allocations_.Remove(reinterpret_cast<uintptr_t>(address));
+}
+
+AllocationRegister::AllocationRef AllocationRegister::ConstIterator::operator*()
+ const {
+ AllocationRef alloc_ref;
+ alloc_ref.address = reinterpret_cast<void*>((*iterator_).first);
+ alloc_ref.size = (*iterator_).second->size;
+ alloc_ref.context = &(*iterator_).second->context;
+ return alloc_ref;
+}
+
+} // namespace trace_event
+} // namespace base

Powered by Google App Engine
This is Rietveld 408576698