OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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 #ifndef BASE_TRACE_EVENT_HEAP_PROFILER_H |
| 6 #define BASE_TRACE_EVENT_HEAP_PROFILER_H |
| 7 |
| 8 #include "base/compiler_specific.h" |
| 9 #include "base/trace_event/heap_profiler_allocation_context_tracker.h" |
| 10 |
| 11 // This header file defines the set of macros that are used to track memory |
| 12 // usage in the heap profiler. This is in addition to the macros defined in |
| 13 // trace_event.h and are specific to heap profiler. This file also defines |
| 14 // implementation details of these macros. |
| 15 |
| 16 // Implementation detail: heap profiler macros create temporary variables to |
| 17 // keep instrumentation overhead low. These macros give each temporary variable |
| 18 // a unique name based on the line number to prevent name collisions. |
| 19 #define INTERNAL_HEAP_PROFILER_UID3(a, b) heap_profiler_unique_##a##b |
| 20 #define INTERNAL_HEAP_PROFILER_UID2(a, b) INTERNAL_HEAP_PROFILER_UID3(a, b) |
| 21 #define INTERNAL_HEAP_PROFILER_UID(name_prefix) \ |
| 22 INTERNAL_HEAP_PROFILER_UID2(name_prefix, __LINE__) |
| 23 |
| 24 // A scoped ignore event used to tell heap profiler to ignore all the |
| 25 // allocations in the scope. It is useful to exclude allocations made for |
| 26 // tracing from the heap profiler dumps. |
| 27 #define HEAP_PROFILER_SCOPED_IGNORE \ |
| 28 trace_event_internal::HeapProfilerScopedIgnore INTERNAL_HEAP_PROFILER_UID( \ |
| 29 scoped_ignore) |
| 30 |
| 31 namespace trace_event_internal { |
| 32 |
| 33 class BASE_EXPORT HeapProfilerScopedIgnore { |
| 34 public: |
| 35 inline HeapProfilerScopedIgnore() { |
| 36 if (UNLIKELY( |
| 37 base::trace_event::AllocationContextTracker::capture_enabled())) { |
| 38 base::trace_event::AllocationContextTracker::GetInstanceForCurrentThread() |
| 39 ->begin_ignore_scope(); |
| 40 } |
| 41 } |
| 42 inline ~HeapProfilerScopedIgnore() { |
| 43 if (UNLIKELY( |
| 44 base::trace_event::AllocationContextTracker::capture_enabled())) { |
| 45 base::trace_event::AllocationContextTracker::GetInstanceForCurrentThread() |
| 46 ->end_ignore_scope(); |
| 47 } |
| 48 } |
| 49 }; |
| 50 |
| 51 } // namespace trace_event_internal |
| 52 |
| 53 #endif // BASE_TRACE_EVENT_HEAP_PROFILER_H |
OLD | NEW |