summaryrefslogtreecommitdiffstats
path: root/base/allocator
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/allocator
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/allocator')
-rw-r--r--base/allocator/allocator_extension.cc36
-rw-r--r--base/allocator/allocator_extension.h18
2 files changed, 18 insertions, 36 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