summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authorwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-25 00:17:53 +0000
committerwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-25 00:17:53 +0000
commit3c4e3015463fd407ccd932e5da17e3c4bc8e3c5c (patch)
tree0d9eb8dc82e0514d1b77943bb452b75396f18dea /base
parentf820596a817c435611567e5131709162bfb6cfad (diff)
downloadchromium_src-3c4e3015463fd407ccd932e5da17e3c4bc8e3c5c.zip
chromium_src-3c4e3015463fd407ccd932e5da17e3c4bc8e3c5c.tar.gz
chromium_src-3c4e3015463fd407ccd932e5da17e3c4bc8e3c5c.tar.bz2
Enable TCMalloc on Linux by default.
This change also reworks the tcmalloc dependency to be added only to chrome and test_shell, instead of base. This is necessary since otherwise tcmalloc will be double initialized (by both the main executable and dlopen'd shared objects like the npapitestplugin.so). Add valgrind suppressions. This are invalid reads on static initialization in the VDSOSupport module. I haven't investigated it yet, but I suspect they're benign. BUG=http://crbug.com/28149, http://crbug.com/28385 Review URL: http://codereview.chromium.org/399081 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@33010 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r--base/base.gyp28
-rw-r--r--base/leak_annotations.h2
-rw-r--r--base/process_util_linux.cc12
-rw-r--r--base/process_util_unittest.cc15
4 files changed, 26 insertions, 31 deletions
diff --git a/base/base.gyp b/base/base.gyp
index 86e4996..f5b9b36 100644
--- a/base/base.gyp
+++ b/base/base.gyp
@@ -394,30 +394,12 @@
[ 'OS == "linux" or OS == "freebsd"', {
'sources/': [ ['exclude', '_(mac|win|chromeos)\\.cc$'],
['exclude', '\\.mm?$' ] ],
- 'variables' : {
- 'linux_use_heapchecker%' : 0,
- },
'conditions': [
[ 'chromeos==1 or toolkit_views==1', {
'sources/': [ ['include', '_chromeos\\.cc$'] ]
},
],
- [ 'linux_use_heapchecker==1', {
- 'defines': [
- 'LINUX_USE_HEAPCHECKER',
- ],
- 'direct_dependent_settings': {
- 'defines': [
- 'LINUX_USE_HEAPCHECKER',
- ],
- },
- },
- ],
- # linux_use_heapchecker==1 implies linux_use_tcmalloc=1.
- [ 'linux_use_tcmalloc==1 or linux_use_heapchecker==1', {
- 'dependencies': [
- '../third_party/tcmalloc/tcmalloc.gyp:tcmalloc',
- ],
+ [ 'linux_use_tcmalloc==1', {
'defines': [
'LINUX_USE_TCMALLOC',
],
@@ -713,6 +695,14 @@
'file_version_info_unittest.cc',
'worker_pool_linux_unittest.cc',
],
+ 'conditions': [
+ [ 'linux_use_tcmalloc==1', {
+ 'dependencies': [
+ '../third_party/tcmalloc/tcmalloc.gyp:tcmalloc',
+ ],
+ },
+ ],
+ ],
'dependencies': [
'../build/linux/system.gyp:gtk',
'../build/linux/system.gyp:nss',
diff --git a/base/leak_annotations.h b/base/leak_annotations.h
index aa57dff..7e652a5 100644
--- a/base/leak_annotations.h
+++ b/base/leak_annotations.h
@@ -5,7 +5,7 @@
#ifndef BASE_LEAK_ANNOTATIONS_H_
#define BASE_LEAK_ANNOTATIONS_H_
-#if defined(LINUX_USE_TCMALLOC) && defined(LINUX_USE_HEAPCHECKER)
+#if defined(LINUX_USE_TCMALLOC)
#include "third_party/tcmalloc/heap-checker.h"
diff --git a/base/process_util_linux.cc b/base/process_util_linux.cc
index 98508be..bd6bcf3 100644
--- a/base/process_util_linux.cc
+++ b/base/process_util_linux.cc
@@ -514,11 +514,7 @@ void OnNoMemory() {
extern "C" {
-#if defined(LINUX_USE_TCMALLOC)
-
-int tc_set_new_mode(int mode);
-
-#else // defined(LINUX_USE_TCMALLOC)
+#if !defined(LINUX_USE_TCMALLOC)
typedef void* (*malloc_type)(size_t size);
typedef void* (*valloc_type)(size_t size);
@@ -603,7 +599,7 @@ int posix_memalign(void** ptr, size_t alignment, size_t size) {
return ret;
}
-#endif // defined(LINUX_USE_TCMALLOC)
+#endif // !defined(LINUX_USE_TCMALLOC)
} // extern C
@@ -612,10 +608,6 @@ void EnableTerminationOnOutOfMemory() {
std::set_new_handler(&OnNoMemory);
// If we're using glibc's allocator, the above functions will override
// malloc and friends and make them die on out of memory.
-#if defined(LINUX_USE_TCMALLOC)
- // For tcmalloc, we just need to tell it to behave like new.
- tc_set_new_mode(1);
-#endif
}
} // namespace base
diff --git a/base/process_util_unittest.cc b/base/process_util_unittest.cc
index 3f53f2a..fe28502 100644
--- a/base/process_util_unittest.cc
+++ b/base/process_util_unittest.cc
@@ -365,8 +365,14 @@ TEST_F(ProcessUtilTest, ParseProcStatCPU) {
#endif // defined(OS_POSIX)
-#if defined(OS_LINUX)
// TODO(vandebo) make this work on Windows and Mac too.
+#if defined(OS_LINUX)
+
+#if defined(LINUX_USE_TCMALLOC)
+extern "C" {
+int tc_set_new_mode(int mode);
+}
+#endif // defined(LINUX_USE_TCMALLOC)
class OutOfMemoryTest : public testing::Test {
public:
@@ -381,6 +387,13 @@ class OutOfMemoryTest : public testing::Test {
// Must call EnableTerminationOnOutOfMemory() because that is called from
// chrome's main function and therefore hasn't been called yet.
EnableTerminationOnOutOfMemory();
+#if defined(LINUX_USE_TCMALLOC)
+ tc_set_new_mode(1);
+ }
+
+ virtual void TearDown() {
+ tc_set_new_mode(0);
+#endif // defined(LINUX_USE_TCMALLOC)
}
void* value_;