summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authorprimiano <primiano@chromium.org>2016-01-25 14:21:15 -0800
committerCommit bot <commit-bot@chromium.org>2016-01-25 22:22:46 +0000
commitd3a81abc8db50ba646915e3ef700c9ac45958c01 (patch)
treeb1e8448350270045421894eb3d719faeebb02817 /base
parentd372eb96f80c84cb73413fa014a35d7de41607d8 (diff)
downloadchromium_src-d3a81abc8db50ba646915e3ef700c9ac45958c01.zip
chromium_src-d3a81abc8db50ba646915e3ef700c9ac45958c01.tar.gz
chromium_src-d3a81abc8db50ba646915e3ef700c9ac45958c01.tar.bz2
Allocator cleanup: allocator_extension call directly into tcmalloc
After crrev.com/1584893002 base/ can use directly allocator. The grand plan is to dismantle all the indirection layer such that: - base is the only thing that knows about allocator-specific details. - non-base code uses only base abstractions and stops looking at USE_TCMALLOC build flags. This CL, specifically, addresses the profiling-related methods moving the tcmalloc-specific dependencies to base and base only. Other parts of the codebase will be cleaned up in separate CLs. Also this CL removes a stale base/debug/OWNERS. That file makes no sense these days as tracing has been moved to base/trace_event/. BUG=564618 Review URL: https://codereview.chromium.org/1607303002 Cr-Commit-Position: refs/heads/master@{#371335}
Diffstat (limited to 'base')
-rw-r--r--base/allocator/allocator_extension.cc36
-rw-r--r--base/allocator/allocator_extension.h18
-rw-r--r--base/debug/OWNERS3
-rw-r--r--base/debug/profiler.cc8
-rw-r--r--base/debug/profiler.h3
5 files changed, 29 insertions, 39 deletions
diff --git a/base/allocator/allocator_extension.cc b/base/allocator/allocator_extension.cc
index 4f0b3a90..17682f8 100644
--- a/base/allocator/allocator_extension.cc
+++ b/base/allocator/allocator_extension.cc
@@ -6,34 +6,32 @@
#include "base/logging.h"
+#if defined(USE_TCMALLOC)
+#include "third_party/tcmalloc/chromium/src/gperftools/heap-profiler.h"
+#include "third_party/tcmalloc/chromium/src/gperftools/malloc_extension.h"
+#endif
+
namespace base {
namespace allocator {
-namespace {
-ReleaseFreeMemoryFunction g_release_free_memory_function = nullptr;
-GetNumericPropertyFunction g_get_numeric_property_function = nullptr;
-}
-
void ReleaseFreeMemory() {
- if (g_release_free_memory_function)
- g_release_free_memory_function();
+#if defined(USE_TCMALLOC)
+ ::MallocExtension::instance()->ReleaseFreeMemory();
+#endif
}
bool GetNumericProperty(const char* name, size_t* value) {
- return g_get_numeric_property_function &&
- g_get_numeric_property_function(name, value);
-}
-
-void SetReleaseFreeMemoryFunction(
- ReleaseFreeMemoryFunction release_free_memory_function) {
- DCHECK(!g_release_free_memory_function);
- g_release_free_memory_function = release_free_memory_function;
+#if defined(USE_TCMALLOC)
+ return ::MallocExtension::instance()->GetNumericProperty(name, value);
+#endif
+ return false;
}
-void SetGetNumericPropertyFunction(
- GetNumericPropertyFunction get_numeric_property_function) {
- DCHECK(!g_get_numeric_property_function);
- g_get_numeric_property_function = get_numeric_property_function;
+bool IsHeapProfilerRunning() {
+#if defined(USE_TCMALLOC)
+ return ::IsHeapProfilerRunning();
+#endif
+ return false;
}
} // namespace allocator
diff --git a/base/allocator/allocator_extension.h b/base/allocator/allocator_extension.h
index 3be2cea..64bfd1c 100644
--- a/base/allocator/allocator_extension.h
+++ b/base/allocator/allocator_extension.h
@@ -13,9 +13,6 @@
namespace base {
namespace allocator {
-typedef void (*ReleaseFreeMemoryFunction)();
-typedef bool (*GetNumericPropertyFunction)(const char* name, size_t* value);
-
// Request that the allocator release any free memory it knows about to the
// system.
BASE_EXPORT void ReleaseFreeMemory();
@@ -26,20 +23,7 @@ BASE_EXPORT void ReleaseFreeMemory();
// |name| or |value| cannot be NULL
BASE_EXPORT bool GetNumericProperty(const char* name, size_t* value);
-// These settings allow specifying a callback used to implement the allocator
-// extension functions. These are optional, but if set they must only be set
-// once. These will typically called in an allocator-specific initialization
-// routine.
-//
-// No threading promises are made. The caller is responsible for making sure
-// these pointers are set before any other threads attempt to call the above
-// functions.
-
-BASE_EXPORT void SetReleaseFreeMemoryFunction(
- ReleaseFreeMemoryFunction release_free_memory_function);
-
-BASE_EXPORT void SetGetNumericPropertyFunction(
- GetNumericPropertyFunction get_numeric_property_function);
+BASE_EXPORT bool IsHeapProfilerRunning();
} // namespace allocator
} // namespace base
diff --git a/base/debug/OWNERS b/base/debug/OWNERS
deleted file mode 100644
index 4976ab1..0000000
--- a/base/debug/OWNERS
+++ /dev/null
@@ -1,3 +0,0 @@
-per-file trace_event*=nduca@chromium.org
-per-file trace_event*=dsinclair@chromium.org
-per-file trace_event_android.cc=wangxianzhu@chromium.org
diff --git a/base/debug/profiler.cc b/base/debug/profiler.cc
index 75e9aac..a205d1f 100644
--- a/base/debug/profiler.cc
+++ b/base/debug/profiler.cc
@@ -56,6 +56,10 @@ void RestartProfilingAfterFork() {
ProfilerRegisterThread();
}
+bool IsProfilingSupported() {
+ return true;
+}
+
#else
void StartProfiling(const std::string& name) {
@@ -74,6 +78,10 @@ bool BeingProfiled() {
void RestartProfilingAfterFork() {
}
+bool IsProfilingSupported() {
+ return false;
+}
+
#endif
#if !defined(OS_WIN)
diff --git a/base/debug/profiler.h b/base/debug/profiler.h
index 7cce7b0..ea81b13 100644
--- a/base/debug/profiler.h
+++ b/base/debug/profiler.h
@@ -38,6 +38,9 @@ BASE_EXPORT void RestartProfilingAfterFork();
// Returns true iff this executable is instrumented with the Syzygy profiler.
BASE_EXPORT bool IsBinaryInstrumented();
+// Returns true iff this executable supports profiling.
+BASE_EXPORT bool IsProfilingSupported();
+
// There's a class of profilers that use "return address swizzling" to get a
// hook on function exits. This class of profilers uses some form of entry hook,
// like e.g. binary instrumentation, or a compiler flag, that calls a hook each