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

Unified Diff: base/trace_event/memory_profiler_allocation_context.cc

Issue 1391933004: [Tracing] Add hook to PartitionAlloc for heap profiling (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
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 side-by-side diff with in-line comments
Download patch
Index: base/trace_event/memory_profiler_allocation_context.cc
diff --git a/base/trace_event/memory_profiler_allocation_context.cc b/base/trace_event/memory_profiler_allocation_context.cc
index b82e2109845b0494c82ee7d689aefe5f7a7d960b..d6444abe47f9c7f8c567d2e5f6aefd45353252ef 100644
--- a/base/trace_event/memory_profiler_allocation_context.cc
+++ b/base/trace_event/memory_profiler_allocation_context.cc
@@ -15,11 +15,32 @@ subtle::Atomic32 AllocationContextTracker::capture_enabled_ = 0;
namespace {
ThreadLocalStorage::StaticSlot g_tls_alloc_ctx_tracker = TLS_INITIALIZER;
+
+// Returns a pointer past the end of the fixed-size array |array| of |T| of
+// length |N|, identical to C++11 |std::end|.
+template <typename T, int N>
+T* End(T(&array)[N]) {
+ return array + N;
}
+} // namespace
+
AllocationStack::AllocationStack() {}
AllocationStack::~AllocationStack() {}
+AllocationContext AllocationContext::Empty() {
+ AllocationContext context;
+
+ for (StackFrame* i = context.backtrace.frames;
+ i != End(context.backtrace.frames); i++)
Primiano Tucci (use gerrit) 2015/10/12 16:36:45 You can make this simpler, shorter and more readab
Ruud van Asseldonk 2015/10/13 10:42:18 Done.
+ *i = nullptr;
+
+ for (auto* i = context.fields; i != End(context.fields); i++)
Primiano Tucci (use gerrit) 2015/10/12 16:36:45 ditto
Ruud van Asseldonk 2015/10/13 10:42:18 Done.
+ i->first = nullptr;
+
+ return context;
+}
+
// This function is added to the TLS slot to clean up the instance when the
// thread exits.
void DestructAllocationContextTracker(void* alloc_ctx_tracker) {
@@ -81,13 +102,6 @@ void AllocationContextTracker::UnsetContextField(const char* key) {
tracker->context_.erase(key);
}
-// Returns a pointer past the end of the fixed-size array |array| of |T| of
-// length |N|, identical to C++11 |std::end|.
-template <typename T, int N>
-T* End(T(&array)[N]) {
- return array + N;
-}
-
// static
AllocationContext AllocationContextTracker::GetContextSnapshot() {
AllocationContextTracker* tracker = GetThreadLocalTracker();

Powered by Google App Engine
This is Rietveld 408576698